28#include "../../binary.h"
29#include "../../codec.h"
35template <
typename TestMsg>
void decode_check(
const TestMsg& msg_in)
37 dccl::dlog.
is(dccl::logger::INFO) && dccl::dlog <<
"Message in:\n" << msg_in.DebugString() << std::endl;
39 dccl::dlog.
is(dccl::logger::INFO) && dccl::dlog <<
"Try encode (in bounds)..." << std::endl;
41 codec.encode(&bytes, msg_in);
42 dccl::dlog.
is(dccl::logger::INFO) && dccl::dlog <<
"... got bytes (hex): " <<
dccl::hex_encode(bytes) << std::endl;
44 dccl::dlog.
is(dccl::logger::INFO) && dccl::dlog <<
"Try decode..." << std::endl;
47 codec.decode(bytes, &msg_out);
49 dccl::dlog.
is(dccl::logger::INFO) && dccl::dlog <<
"... got Message out:\n" << msg_out.DebugString() << std::endl;
52int main(
int argc,
char* argv[])
55 for (
int i = 1; i < argc; ++i)
57 if (argv[i] && argv[i][0] ==
'-' && argv[i][1] ==
'v' && argv[i][2] ==
'\0')
61 dccl::dlog.
connect(verbose ? dccl::logger::ALL :
dccl::logger::WARN_PLUS, &std::cerr);
63 codec.load<TestMsgOmit1>();
64 codec.info<TestMsgOmit1>();
66 codec.load<TestMsgOmit2>();
67 codec.info<TestMsgOmit2>();
69 codec.load<TestMsgNormal>();
70 codec.info<TestMsgNormal>();
101 codec.encode(&bytes, msg_in);
102 TestMsgNormalId3 msg_out;
107 codec.decode(bytes, &msg_out);
111 dccl::dlog.
is(dccl::logger::INFO) && dccl::dlog <<
"Caught expected exception: " << e.what() << std::endl;
115 dccl::dlog.
is(dccl::logger::INFO) && dccl::dlog <<
"all tests passed" << std::endl;
The Dynamic CCL enCODer/DECoder. This is the main class you will use to load, encode and decode DCCL ...
Exception class for DCCL.
bool is(logger::Verbosity verbosity, logger::Group group=logger::GENERAL)
Indicates the verbosity of the Logger until the next std::flush or std::endl. The boolean return is u...
void connect(int verbosity_mask, Slot slot)
Connect the output of one or more given verbosities to a slot (function pointer or similar)
Dynamic Compact Control Language namespace.
void hex_encode(CharIterator begin, CharIterator end, std::string *out, bool upper_case=false)
Encodes a (little-endian) hexadecimal string from a byte string. Index 0 of begin is written to index...