...
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#include <algorithm>
|
||||
#include <list>
|
||||
#include <print>
|
||||
|
||||
@@ -6,6 +7,8 @@
|
||||
|
||||
int main()
|
||||
{
|
||||
std::println("{:*^80}\n", " STOP-SEQ PROTOCOL ");
|
||||
|
||||
snplib::snplib_netproto_stopseq_t<> proto;
|
||||
|
||||
std::string bytes{"SET VAL1 10\n"};
|
||||
@@ -38,13 +41,13 @@ int main()
|
||||
}
|
||||
|
||||
|
||||
std::println("\n\n");
|
||||
std::println("\n");
|
||||
|
||||
bytes = "GET VAL2 1";
|
||||
bytes_vec = {std::from_range, bytes};
|
||||
bytes_lst = {std::from_range, bytes};
|
||||
|
||||
std::println("MSG: ", bytes_vec);
|
||||
std::println("MSG: {}", bytes_vec);
|
||||
|
||||
auto bs = proto.toBytes(bytes_vec);
|
||||
std::println("BYTES (from std::vector): {}", bs);
|
||||
@@ -55,5 +58,37 @@ int main()
|
||||
bytes_vec = proto.toBytes<decltype(bytes_vec)>(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<std::vector<char>>(blob);
|
||||
if (vmsg) {
|
||||
std::println("BLOB (from std::vector): {}", vmsg.value());
|
||||
} else {
|
||||
std::println("VMSG ERR: {}", vmsg.error().message());
|
||||
}
|
||||
|
||||
// std::array<char, 30> arr = bb_proto.toBytes<decltype(arr)>(bytes_lst);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -84,7 +84,7 @@ int main()
|
||||
std::println("valueSeq = '{}'", kvl.valueSeq<std::list<std::string>>());
|
||||
|
||||
|
||||
snplib_randoom_string_generator_t<> rstr_gen;
|
||||
snplib_random_string_generator_t<> rstr_gen;
|
||||
|
||||
std::println("\n\n");
|
||||
std::println("RAND STR: {}", rstr_gen.generate());
|
||||
|
||||
Reference in New Issue
Block a user