| 3901 | } |
| 3902 | |
| 3903 | void Parser::Serialize() { |
| 3904 | builder_.Clear(); |
| 3905 | AssignIndices(structs_.vec); |
| 3906 | AssignIndices(enums_.vec); |
| 3907 | std::vector<Offset<reflection::Object>> object_offsets; |
| 3908 | std::set<std::string> files; |
| 3909 | for (auto it = structs_.vec.begin(); it != structs_.vec.end(); ++it) { |
| 3910 | auto offset = (*it)->Serialize(&builder_, *this); |
| 3911 | object_offsets.push_back(offset); |
| 3912 | (*it)->serialized_location = offset.o; |
| 3913 | const std::string *file = (*it)->declaration_file; |
| 3914 | if (file) files.insert(*file); |
| 3915 | } |
| 3916 | std::vector<Offset<reflection::Enum>> enum_offsets; |
| 3917 | for (auto it = enums_.vec.begin(); it != enums_.vec.end(); ++it) { |
| 3918 | auto offset = (*it)->Serialize(&builder_, *this); |
| 3919 | enum_offsets.push_back(offset); |
| 3920 | const std::string *file = (*it)->declaration_file; |
| 3921 | if (file) files.insert(*file); |
| 3922 | } |
| 3923 | std::vector<Offset<reflection::Service>> service_offsets; |
| 3924 | for (auto it = services_.vec.begin(); it != services_.vec.end(); ++it) { |
| 3925 | auto offset = (*it)->Serialize(&builder_, *this); |
| 3926 | service_offsets.push_back(offset); |
| 3927 | const std::string *file = (*it)->declaration_file; |
| 3928 | if (file) files.insert(*file); |
| 3929 | } |
| 3930 | |
| 3931 | // Create Schemafiles vector of tables. |
| 3932 | flatbuffers::Offset< |
| 3933 | flatbuffers::Vector<flatbuffers::Offset<reflection::SchemaFile>>> |
| 3934 | schema_files__; |
| 3935 | if (!opts.project_root.empty()) { |
| 3936 | std::vector<Offset<reflection::SchemaFile>> schema_files; |
| 3937 | std::vector<Offset<flatbuffers::String>> included_files; |
| 3938 | for (auto f = files_included_per_file_.begin(); |
| 3939 | f != files_included_per_file_.end(); f++) { |
| 3940 | |
| 3941 | const auto filename__ = builder_.CreateSharedString(FilePath( |
| 3942 | opts.project_root, f->first, opts.binary_schema_absolute_paths)); |
| 3943 | for (auto i = f->second.begin(); i != f->second.end(); i++) { |
| 3944 | included_files.push_back(builder_.CreateSharedString( |
| 3945 | FilePath(opts.project_root, i->filename, opts.binary_schema_absolute_paths))); |
| 3946 | } |
| 3947 | const auto included_files__ = builder_.CreateVector(included_files); |
| 3948 | included_files.clear(); |
| 3949 | |
| 3950 | schema_files.push_back( |
| 3951 | reflection::CreateSchemaFile(builder_, filename__, included_files__)); |
| 3952 | } |
| 3953 | schema_files__ = builder_.CreateVectorOfSortedTables(&schema_files); |
| 3954 | } |
| 3955 | |
| 3956 | const auto objs__ = builder_.CreateVectorOfSortedTables(&object_offsets); |
| 3957 | const auto enum__ = builder_.CreateVectorOfSortedTables(&enum_offsets); |
| 3958 | const auto fiid__ = builder_.CreateString(file_identifier_); |
| 3959 | const auto fext__ = builder_.CreateString(file_extension_); |
| 3960 | const auto serv__ = builder_.CreateVectorOfSortedTables(&service_offsets); |
no test coverage detected