From fd836cad270f7eb9645356cd583c8f11bf737b0f Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Thu, 31 Dec 2015 00:31:00 -0300 Subject: -Ensure .tscn and .tres always save in a deterministic way, fixes #2495 -Scene edit state is saved outside the scene now, to avoid changes .tscn files when nothing really changed -Created a VariantWriter helper to unify all variant to text writing -Moved SceneFormatText writing to VariantWriter -Moved ConfigFile to use VariantWriter and VariantParser, added compatibility mode for old .cfg files that use engine.cfg format --- core/variant_parser.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'core/variant_parser.h') diff --git a/core/variant_parser.h b/core/variant_parser.h index e1d25f751..2bfb244fc 100644 --- a/core/variant_parser.h +++ b/core/variant_parser.h @@ -86,6 +86,7 @@ private: template static Error _parse_construct(Stream *p_stream, Vector& r_construct, int &line, String &r_err_str); + static Error _parse_enginecfg(Stream *p_stream, Vector& 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); @@ -100,4 +101,24 @@ public: static Error parse(Stream *p_stream, Variant &r_ret, String &r_err_str, int &r_err_line,ResourceParser *p_res_parser=NULL); }; + + + +class VariantWriter { +public: + + typedef Error (*StoreStringFunc)(void *ud,const String& p_string); + 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); + + +}; + + + + + + #endif // VARIANT_PARSER_H -- cgit v1.2.3-70-g09d2