Refactor FieldDef to model presense as an enum rather than 2 bools. (#6420)

* Define presence.

* Migrate to IsRequired and IsOptional methods

* moved stuff around

* Removed optional and required bools from FieldDef

* change assert to return error

* Fix tests.cpp

* MakeFieldPresence helper

* fmt

* old c++ compatibility stuff

Co-authored-by: Casper Neo <cneo@google.com>
This commit is contained in:
Casper
2021-01-25 12:29:43 -05:00
committed by GitHub
parent 0984d4328d
commit e581013e3d
14 changed files with 183 additions and 160 deletions

View File

@@ -136,7 +136,7 @@ std::string GenerateFBS(const Parser &parser, const std::string &file_name) {
GenComment(field.doc_comment, &schema, nullptr, " ");
schema += " " + field.name + ":" + GenType(field.value.type);
if (field.value.constant != "0") schema += " = " + field.value.constant;
if (field.required) schema += " (required)";
if (field.IsRequired()) schema += " (required)";
schema += ";\n";
}
}