12#include "flatbuffers/flatbuffers.h"
17#define SerializeFlatbufferText(TYPE, ITEM) Flat::FlatbufferInterface::SerializeHelper<TYPE>(ITEM, TYPE##Identifier())
18#define SerializeFlatbufferTextDirect(TYPE, BUFFER) Flat::FlatbufferInterface::BufferToText(BUFFER, TYPE##Identifier())
19#define CompileFlatbuffer(TYPE, SOURCE, TARGET) Flat::FlatbufferInterface::Compile(SOURCE, TARGET, TYPE##Identifier())
48 template<
typename BaseT,
typename ItemT>
static void DeserializeFlatbuffer(ItemT& item,
const uint8_t* buf);
67 flatbuffers::FlatBufferBuilder builder(65536);
68 builder.Finish(BaseT::Pack(builder, &item));
75template <
typename BaseT,
typename ItemT>
Util::Blob
78 flatbuffers::FlatBufferBuilder builder(65536);
79 builder.Finish(BaseT::Pack(builder, &item));
80 return Util::Blob(builder.GetBufferPointer(), builder.GetSize());
86template<
typename BaseT,
typename ItemT>
90 const BaseT* bItem = flatbuffers::GetRoot<BaseT>(buf);
91 bItem->UnPackTo(&item);
97template<
typename BaseT,
typename ItemT>
102 if (IO::IoServer::Instance()->ReadFile(file, contents))
104 const BaseT* bItem = flatbuffers::GetRoot<BaseT>(contents.
AsCharPtr());
105 bItem->UnPackTo(&item);
Definition flatbufferinterface.h:25
static void DeserializeFlatbufferFile(ItemT &item, IO::URI const &file)
Definition flatbufferinterface.h:99
static bool LoadSchema(IO::URI const &file)
Definition flatbufferinterface.cc:135
static Util::String SerializeHelper(ItemT const &item, const char *ident)
Helper function, use SerializeFlatbuffer macro instead.
Definition flatbufferinterface.h:63
static void Init()
Initialize datastructures and load all schema files in export.
Definition flatbufferinterface.cc:126
static Util::Blob SerializeFlatbuffer(ItemT const &item)
Serialize to binary blob.
Definition flatbufferinterface.h:76
static bool Compile(IO::URI const &source, IO::URI const &targetFolder, const char *ident)
compile flatbuffer json to binary
Definition flatbufferinterface.cc:183
static bool CompileSchema(IO::URI const &file)
Definition flatbufferinterface.cc:143
static Util::String SerializeToText(const uint8_t *buf)
static bool HasSchema(Util::StringAtom identifier)
Definition flatbufferinterface.cc:165
static void DeserializeFlatbuffer(ItemT &item, const uint8_t *buf)
Definition flatbufferinterface.h:88
static Util::String BufferToText(const uint8_t *buffer, Util::StringAtom identifier)
Definition flatbufferinterface.cc:173
An URI object can split a Uniform Resource Identifier string into its components or build a string fr...
Definition uri.h:67
The Util::Blob class encapsulates a chunk of raw memory into a C++ object which can be copied,...
Definition blob.h:22
A StringAtom.
Definition stringatom.h:22
#define n_assert(exp)
Definition debug.h:50
Flatbuffer to Nebula type conversion functions.
Definition flatbufferinterface.h:22
Nebula's universal string class.
Definition string.h:50
const char * AsCharPtr() const
return contents as character pointer
Definition string.h:540