aboutsummaryrefslogtreecommitdiff
path: root/include/flatbuffers/idl.h
diff options
context:
space:
mode:
authorVladimir Glavnyy <31897320+vglavnyy@users.noreply.github.com>2018-10-12 00:37:47 +0700
committerWouter van Oortmerssen <aardappel@gmail.com>2018-10-11 10:37:47 -0700
commit4ed6fafdfa5689d72e821baec522a9d03ee6d652 (patch)
treeace83b909c40043f8a0d2776b3b184085b49ebb7 /include/flatbuffers/idl.h
parent53ce80ce916d3cb1e3b28562cc2a27229e8afea7 (diff)
downloadflatbuffers-4ed6fafdfa5689d72e821baec522a9d03ee6d652.tar.gz
Refactoring of idl_parser (#4948)
* Refactoring of numbers parser More accurate parse of float and double. Hexadecimal floats. Check "out-of-range" of uint64 fields. Check correctness of default values and metadata. * Remove locale-independent code strtod/strtof from PR #4948. * small optimization * Add is_(ascii) functions * is_ascii cleanup * Fix format conversation * Refine number parser * Make code compatible with Android build * Remove unnecessary suppression of warning C4127
Diffstat (limited to 'include/flatbuffers/idl.h')
-rw-r--r--include/flatbuffers/idl.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/include/flatbuffers/idl.h b/include/flatbuffers/idl.h
index cf5446a2..024f324e 100644
--- a/include/flatbuffers/idl.h
+++ b/include/flatbuffers/idl.h
@@ -484,7 +484,11 @@ struct IDLOptions {
// This encapsulates where the parser is in the current source file.
struct ParserState {
ParserState()
- : cursor_(nullptr), line_start_(nullptr), line_(0), token_(-1) {}
+ : cursor_(nullptr),
+ line_start_(nullptr),
+ line_(0),
+ token_(-1),
+ attr_is_trivial_ascii_string_(true) {}
protected:
void ResetState(const char *source) {
@@ -508,6 +512,10 @@ struct ParserState {
int line_; // the current line being parsed
int token_;
+ // Flag: text in attribute_ is true ASCII string without escape
+ // sequences. Only printable ASCII (without [\t\r\n]).
+ // Used for number-in-string (and base64 string in future).
+ bool attr_is_trivial_ascii_string_;
std::string attribute_;
std::vector<std::string> doc_comment_;
};
@@ -644,7 +652,8 @@ class Parser : public ParserState {
bool ParseFlexBuffer(const char *source, const char *source_filename,
flexbuffers::Builder *builder);
- FLATBUFFERS_CHECKED_ERROR CheckInRange(int64_t val, int64_t min, int64_t max);
+ FLATBUFFERS_CHECKED_ERROR InvalidNumber(const char *number,
+ const std::string &msg);
StructDef *LookupStruct(const std::string &id) const;
@@ -711,7 +720,7 @@ class Parser : public ParserState {
BaseType req, bool *destmatch);
FLATBUFFERS_CHECKED_ERROR ParseHash(Value &e, FieldDef* field);
FLATBUFFERS_CHECKED_ERROR TokenError();
- FLATBUFFERS_CHECKED_ERROR ParseSingleValue(const std::string *name, Value &e);
+ FLATBUFFERS_CHECKED_ERROR ParseSingleValue(const std::string *name, Value &e, bool check_now);
FLATBUFFERS_CHECKED_ERROR ParseEnumFromString(Type &type, int64_t *result);
StructDef *LookupCreateStruct(const std::string &name,
bool create_if_new = true,