#include #include #include #include int main() { std::println("{:*^80}\n", " STOP-SEQ PROTOCOL "); snplib::snplib_netproto_stopseq_t<> proto; std::string bytes{"SET VAL1 10\n"}; std::vector bytes_vec{std::from_range, bytes}; std::list bytes_lst{std::from_range, bytes}; std::println("BYTES VEC: {}", bytes_vec); auto msg = proto.fromBytes(bytes_vec); if (msg) { std::println("MSG (from std::vector): {}", msg.value()); } else { std::println("MSG ERR: {}", msg.error().message()); } auto msg_l = proto.fromBytes(bytes_lst); if (msg_l) { std::println("MSG (from std::list): {}", msg_l.value()); } else { std::println("MSG ERR: {}", msg_l.error().message()); } auto vmsg = proto.fromBytes>(bytes_lst); if (vmsg) { std::println("VMSG (from std::list): {}", vmsg.value()); } else { std::println("VMSG ERR: {}", vmsg.error().message()); } std::println("\n"); bytes = "GET VAL2 1"; bytes_vec = {std::from_range, bytes}; bytes_lst = {std::from_range, bytes}; std::println("MSG: {}", bytes_vec); auto bs = proto.toBytes(bytes_vec); std::println("BYTES (from std::vector): {}", bs); auto bs1 = proto.toBytes(bytes_lst); std::println("BYTES (from std::list): {}", bs1); bytes_vec = proto.toBytes(bytes_lst); std::println("BYTES: {}", bytes_vec); std::println("\n\n{:*^80}\n", " BINARY-BLOB PROTOCOL "); snplib::snplib_netproto_binary_blob_t<> bb_proto; snplib::snplib_random_string_generator_t<> rstr_gen; bytes = rstr_gen.generate(15); bytes_vec = {std::from_range, bytes}; bytes_lst = {std::from_range, bytes}; std::println("BLOB: {}", bytes); bs = bb_proto.toBytes(bytes_vec); std::println("BYTES (from std::vector): {}", bs); auto bs2 = bb_proto.toBytes(bytes_lst); std::println("BYTES (from std::list): {}", bs2); auto blob = std::vector(std::from_range, bs | std::views::join); std::println("\nBYTES: {}", blob); vmsg = bb_proto.fromBytes>(blob); if (vmsg) { std::println("BLOB (from std::vector): {}", vmsg.value()); } else { std::println("VMSG ERR: {}", vmsg.error().message()); } // std::array arr = bb_proto.toBytes(bytes_lst); return 0; }