summaryrefslogtreecommitdiff
path: root/src/idl_gen_text.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/idl_gen_text.cpp')
-rw-r--r--src/idl_gen_text.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/idl_gen_text.cpp b/src/idl_gen_text.cpp
index fb75a795..4c61ff99 100644
--- a/src/idl_gen_text.cpp
+++ b/src/idl_gen_text.cpp
@@ -263,6 +263,23 @@ static bool GenStruct(const StructDef &struct_def, const Table *table,
}
// Generate a text representation of a flatbuffer in JSON format.
+bool GenerateTextFromTable(const Parser &parser, const void *table,
+ const std::string &table_name, std::string *_text) {
+ auto struct_def = parser.LookupStruct(table_name);
+ if (struct_def == nullptr) {
+ return false;
+ }
+ auto text = *_text;
+ text.reserve(1024); // Reduce amount of inevitable reallocs.
+ auto root = static_cast<const Table *>(table);
+ if (!GenStruct(*struct_def, root, 0, parser.opts, _text)) {
+ return false;
+ }
+ text += NewLine(parser.opts);
+ return true;
+}
+
+// Generate a text representation of a flatbuffer in JSON format.
bool GenerateText(const Parser &parser, const void *flatbuffer,
std::string *_text) {
std::string &text = *_text;