ONE - On-device Neural Engine
Loading...
Searching...
No Matches
flatbuffers::Registry Class Reference

#include <registry.h>

Public Member Functions

void Register (const char *file_identifier, const char *schema_path)
 
bool FlatBufferToText (const uint8_t *flatbuf, size_t len, std::string *dest)
 
DetachedBuffer TextToFlatBuffer (const char *text, const char *file_identifier)
 
void SetOptions (const IDLOptions &opts)
 
void AddIncludeDirectory (const char *path)
 
const std::string & GetLastError ()
 

Detailed Description

Definition at line 29 of file registry.h.

Member Function Documentation

◆ AddIncludeDirectory()

void flatbuffers::Registry::AddIncludeDirectory ( const char *  path)
inline

Definition at line 86 of file registry.h.

86{ include_paths_.push_back(path); }

◆ FlatBufferToText()

bool flatbuffers::Registry::FlatBufferToText ( const uint8_t *  flatbuf,
size_t  len,
std::string *  dest 
)
inline

Definition at line 41 of file registry.h.

41 {
42 // Get the identifier out of the buffer.
43 // If the buffer is truncated, exit.
44 if (len < sizeof(uoffset_t) + kFileIdentifierLength) {
45 lasterror_ = "buffer truncated";
46 return false;
47 }
48 std::string ident(
49 reinterpret_cast<const char *>(flatbuf) + sizeof(uoffset_t),
50 kFileIdentifierLength);
51 // Load and parse the schema.
52 Parser parser;
53 if (!LoadSchema(ident, &parser)) return false;
54 // Now we're ready to generate text.
55 auto err = GenText(parser, flatbuf, dest);
56 if (err) {
57 lasterror_ =
58 "unable to generate text for FlatBuffer binary: " + std::string(err);
59 return false;
60 }
61 return true;
62 }
const char * GenText(const Parser &parser, const void *flatbuffer, std::string *text)
parser
Definition infer.py:17

References flatbuffers::GenText().

◆ GetLastError()

const std::string & flatbuffers::Registry::GetLastError ( )
inline

Definition at line 89 of file registry.h.

89{ return lasterror_; }

◆ Register()

void flatbuffers::Registry::Register ( const char *  file_identifier,
const char *  schema_path 
)
inline

Definition at line 33 of file registry.h.

33 {
34 Schema schema;
35 schema.path_ = schema_path;
36 schemas_[file_identifier] = schema;
37 }

◆ SetOptions()

void flatbuffers::Registry::SetOptions ( const IDLOptions opts)
inline

Definition at line 82 of file registry.h.

82{ opts_ = opts; }

◆ TextToFlatBuffer()

DetachedBuffer flatbuffers::Registry::TextToFlatBuffer ( const char *  text,
const char *  file_identifier 
)
inline

Definition at line 67 of file registry.h.

68 {
69 // Load and parse the schema.
70 Parser parser;
71 if (!LoadSchema(file_identifier, &parser)) return DetachedBuffer();
72 // Parse the text.
73 if (!parser.Parse(text)) {
74 lasterror_ = parser.error_;
75 return DetachedBuffer();
76 }
77 // We have a valid FlatBuffer. Detach it from the builder and return.
78 return parser.builder_.Release();
79 }

The documentation for this class was generated from the following file: