mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-04 20:48:59 +00:00
[C++] Add ParseJson(), Parser(Parser&&), update fuzzers (#6284)
- add a new method ParseJson to minimize failures during fuzzing - add default (conditional) move-constructor for Parser - add a new monster_fuzzer - switch fuzzers to C++17 and `test/cpp17` generated code
This commit is contained in:
@@ -197,6 +197,7 @@ namespace flatbuffers {
|
||||
#if (!defined(_MSC_VER) || _MSC_FULL_VER >= 180020827) && \
|
||||
(!defined(__GNUC__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 404)) || \
|
||||
defined(__clang__)
|
||||
#define FLATBUFFERS_DEFAULT_DECLARATION
|
||||
#define FLATBUFFERS_DELETE_FUNC(func) func = delete;
|
||||
#else
|
||||
#define FLATBUFFERS_DELETE_FUNC(func) private: func;
|
||||
|
||||
@@ -1240,7 +1240,7 @@ class FlatBufferBuilder {
|
||||
}
|
||||
|
||||
/// @brief Get the serialized buffer (after you call `Finish()`) as a span.
|
||||
/// @return Returns a constructed flatbuffers::span that is a view over the
|
||||
/// @return Returns a constructed flatbuffers::span that is a view over the
|
||||
/// FlatBuffer data inside the buffer.
|
||||
flatbuffers::span<uint8_t> GetBufferSpan() const {
|
||||
Finished();
|
||||
|
||||
@@ -908,6 +908,11 @@ class Builder FLATBUFFERS_FINAL_CLASS {
|
||||
buf_.clear();
|
||||
}
|
||||
|
||||
#ifdef FLATBUFFERS_DEFAULT_DECLARATION
|
||||
Builder(Builder &&) = default;
|
||||
Builder &operator=(Builder &&) = default;
|
||||
#endif
|
||||
|
||||
/// @brief Get the serialized buffer (after you call `Finish()`).
|
||||
/// @return Returns a vector owned by this class.
|
||||
const std::vector<uint8_t> &GetBuffer() const {
|
||||
|
||||
@@ -804,6 +804,11 @@ class Parser : public ParserState {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FLATBUFFERS_DEFAULT_DECLARATION
|
||||
Parser(Parser&&) = default;
|
||||
Parser& operator=(Parser&&) = default;
|
||||
#endif
|
||||
|
||||
// Parse the string containing either schema or JSON data, which will
|
||||
// populate the SymbolTable's or the FlatBufferBuilder above.
|
||||
// include_paths is used to resolve any include statements, and typically
|
||||
@@ -818,6 +823,8 @@ class Parser : public ParserState {
|
||||
bool Parse(const char *_source, const char **include_paths = nullptr,
|
||||
const char *source_filename = nullptr);
|
||||
|
||||
bool ParseJson(const char *json, const char *json_filename = nullptr);
|
||||
|
||||
// Set the root type. May override the one set in the schema.
|
||||
bool SetRootType(const char *name);
|
||||
|
||||
@@ -945,6 +952,7 @@ class Parser : public ParserState {
|
||||
const char **include_paths,
|
||||
const char *source_filename,
|
||||
const char *include_filename);
|
||||
FLATBUFFERS_CHECKED_ERROR DoParseJson();
|
||||
FLATBUFFERS_CHECKED_ERROR CheckClash(std::vector<FieldDef *> &fields,
|
||||
StructDef *struct_def,
|
||||
const char *suffix, BaseType baseType);
|
||||
|
||||
Reference in New Issue
Block a user