diff --git a/include/snipplib/network/snplib_netmsg.h b/include/snipplib/network/snplib_netmsg.h new file mode 100644 index 0000000..cd5996e --- /dev/null +++ b/include/snipplib/network/snplib_netmsg.h @@ -0,0 +1,64 @@ +#pragma once + +#include "../utils/snplib_keyvalue_expr.h" + +/* + A SIMPLE NETWORK MESSAGE + + + format: + keywordvalue1value2value3...valueN + + e.g.: + 1) keyword-only: + 'key1' + 2) keyword-value (=" "): + 'key value' + 2) keyword-value-seq (=" =", =", "): + 'key = value1, value2, value3' + */ + + +namespace snplib +{ + +static constexpr char SNPLIB_DEFAULT_NETMSG_KEYVALUE_DELIM[] = "="; +static constexpr char SNPLIB_DEFAULT_NETMSG_VALUEVALUE_DELIM[] = ","; + + +template > +class snplib_netmsg_t : public snplib_keyvalue_expr_t +{ +protected: + using base_t = snplib_keyvalue_expr_t; + + std::conditional_t, void> _byteSeq{}; + +public: + using base_t::config_t; + + using base_t::base_t; + + snplib_netmsg_t(base_t::config_t config = {.keyval_delim = SNPLIB_DEFAULT_NETMSG_KEYVALUE_DELIM, + .valseq_delim = SNPLIB_DEFAULT_NETMSG_VALUEVALUE_DELIM}) + requires(base_t::mutableContent) + : base_t(_byteSeq, std::move(config)) + { + } + + ~snplib_netmsg_t() = default; + + template + static snplib_netmsg_t fromBytes(R&& r) + { + return base_t::fromByteSequence(); + } + + + template + OR toBytes() + { + } +}; + +} // namespace snplib \ No newline at end of file