10 #ifndef logger_types_flatbuffer_log_hpp
11 #define logger_types_flatbuffer_log_hpp
13 #include "flatbuffers/flatbuffers.h"
14 #include "flatbuffers/idl.h"
16 #include "../logMeta.hpp"
47 return msg.builder.GetSize();
57 uint8_t * cbuff =
reinterpret_cast<uint8_t *
>(msgBuffer);
59 memcpy(cbuff,
msg.builder.GetBufferPointer(),
msg.builder.GetSize());
64 static std::string
msgJSON(
void * msgBuffer,
66 const uint8_t * binarySchema,
67 const unsigned int binarySchemaLength
70 static_cast<void>(len);
71 flatbuffers::Parser parser;
72 parser.opts.output_default_scalars_in_json =
true;
73 parser.opts.output_enum_identifiers =
true;
74 parser.opts.strict_json =
true;
75 parser.opts.indent_step = -1;
76 bool ok = parser.Deserialize(binarySchema, binarySchemaLength);
78 std::cerr << __FILE__ <<
":" << __LINE__ <<
" Failed to deserialize binary schema\n";
81 flatbuffers::GenText(parser, msgBuffer, &output);
msgLen2T msgLenT
The type used to refer to the message length, regardless of length.
Message type for resolving log messages with a f.b. builder.
flatbuffers::FlatBufferBuilder builder
Base class for logs consisting of a flatbuffer message.
static int format(void *msgBuffer, const fbMessage &msg)
Format the buffer given the input message.
static std::string msgJSON(void *msgBuffer, flatlogs::msgLenT len, const uint8_t *binarySchema, const unsigned int binarySchemaLength)
static flatlogs::msgLenT length(const fbMessage &msg)
Get the length of the message.