Refactor FlatC to receive FlatCOptions (#7770)

* Refactor FlatC to receive `FlatCOptions`

* switch to c++11 unique_ptr
This commit is contained in:
Derek Bailey
2023-01-08 13:29:00 -08:00
committed by GitHub
parent 5638a6a900
commit 641fbe4658
4 changed files with 222 additions and 145 deletions

View File

@@ -298,7 +298,7 @@ struct FieldDef : public Definition {
presence(kDefault),
nested_flatbuffer(nullptr),
padding(0),
sibling_union_field(nullptr){}
sibling_union_field(nullptr) {}
Offset<reflection::Field> Serialize(FlatBufferBuilder *builder, uint16_t id,
const Parser &parser) const;
@@ -803,7 +803,7 @@ struct ParserState {
FLATBUFFERS_ASSERT(cursor_ && line_start_ && cursor_ >= line_start_);
return static_cast<int64_t>(cursor_ - line_start_);
}
const char *prev_cursor_;
const char *cursor_;
const char *line_start_;
@@ -910,6 +910,13 @@ class Parser : public ParserState {
known_attributes_["private"] = true;
}
// Copying is not allowed
Parser(const Parser &) = delete;
Parser &operator=(const Parser &) = delete;
Parser(Parser &&) = default;
Parser &operator=(Parser &&) = default;
~Parser() {
for (auto it = namespaces_.begin(); it != namespaces_.end(); ++it) {
delete *it;