Lines Matching refs:code_
65 code_ += "#include \"" + *it + "\""; in GenIncludeDependencies()
73 code_ += "#include \"" + parser_.opts.include_prefix + basename + in GenIncludeDependencies()
78 if (num_includes) code_ += ""; in GenIncludeDependencies()
86 code_.Clear(); in generate()
87 code_ += "// " + std::string(FlatBuffersGeneratedWarning()); in generate()
90 code_ += "#ifndef " + include_guard; in generate()
91 code_ += "#define " + include_guard; in generate()
92 code_ += ""; in generate()
94 code_ += "#include \"flatbuffers/flatbuffers.h\""; in generate()
95 code_ += ""; in generate()
110 code_ += "struct " + struct_def.name + ";"; in generate()
112 code_ += "struct " + NativeName(struct_def.name) + ";"; in generate()
114 code_ += ""; in generate()
173 code_.SetValue("STRUCT_NAME", name); in generate()
174 code_.SetValue("CPP_NAME", cpp_name); in generate()
177 code_ += "inline \\"; in generate()
178 code_ += "const {{CPP_NAME}} *Get{{STRUCT_NAME}}(const void *buf) {"; in generate()
179 code_ += " return flatbuffers::GetRoot<{{CPP_NAME}}>(buf);"; in generate()
180 code_ += "}"; in generate()
181 code_ += ""; in generate()
184 code_ += "inline \\"; in generate()
185 code_ += "{{STRUCT_NAME}} *GetMutable{{STRUCT_NAME}}(void *buf) {"; in generate()
186 code_ += " return flatbuffers::GetMutableRoot<{{STRUCT_NAME}}>(buf);"; in generate()
187 code_ += "}"; in generate()
188 code_ += ""; in generate()
193 code_ += "inline const char *{{STRUCT_NAME}}Identifier() {"; in generate()
194 code_ += " return \"" + parser_.file_identifier_ + "\";"; in generate()
195 code_ += "}"; in generate()
196 code_ += ""; in generate()
199 code_ += "inline \\"; in generate()
200 code_ += "bool {{STRUCT_NAME}}BufferHasIdentifier(const void *buf) {"; in generate()
201 code_ += " return flatbuffers::BufferHasIdentifier("; in generate()
202 code_ += " buf, {{STRUCT_NAME}}Identifier());"; in generate()
203 code_ += "}"; in generate()
204 code_ += ""; in generate()
209 code_.SetValue("ID", name + "Identifier()"); in generate()
211 code_.SetValue("ID", "nullptr"); in generate()
214 code_ += "inline bool Verify{{STRUCT_NAME}}Buffer("; in generate()
215 code_ += " flatbuffers::Verifier &verifier) {"; in generate()
216 code_ += " return verifier.VerifyBuffer<{{CPP_NAME}}>({{ID}});"; in generate()
217 code_ += "}"; in generate()
218 code_ += ""; in generate()
222 code_ += "inline const char *{{STRUCT_NAME}}Extension() {"; in generate()
223 code_ += " return \"" + parser_.file_extension_ + "\";"; in generate()
224 code_ += "}"; in generate()
225 code_ += ""; in generate()
229 code_ += "inline void Finish{{STRUCT_NAME}}Buffer("; in generate()
230 code_ += " flatbuffers::FlatBufferBuilder &fbb,"; in generate()
231 code_ += " flatbuffers::Offset<{{CPP_NAME}}> root) {"; in generate()
233 code_ += " fbb.Finish(root, {{STRUCT_NAME}}Identifier());"; in generate()
235 code_ += " fbb.Finish(root);"; in generate()
236 code_ += "}"; in generate()
237 code_ += ""; in generate()
243 code_.SetValue("UNPACK_RETURN", in generate()
245 code_.SetValue("UNPACK_TYPE", in generate()
248 code_ += "inline {{UNPACK_RETURN}} UnPack{{STRUCT_NAME}}("; in generate()
249 code_ += " const void *buf,"; in generate()
250 code_ += " const flatbuffers::resolver_function_t *res = nullptr) {"; in generate()
251 code_ += " return {{UNPACK_TYPE}}\\"; in generate()
252 code_ += "(Get{{STRUCT_NAME}}(buf)->UnPack(res));"; in generate()
253 code_ += "}"; in generate()
254 code_ += ""; in generate()
262 code_ += "#endif // " + include_guard; in generate()
265 const auto final_code = code_.ToString(); in generate()
270 CodeWriter code_; member in flatbuffers::cpp::CppGenerator
292 code_ += text + "\\"; in GenComment()
521 code_.SetValue("ENUM_NAME", enum_def.name); in GenEnum()
522 code_.SetValue("BASE_TYPE", GenTypeBasic(enum_def.underlying_type, false)); in GenEnum()
523 code_.SetValue("SEP", ""); in GenEnum()
526 code_ += GenEnumDecl(enum_def) + "\\"; in GenEnum()
528 code_ += " : {{BASE_TYPE}}\\"; in GenEnum()
529 code_ += " {"; in GenEnum()
538 code_.SetValue("KEY", GenEnumValDecl(enum_def, ev.name)); in GenEnum()
539 code_.SetValue("VALUE", NumToString(ev.value)); in GenEnum()
540 code_ += "{{SEP}} {{KEY}} = {{VALUE}}\\"; in GenEnum()
541 code_.SetValue("SEP", ",\n"); in GenEnum()
551 code_.SetValue("SEP", ",\n"); in GenEnum()
553 code_.SetValue("KEY", GenEnumValDecl(enum_def, "NONE")); in GenEnum()
554 code_.SetValue("VALUE", "0"); in GenEnum()
555 code_ += "{{SEP}} {{KEY}} = {{VALUE}}\\"; in GenEnum()
557 code_.SetValue("KEY", GenEnumValDecl(enum_def, "ANY")); in GenEnum()
558 code_.SetValue("VALUE", NumToString(anyv)); in GenEnum()
559 code_ += "{{SEP}} {{KEY}} = {{VALUE}}\\"; in GenEnum()
561 code_.SetValue("KEY",GenEnumValDecl(enum_def, "MIN")); in GenEnum()
562 code_.SetValue("VALUE", GenEnumValDecl(enum_def, minv->name)); in GenEnum()
563 code_ += "{{SEP}} {{KEY}} = {{VALUE}}\\"; in GenEnum()
565 code_.SetValue("KEY",GenEnumValDecl(enum_def, "MAX")); in GenEnum()
566 code_.SetValue("VALUE", GenEnumValDecl(enum_def, maxv->name)); in GenEnum()
567 code_ += "{{SEP}} {{KEY}} = {{VALUE}}\\"; in GenEnum()
570 code_ += ""; in GenEnum()
571 code_ += "};"; in GenEnum()
574 code_ += "DEFINE_BITMASK_OPERATORS({{ENUM_NAME}}, {{BASE_TYPE}})"; in GenEnum()
576 code_ += ""; in GenEnum()
589 code_ += "inline const char **EnumNames{{ENUM_NAME}}() {"; in GenEnum()
590 code_ += " static const char *names[] = {"; in GenEnum()
597 code_ += " \"\","; in GenEnum()
599 code_ += " \"" + ev.name + "\","; in GenEnum()
601 code_ += " nullptr"; in GenEnum()
602 code_ += " };"; in GenEnum()
604 code_ += " return names;"; in GenEnum()
605 code_ += "}"; in GenEnum()
606 code_ += ""; in GenEnum()
608 code_ += "inline const char *EnumName{{ENUM_NAME}}({{ENUM_NAME}} e) {"; in GenEnum()
610 code_ += " const size_t index = static_cast<int>(e)\\"; in GenEnum()
613 code_ += " - static_cast<int>(" + vals + ")\\"; in GenEnum()
615 code_ += ";"; in GenEnum()
617 code_ += " return EnumNames{{ENUM_NAME}}()[index];"; in GenEnum()
618 code_ += "}"; in GenEnum()
619 code_ += ""; in GenEnum()
629 code_ += "template<typename T> struct {{ENUM_NAME}}Traits {"; in GenEnum()
633 code_ += "template<> struct {{ENUM_NAME}}Traits<" + name + "> {"; in GenEnum()
637 code_ += " static const {{ENUM_NAME}} enum_value = " + value + ";"; in GenEnum()
638 code_ += "};"; in GenEnum()
639 code_ += ""; in GenEnum()
645 code_.SetValue("NAME", enum_def.name); in GenEnum()
646 code_.SetValue("NONE", in GenEnum()
649 code_ += "struct {{NAME}}Union {"; in GenEnum()
650 code_ += " {{NAME}} type;"; in GenEnum()
651 code_ += " flatbuffers::NativeTable *table;"; in GenEnum()
652 code_ += ""; in GenEnum()
653 code_ += " {{NAME}}Union() : type({{NONE}}), table(nullptr) {}"; in GenEnum()
654 code_ += " {{NAME}}Union({{NAME}}Union&& u):"; in GenEnum()
655 code_ += " type(std::move(u.type)), table(std::move(u.table)) {}"; in GenEnum()
656 code_ += " {{NAME}}Union(const {{NAME}}Union &);"; in GenEnum()
657 code_ += " {{NAME}}Union &operator=(const {{NAME}}Union &);"; in GenEnum()
658 code_ += " ~{{NAME}}Union() { Reset(); }"; in GenEnum()
659 code_ += ""; in GenEnum()
660 code_ += " void Reset();"; in GenEnum()
661 code_ += ""; in GenEnum()
662 code_ += " template <typename T>"; in GenEnum()
663 code_ += " void Set(T&& value) {"; in GenEnum()
664 code_ += " Reset();"; in GenEnum()
665 code_ += " type = {{NAME}}Traits<typename T::TableType>::enum_value;"; in GenEnum()
666 code_ += " if (type != {{NONE}}) {"; in GenEnum()
667 code_ += " table = new T(std::forward<T>(value));"; in GenEnum()
668 code_ += " }"; in GenEnum()
669 code_ += " }"; in GenEnum()
670 code_ += ""; in GenEnum()
671 code_ += " " + UnionUnPackSignature(enum_def, true) + ";"; in GenEnum()
672 code_ += " " + UnionPackSignature(enum_def, true) + ";"; in GenEnum()
673 code_ += ""; in GenEnum()
683 code_.SetValue("NATIVE_TYPE", native_type); in GenEnum()
684 code_.SetValue("NATIVE_NAME", ev.name); in GenEnum()
685 code_.SetValue("NATIVE_ID", GetEnumValUse(enum_def, ev)); in GenEnum()
687 code_ += " {{NATIVE_TYPE}} *As{{NATIVE_NAME}}() {"; in GenEnum()
688 code_ += " return type == {{NATIVE_ID}} ?"; in GenEnum()
689 code_ += " reinterpret_cast<{{NATIVE_TYPE}} *>(table) : nullptr;"; in GenEnum()
690 code_ += " }"; in GenEnum()
692 code_ += "};"; in GenEnum()
693 code_ += ""; in GenEnum()
697 code_ += UnionVerifySignature(enum_def) + ";"; in GenEnum()
698 code_ += UnionVectorVerifySignature(enum_def) + ";"; in GenEnum()
699 code_ += ""; in GenEnum()
709 code_.SetValue("ENUM_NAME", enum_def.name); in GenUnionPost()
711 code_ += "inline " + UnionVerifySignature(enum_def) + " {"; in GenUnionPost()
712 code_ += " switch (type) {"; in GenUnionPost()
716 code_.SetValue("LABEL", GetEnumValUse(enum_def, ev)); in GenUnionPost()
719 code_.SetValue("TYPE", WrapInNameSpace(*ev.struct_def)); in GenUnionPost()
720 code_ += " case {{LABEL}}: {"; in GenUnionPost()
721 code_ += " auto ptr = reinterpret_cast<const {{TYPE}} *>(obj);"; in GenUnionPost()
722 code_ += " return verifier.VerifyTable(ptr);"; in GenUnionPost()
723 code_ += " }"; in GenUnionPost()
725 code_ += " case {{LABEL}}: {"; in GenUnionPost()
726 code_ += " return true;"; // "NONE" enum value. in GenUnionPost()
727 code_ += " }"; in GenUnionPost()
730 code_ += " default: return false;"; in GenUnionPost()
731 code_ += " }"; in GenUnionPost()
732 code_ += "}"; in GenUnionPost()
733 code_ += ""; in GenUnionPost()
735 code_ += "inline " + UnionVectorVerifySignature(enum_def) + " {"; in GenUnionPost()
736 code_ += " if (values->size() != types->size()) return false;"; in GenUnionPost()
737 code_ += " for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) {"; in GenUnionPost()
738 code_ += " if (!Verify" + enum_def.name + "("; in GenUnionPost()
739 code_ += " verifier, values->Get(i), types->GetEnum<" + enum_def.name + ">(i))) {"; in GenUnionPost()
740 code_ += " return false;"; in GenUnionPost()
741 code_ += " }"; in GenUnionPost()
742 code_ += " }"; in GenUnionPost()
743 code_ += " return true;"; in GenUnionPost()
744 code_ += "}"; in GenUnionPost()
745 code_ += ""; in GenUnionPost()
749 code_ += "inline " + UnionUnPackSignature(enum_def, false) + " {"; in GenUnionPost()
750 code_ += " switch (type) {"; in GenUnionPost()
758 code_.SetValue("LABEL", GetEnumValUse(enum_def, ev)); in GenUnionPost()
759 code_.SetValue("TYPE", WrapInNameSpace(*ev.struct_def)); in GenUnionPost()
760 code_ += " case {{LABEL}}: {"; in GenUnionPost()
761 code_ += " auto ptr = reinterpret_cast<const {{TYPE}} *>(obj);"; in GenUnionPost()
762 code_ += " return ptr->UnPack(resolver);"; in GenUnionPost()
763 code_ += " }"; in GenUnionPost()
765 code_ += " default: return nullptr;"; in GenUnionPost()
766 code_ += " }"; in GenUnionPost()
767 code_ += "}"; in GenUnionPost()
768 code_ += ""; in GenUnionPost()
770 code_ += "inline " + UnionPackSignature(enum_def, false) + " {"; in GenUnionPost()
771 code_ += " switch (type) {"; in GenUnionPost()
779 code_.SetValue("LABEL", GetEnumValUse(enum_def, ev)); in GenUnionPost()
780 code_.SetValue("TYPE", NativeName(WrapInNameSpace(*ev.struct_def))); in GenUnionPost()
781 code_.SetValue("NAME", ev.struct_def->name); in GenUnionPost()
782 code_ += " case {{LABEL}}: {"; in GenUnionPost()
783 code_ += " auto ptr = reinterpret_cast<const {{TYPE}} *>(table);"; in GenUnionPost()
784 code_ += " return Create{{NAME}}(_fbb, ptr, _rehasher).Union();"; in GenUnionPost()
785 code_ += " }"; in GenUnionPost()
787 code_ += " default: return 0;"; in GenUnionPost()
788 code_ += " }"; in GenUnionPost()
789 code_ += "}"; in GenUnionPost()
790 code_ += ""; in GenUnionPost()
793 code_.SetValue("NONE", in GenUnionPost()
796 code_ += "inline void {{ENUM_NAME}}Union::Reset() {"; in GenUnionPost()
797 code_ += " switch (type) {"; in GenUnionPost()
805 code_.SetValue("LABEL", GetEnumValUse(enum_def, ev)); in GenUnionPost()
806 code_.SetValue("TYPE", NativeName(WrapInNameSpace(*ev.struct_def))); in GenUnionPost()
808 code_ += " case {{LABEL}}: {"; in GenUnionPost()
809 code_ += " auto ptr = reinterpret_cast<{{TYPE}} *>(table);"; in GenUnionPost()
810 code_ += " delete ptr;"; in GenUnionPost()
811 code_ += " break;"; in GenUnionPost()
812 code_ += " }"; in GenUnionPost()
814 code_ += " default: break;"; in GenUnionPost()
815 code_ += " }"; in GenUnionPost()
816 code_ += " table = nullptr;"; in GenUnionPost()
817 code_ += " type = {{NONE}};"; in GenUnionPost()
818 code_ += "}"; in GenUnionPost()
819 code_ += ""; in GenUnionPost()
853 code_.SetValue("NAME", fullname); in GenFullyQualifiedNameGetter()
854 code_.SetValue("CONSTEXPR", "FLATBUFFERS_CONSTEXPR"); in GenFullyQualifiedNameGetter()
856 code_ += " static {{CONSTEXPR}} const char *GetFullyQualifiedName() {"; in GenFullyQualifiedNameGetter()
857 code_ += " return \"{{NAME}}\";"; in GenFullyQualifiedNameGetter()
858 code_ += " }"; in GenFullyQualifiedNameGetter()
886 code_.SetValue("PRE", prefix); in GenParam()
887 code_.SetValue("PARAM_NAME", field.name); in GenParam()
889 code_.SetValue("PARAM_TYPE", "const char *"); in GenParam()
890 code_.SetValue("PARAM_VALUE", "nullptr"); in GenParam()
893 code_.SetValue("PARAM_TYPE", "const std::vector<" + type + "> *"); in GenParam()
894 code_.SetValue("PARAM_VALUE", "nullptr"); in GenParam()
896 code_.SetValue("PARAM_TYPE", GenTypeWire(field.value.type, " ", true)); in GenParam()
897 code_.SetValue("PARAM_VALUE", GetDefaultScalarValue(field)); in GenParam()
899 code_ += "{{PRE}}{{PARAM_TYPE}}{{PARAM_NAME}} = {{PARAM_VALUE}}\\"; in GenParam()
909 code_.SetValue("FIELD_TYPE", full_type); in GenMember()
910 code_.SetValue("FIELD_NAME", field.name); in GenMember()
911 code_ += " {{FIELD_TYPE}}{{FIELD_NAME}};"; in GenMember()
955 code_.SetValue("NATIVE_NAME", NativeName(struct_def.name)); in GenDefaultConstructor()
956 code_.SetValue("INIT_LIST", initializer_list); in GenDefaultConstructor()
958 code_ += " {{NATIVE_NAME}}(){{INIT_LIST}} {"; in GenDefaultConstructor()
959 code_ += " }"; in GenDefaultConstructor()
964 code_.SetValue("STRUCT_NAME", struct_def.name); in GenNativeTable()
965 code_.SetValue("NATIVE_NAME", native_name); in GenNativeTable()
968 code_ += "struct {{NATIVE_NAME}} : public flatbuffers::NativeTable {"; in GenNativeTable()
969 code_ += " typedef {{STRUCT_NAME}} TableType;"; in GenNativeTable()
976 code_ += "};"; in GenNativeTable()
977 code_ += ""; in GenNativeTable()
982 code_.SetValue("PRE", prefix); in GenVerifyCall()
983 code_.SetValue("NAME", field.name); in GenVerifyCall()
984 code_.SetValue("REQUIRED", field.required ? "Required" : ""); in GenVerifyCall()
985 code_.SetValue("SIZE", GenTypeSize(field.value.type)); in GenVerifyCall()
986 code_.SetValue("OFFSET", GenFieldOffsetName(field)); in GenVerifyCall()
987 code_ += "{{PRE}}VerifyField{{REQUIRED}}<{{SIZE}}>(verifier, {{OFFSET}})\\"; in GenVerifyCall()
991 code_.SetValue("ENUM_NAME", field.value.type.enum_def->name); in GenVerifyCall()
992 code_.SetValue("SUFFIX", UnionTypeFieldSuffix()); in GenVerifyCall()
993 code_ += "{{PRE}}Verify{{ENUM_NAME}}(verifier, {{NAME}}(), " in GenVerifyCall()
999 code_ += "{{PRE}}verifier.VerifyTable({{NAME}}())\\"; in GenVerifyCall()
1004 code_ += "{{PRE}}verifier.Verify({{NAME}}())\\"; in GenVerifyCall()
1008 code_ += "{{PRE}}verifier.Verify({{NAME}}())\\"; in GenVerifyCall()
1012 code_ += "{{PRE}}verifier.VerifyVectorOfStrings({{NAME}}())\\"; in GenVerifyCall()
1017 code_ += "{{PRE}}verifier.VerifyVectorOfTables({{NAME}}())\\"; in GenVerifyCall()
1022 code_.SetValue("ENUM_NAME", field.value.type.enum_def->name); in GenVerifyCall()
1023 code_ += "{{PRE}}Verify{{ENUM_NAME}}Vector(verifier, {{NAME}}(), {{NAME}}_type())\\"; in GenVerifyCall()
1047 code_.SetValue("STRUCT_NAME", struct_def.name); in GenTable()
1048 code_ += "struct {{STRUCT_NAME}} FLATBUFFERS_FINAL_CLASS" in GenTable()
1051 code_ += " typedef {{NATIVE_NAME}} NativeTableType;"; in GenTable()
1060 code_.SetValue("SEP", ""); in GenTable()
1061 code_ += " enum {"; in GenTable()
1070 code_.SetValue("OFFSET_NAME", GenFieldOffsetName(field)); in GenTable()
1071 code_.SetValue("OFFSET_VALUE", NumToString(field.value.offset)); in GenTable()
1072 code_ += "{{SEP}} {{OFFSET_NAME}} = {{OFFSET_VALUE}}\\"; in GenTable()
1073 code_.SetValue("SEP", ",\n"); in GenTable()
1075 code_ += ""; in GenTable()
1076 code_ += " };"; in GenTable()
1090 code_.SetValue("FIELD_NAME", field.name); in GenTable()
1113 code_.SetValue("FIELD_TYPE", in GenTable()
1115 code_.SetValue("FIELD_VALUE", GenUnderlyingCast(field, true, call)); in GenTable()
1117 code_ += " {{FIELD_TYPE}}{{FIELD_NAME}}() const {"; in GenTable()
1118 code_ += " return {{FIELD_VALUE}};"; in GenTable()
1119 code_ += " }"; in GenTable()
1123 code_.SetValue("OFFSET_NAME", offset_str); in GenTable()
1124 code_.SetValue("FIELD_TYPE", GenTypeBasic(field.value.type, true)); in GenTable()
1125 code_.SetValue("FIELD_VALUE", in GenTable()
1128 code_ += " bool mutate_{{FIELD_NAME}}({{FIELD_TYPE}} " in GenTable()
1130 code_ += " return SetField({{OFFSET_NAME}}, {{FIELD_VALUE}});"; in GenTable()
1131 code_ += " }"; in GenTable()
1135 code_.SetValue("FIELD_TYPE", type); in GenTable()
1136 code_.SetValue("FIELD_VALUE", in GenTable()
1139 code_ += " {{FIELD_TYPE}}mutable_{{FIELD_NAME}}() {"; in GenTable()
1140 code_ += " return {{FIELD_VALUE}};"; in GenTable()
1141 code_ += " }"; in GenTable()
1153 code_.SetValue("CPP_NAME", TranslateNameSpace(qualified_name)); in GenTable()
1155 code_ += " const {{CPP_NAME}} *{{FIELD_NAME}}_nested_root() const {"; in GenTable()
1156 code_ += " const uint8_t* data = {{FIELD_NAME}}()->Data();"; in GenTable()
1157 code_ += " return flatbuffers::GetRoot<{{CPP_NAME}}>(data);"; in GenTable()
1158 code_ += " }"; in GenTable()
1165 code_ += " bool KeyCompareLessThan(const {{STRUCT_NAME}} *o) const {"; in GenTable()
1167 code_ += " return *{{FIELD_NAME}}() < *o->{{FIELD_NAME}}();"; in GenTable()
1169 code_ += " return {{FIELD_NAME}}() < o->{{FIELD_NAME}}();"; in GenTable()
1171 code_ += " }"; in GenTable()
1174 code_ += " int KeyCompareWithValue(const char *val) const {"; in GenTable()
1175 code_ += " return strcmp({{FIELD_NAME}}()->c_str(), val);"; in GenTable()
1176 code_ += " }"; in GenTable()
1184 code_.SetValue("KEY_TYPE", type); in GenTable()
1185 code_ += " int KeyCompareWithValue({{KEY_TYPE}} val) const {"; in GenTable()
1186 code_ += " const auto key = {{FIELD_NAME}}();"; in GenTable()
1187 code_ += " if (key < val) {"; in GenTable()
1188 code_ += " return -1;"; in GenTable()
1189 code_ += " } else if (key > val) {"; in GenTable()
1190 code_ += " return 1;"; in GenTable()
1191 code_ += " } else {"; in GenTable()
1192 code_ += " return 0;"; in GenTable()
1193 code_ += " }"; in GenTable()
1194 code_ += " }"; in GenTable()
1201 code_ += " bool Verify(flatbuffers::Verifier &verifier) const {"; in GenTable()
1202 code_ += " return VerifyTableStart(verifier)\\"; in GenTable()
1212 code_ += " &&\n verifier.EndTable();"; in GenTable()
1213 code_ += " }"; in GenTable()
1217 code_ += " " + TableUnPackSignature(struct_def, true) + ";"; in GenTable()
1218 code_ += " " + TableUnPackToSignature(struct_def, true) + ";"; in GenTable()
1219 code_ += " " + TablePackSignature(struct_def, true) + ";"; in GenTable()
1222 code_ += "};"; // End of table. in GenTable()
1223 code_ += ""; in GenTable()
1230 code_ += TableCreateSignature(struct_def, true) + ";"; in GenTable()
1231 code_ += ""; in GenTable()
1236 code_.SetValue("STRUCT_NAME", struct_def.name); in GenBuilders()
1239 code_ += "struct {{STRUCT_NAME}}Builder {"; in GenBuilders()
1240 code_ += " flatbuffers::FlatBufferBuilder &fbb_;"; in GenBuilders()
1241 code_ += " flatbuffers::uoffset_t start_;"; in GenBuilders()
1263 code_.SetValue("FIELD_NAME", field.name); in GenBuilders()
1264 code_.SetValue("FIELD_TYPE", GenTypeWire(field.value.type, " ", true)); in GenBuilders()
1265 code_.SetValue("ADD_OFFSET", struct_def.name + "::" + offset); in GenBuilders()
1266 code_.SetValue("ADD_NAME", name); in GenBuilders()
1267 code_.SetValue("ADD_VALUE", value); in GenBuilders()
1270 code_.SetValue("ADD_FN", "AddElement<" + type + ">"); in GenBuilders()
1272 code_.SetValue("ADD_FN", "AddStruct"); in GenBuilders()
1274 code_.SetValue("ADD_FN", "AddOffset"); in GenBuilders()
1277 code_ += " void add_{{FIELD_NAME}}({{FIELD_TYPE}}{{FIELD_NAME}}) {"; in GenBuilders()
1278 code_ += " fbb_.{{ADD_FN}}(\\"; in GenBuilders()
1280 code_ += "{{ADD_OFFSET}}, {{ADD_NAME}}, {{ADD_VALUE}});"; in GenBuilders()
1282 code_ += "{{ADD_OFFSET}}, {{ADD_NAME}});"; in GenBuilders()
1284 code_ += " }"; in GenBuilders()
1289 code_ += " {{STRUCT_NAME}}Builder(flatbuffers::FlatBufferBuilder &_fbb)"; in GenBuilders()
1290 code_ += " : fbb_(_fbb) {"; in GenBuilders()
1291 code_ += " start_ = fbb_.StartTable();"; in GenBuilders()
1292 code_ += " }"; in GenBuilders()
1295 code_ += " {{STRUCT_NAME}}Builder &operator=" in GenBuilders()
1300 code_ += " flatbuffers::Offset<{{STRUCT_NAME}}> Finish() {"; in GenBuilders()
1301 code_ += " const auto end = fbb_.EndTable(start_, " + num_fields + ");"; in GenBuilders()
1302 code_ += " auto o = flatbuffers::Offset<{{STRUCT_NAME}}>(end);"; in GenBuilders()
1308 code_.SetValue("FIELD_NAME", field.name); in GenBuilders()
1309 code_.SetValue("OFFSET_NAME", GenFieldOffsetName(field)); in GenBuilders()
1310 code_ += " fbb_.Required(o, {{STRUCT_NAME}}::{{OFFSET_NAME}});"; in GenBuilders()
1313 code_ += " return o;"; in GenBuilders()
1314 code_ += " }"; in GenBuilders()
1315 code_ += "};"; in GenBuilders()
1316 code_ += ""; in GenBuilders()
1320 code_ += "inline flatbuffers::Offset<{{STRUCT_NAME}}> " in GenBuilders()
1322 code_ += " flatbuffers::FlatBufferBuilder &_fbb\\"; in GenBuilders()
1330 code_ += ") {"; in GenBuilders()
1332 code_ += " {{STRUCT_NAME}}Builder builder_(_fbb);"; in GenBuilders()
1340 code_.SetValue("FIELD_NAME", field.name); in GenBuilders()
1341 code_ += " builder_.add_{{FIELD_NAME}}({{FIELD_NAME}});"; in GenBuilders()
1345 code_ += " return builder_.Finish();"; in GenBuilders()
1346 code_ += "}"; in GenBuilders()
1347 code_ += ""; in GenBuilders()
1351 code_ += "inline flatbuffers::Offset<{{STRUCT_NAME}}> " in GenBuilders()
1353 code_ += " flatbuffers::FlatBufferBuilder &_fbb\\"; in GenBuilders()
1364 code_.SetValue("CREATE_NAME", TranslateNameSpace(qualified_create_name)); in GenBuilders()
1366 code_ += ") {"; in GenBuilders()
1367 code_ += " return {{CREATE_NAME}}{{STRUCT_NAME}}("; in GenBuilders()
1368 code_ += " _fbb\\"; in GenBuilders()
1373 code_.SetValue("FIELD_NAME", field.name); in GenBuilders()
1376 code_ += ",\n {{FIELD_NAME}} ? " in GenBuilders()
1380 code_ += ",\n {{FIELD_NAME}} ? " in GenBuilders()
1383 code_ += ",\n {{FIELD_NAME}}\\"; in GenBuilders()
1387 code_ += ");"; in GenBuilders()
1388 code_ += "}"; in GenBuilders()
1389 code_ += ""; in GenBuilders()
1609 code_.SetValue("STRUCT_NAME", struct_def.name); in GenTablePost()
1610 code_.SetValue("NATIVE_NAME", NativeName(struct_def.name)); in GenTablePost()
1614 code_ += "inline " + TableUnPackSignature(struct_def, false) + " {"; in GenTablePost()
1615 code_ += " auto _o = new {{NATIVE_NAME}}();"; in GenTablePost()
1616 code_ += " UnPackTo(_o, _resolver);"; in GenTablePost()
1617 code_ += " return _o;"; in GenTablePost()
1618 code_ += "}"; in GenTablePost()
1619 code_ += ""; in GenTablePost()
1621 code_ += "inline " + TableUnPackToSignature(struct_def, false) + " {"; in GenTablePost()
1622 code_ += " (void)_o;"; in GenTablePost()
1623 code_ += " (void)_resolver;"; in GenTablePost()
1639 code_.SetValue("FIELD_NAME", field.name); in GenTablePost()
1643 code_ += std::string(prefix) + check + statement + postfix; in GenTablePost()
1645 code_ += "}"; in GenTablePost()
1646 code_ += ""; in GenTablePost()
1650 code_ += "inline " + TablePackSignature(struct_def, false) + " {"; in GenTablePost()
1651 code_ += " return Create{{STRUCT_NAME}}(_fbb, _o, _rehasher);"; in GenTablePost()
1652 code_ += "}"; in GenTablePost()
1653 code_ += ""; in GenTablePost()
1656 code_ += "inline " + TableCreateSignature(struct_def, false) + " {"; in GenTablePost()
1657 code_ += " (void)_rehasher;"; in GenTablePost()
1658 code_ += " (void)_o;"; in GenTablePost()
1666 code_ += " auto _" + field.name + " = " + GenCreateParam(field) + ";"; in GenTablePost()
1670 code_.SetValue("CREATE_NAME", TranslateNameSpace(qualified_create_name)); in GenTablePost()
1672 code_ += " return {{CREATE_NAME}}{{STRUCT_NAME}}("; in GenTablePost()
1673 code_ += " _fbb\\"; in GenTablePost()
1694 code_ += ",\n &_" + field.name + "\\"; in GenTablePost()
1696 code_ += ",\n _" + field.name + "\\"; in GenTablePost()
1699 code_ += ");"; in GenTablePost()
1700 code_ += "}"; in GenTablePost()
1701 code_ += ""; in GenTablePost()
1741 code_.SetValue("ALIGN", NumToString(struct_def.minalign)); in GenStruct()
1742 code_.SetValue("STRUCT_NAME", struct_def.name); in GenStruct()
1744 code_ += "MANUALLY_ALIGNED_STRUCT({{ALIGN}}) " in GenStruct()
1746 code_ += " private:"; in GenStruct()
1752 code_.SetValue("FIELD_TYPE", in GenStruct()
1754 code_.SetValue("FIELD_NAME", field.name); in GenStruct()
1755 code_ += " {{FIELD_TYPE}}{{FIELD_NAME}}_;"; in GenStruct()
1760 code_ += padding; in GenStruct()
1765 code_ += ""; in GenStruct()
1766 code_ += " public:"; in GenStruct()
1770 code_ += " {{STRUCT_NAME}}() {"; in GenStruct()
1771 code_ += " memset(this, 0, sizeof({{STRUCT_NAME}}));"; in GenStruct()
1772 code_ += " }"; in GenStruct()
1775 code_ += " {{STRUCT_NAME}}(const {{STRUCT_NAME}} &_o) {"; in GenStruct()
1776 code_ += " memcpy(this, &_o, sizeof({{STRUCT_NAME}}));"; in GenStruct()
1777 code_ += " }"; in GenStruct()
1809 code_.SetValue("ARG_LIST", arg_list); in GenStruct()
1810 code_.SetValue("INIT_LIST", init_list); in GenStruct()
1811 code_ += " {{STRUCT_NAME}}({{ARG_LIST}})"; in GenStruct()
1812 code_ += " : {{INIT_LIST}} {"; in GenStruct()
1820 code_ += padding; in GenStruct()
1823 code_ += " }"; in GenStruct()
1837 code_.SetValue("FIELD_NAME", field.name); in GenStruct()
1838 code_.SetValue("FIELD_TYPE", field_type); in GenStruct()
1839 code_.SetValue("FIELD_VALUE", GenUnderlyingCast(field, true, value)); in GenStruct()
1842 code_ += " {{FIELD_TYPE}}{{FIELD_NAME}}() const {"; in GenStruct()
1843 code_ += " return {{FIELD_VALUE}};"; in GenStruct()
1844 code_ += " }"; in GenStruct()
1848 code_.SetValue("ARG", GenTypeBasic(field.value.type, true)); in GenStruct()
1849 code_.SetValue("FIELD_VALUE", in GenStruct()
1852 code_ += " void mutate_{{FIELD_NAME}}({{ARG}} _{{FIELD_NAME}}) {"; in GenStruct()
1853 code_ += " flatbuffers::WriteScalar(&{{FIELD_NAME}}_, " in GenStruct()
1855 code_ += " }"; in GenStruct()
1857 code_ += " {{FIELD_TYPE}}mutable_{{FIELD_NAME}}() {"; in GenStruct()
1858 code_ += " return {{FIELD_NAME}}_;"; in GenStruct()
1859 code_ += " }"; in GenStruct()
1863 code_ += "};"; in GenStruct()
1865 code_.SetValue("STRUCT_BYTE_SIZE", NumToString(struct_def.bytesize)); in GenStruct()
1866 code_ += "STRUCT_END({{STRUCT_NAME}}, {{STRUCT_BYTE_SIZE}});"; in GenStruct()
1867 code_ += ""; in GenStruct()
1897 code_ += "} // namespace " + cur_name_space_->components[j - 1]; in SetNameSpace()
1900 code_ += ""; in SetNameSpace()
1906 code_ += "namespace " + ns->components[j] + " {"; in SetNameSpace()
1909 code_ += ""; in SetNameSpace()