summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorWouter van Oortmerssen <wvo@google.com>2014-11-17 17:27:26 -0800
committerWouter van Oortmerssen <wvo@google.com>2014-11-19 11:06:17 -0800
commit0952143971bdbb5ef20dae8a865e811a0e31b4b3 (patch)
treee5886d0e82dacb16685721d8c36c4ce1969fce78 /include
parent0ce53c96c30fe5438edf50251ca60b7655db1f2a (diff)
downloadflatbuffers-0952143971bdbb5ef20dae8a865e811a0e31b4b3.tar.gz
flatbuffers-0952143971bdbb5ef20dae8a865e811a0e31b4b3.tar.bz2
flatbuffers-0952143971bdbb5ef20dae8a865e811a0e31b4b3.zip
Added user defined attribute declarations.
This is such that if you mis-spell an attribute, it doesn't get silently ignored. Bug: 18294628 Change-Id: I10013f5b2a21048b7daba2e9410678f528e09761 Tested: on Linux.
Diffstat (limited to 'include')
-rw-r--r--include/flatbuffers/idl.h26
1 files changed, 18 insertions, 8 deletions
diff --git a/include/flatbuffers/idl.h b/include/flatbuffers/idl.h
index f7b747cc..eccd1d84 100644
--- a/include/flatbuffers/idl.h
+++ b/include/flatbuffers/idl.h
@@ -18,6 +18,7 @@
#define FLATBUFFERS_IDL_H_
#include <map>
+#include <set>
#include <memory>
#include <functional>
@@ -260,14 +261,21 @@ struct EnumDef : public Definition {
class Parser {
public:
- Parser(bool proto_mode = false) :
- root_struct_def(nullptr),
- source_(nullptr),
- cursor_(nullptr),
- line_(1),
- proto_mode_(proto_mode) {
- // Just in case none are declared:
- namespaces_.push_back(new Namespace());
+ Parser(bool proto_mode = false)
+ : root_struct_def(nullptr),
+ source_(nullptr),
+ cursor_(nullptr),
+ line_(1),
+ proto_mode_(proto_mode) {
+ // Just in case none are declared:
+ namespaces_.push_back(new Namespace());
+ known_attributes_.insert("deprecated");
+ known_attributes_.insert("required");
+ known_attributes_.insert("id");
+ known_attributes_.insert("force_align");
+ known_attributes_.insert("bit_flags");
+ known_attributes_.insert("original_order");
+ known_attributes_.insert("nested_flatbuffer");
}
~Parser() {
@@ -345,6 +353,8 @@ class Parser {
std::vector<std::pair<Value, FieldDef *>> field_stack_;
std::vector<uint8_t> struct_stack_;
+
+ std::set<std::string> known_attributes_;
};
// Utility functions for multiple generators: