diff options
Diffstat (limited to 'core/variant_parser.h')
-rw-r--r-- | core/variant_parser.h | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/core/variant_parser.h b/core/variant_parser.h index d50842145c..b55d7b2df0 100644 --- a/core/variant_parser.h +++ b/core/variant_parser.h @@ -38,45 +38,40 @@ class VariantParser { public: struct Stream { - virtual CharType get_char() = 0; virtual bool is_utf8() const = 0; virtual bool is_eof() const = 0; - CharType saved; + CharType saved = 0; - Stream() : - saved(0) {} + Stream() {} virtual ~Stream() {} }; struct StreamFile : public Stream { - - FileAccess *f; + FileAccess *f = nullptr; virtual CharType get_char(); virtual bool is_utf8() const; virtual bool is_eof() const; - StreamFile() { f = NULL; } + StreamFile() {} }; struct StreamString : public Stream { - String s; - int pos; + int pos = 0; virtual CharType get_char(); virtual bool is_utf8() const; virtual bool is_eof() const; - StreamString() { pos = 0; } + StreamString() {} }; typedef Error (*ParseResourceFunc)(void *p_self, Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str); struct ResourceParser { - void *userdata = nullptr; ParseResourceFunc func; ParseResourceFunc ext_func; @@ -113,13 +108,11 @@ public: }; struct Token { - TokenType type; Variant value; }; struct Tag { - String name; Map<String, Variant> fields; }; @@ -130,17 +123,17 @@ private: template <class T> static Error _parse_construct(Stream *p_stream, Vector<T> &r_construct, int &line, String &r_err_str); static Error _parse_enginecfg(Stream *p_stream, Vector<String> &strings, int &line, String &r_err_str); - static Error _parse_dictionary(Dictionary &object, Stream *p_stream, int &line, String &r_err_str, ResourceParser *p_res_parser = NULL); - static Error _parse_array(Array &array, Stream *p_stream, int &line, String &r_err_str, ResourceParser *p_res_parser = NULL); - static Error _parse_tag(Token &token, Stream *p_stream, int &line, String &r_err_str, Tag &r_tag, ResourceParser *p_res_parser = NULL, bool p_simple_tag = false); + static Error _parse_dictionary(Dictionary &object, Stream *p_stream, int &line, String &r_err_str, ResourceParser *p_res_parser = nullptr); + static Error _parse_array(Array &array, Stream *p_stream, int &line, String &r_err_str, ResourceParser *p_res_parser = nullptr); + static Error _parse_tag(Token &token, Stream *p_stream, int &line, String &r_err_str, Tag &r_tag, ResourceParser *p_res_parser = nullptr, bool p_simple_tag = false); public: - static Error parse_tag(Stream *p_stream, int &line, String &r_err_str, Tag &r_tag, ResourceParser *p_res_parser = NULL, bool p_simple_tag = false); - static Error parse_tag_assign_eof(Stream *p_stream, int &line, String &r_err_str, Tag &r_tag, String &r_assign, Variant &r_value, ResourceParser *p_res_parser = NULL, bool p_simple_tag = false); + static Error parse_tag(Stream *p_stream, int &line, String &r_err_str, Tag &r_tag, ResourceParser *p_res_parser = nullptr, bool p_simple_tag = false); + static Error parse_tag_assign_eof(Stream *p_stream, int &line, String &r_err_str, Tag &r_tag, String &r_assign, Variant &r_value, ResourceParser *p_res_parser = nullptr, bool p_simple_tag = false); - static Error parse_value(Token &token, Variant &value, Stream *p_stream, int &line, String &r_err_str, ResourceParser *p_res_parser = NULL); + static Error parse_value(Token &token, Variant &value, Stream *p_stream, int &line, String &r_err_str, ResourceParser *p_res_parser = nullptr); static Error get_token(Stream *p_stream, Token &r_token, int &line, String &r_err_str); - static Error parse(Stream *p_stream, Variant &r_ret, String &r_err_str, int &r_err_line, ResourceParser *p_res_parser = NULL); + static Error parse(Stream *p_stream, Variant &r_ret, String &r_err_str, int &r_err_line, ResourceParser *p_res_parser = nullptr); }; class VariantWriter { @@ -149,7 +142,7 @@ public: typedef String (*EncodeResourceFunc)(void *ud, const RES &p_resource); static Error write(const Variant &p_variant, StoreStringFunc p_store_string_func, void *p_store_string_ud, EncodeResourceFunc p_encode_res_func, void *p_encode_res_ud); - static Error write_to_string(const Variant &p_variant, String &r_string, EncodeResourceFunc p_encode_res_func = NULL, void *p_encode_res_ud = NULL); + static Error write_to_string(const Variant &p_variant, String &r_string, EncodeResourceFunc p_encode_res_func = nullptr, void *p_encode_res_ud = nullptr); }; #endif // VARIANT_PARSER_H |