summaryrefslogtreecommitdiff
path: root/core/variant_parser.h
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2017-03-05 16:44:50 +0100
committerRémi Verschelde <rverschelde@gmail.com>2017-03-05 16:44:50 +0100
commit5dbf1809c6e3e905b94b8764e99491e608122261 (patch)
tree5e5a5360db15d86d59ec8c6e4f7eb511388c5a9a /core/variant_parser.h
parent45438e9918d421b244bfd7776a30e67dc7f2d3e3 (diff)
A Whole New World (clang-format edition)
I can show you the code Pretty, with proper whitespace Tell me, coder, now when did You last write readable code? I can open your eyes Make you see your bad indent Force you to respect the style The core devs agreed upon A whole new world A new fantastic code format A de facto standard With some sugar Enforced with clang-format A whole new world A dazzling style we all dreamed of And when we read it through It's crystal clear That now we're in a whole new world of code
Diffstat (limited to 'core/variant_parser.h')
-rw-r--r--core/variant_parser.h66
1 files changed, 25 insertions, 41 deletions
diff --git a/core/variant_parser.h b/core/variant_parser.h
index c69673b0e4..20cc72f20d 100644
--- a/core/variant_parser.h
+++ b/core/variant_parser.h
@@ -29,22 +29,21 @@
#ifndef VARIANT_PARSER_H
#define VARIANT_PARSER_H
-#include "variant.h"
#include "os/file_access.h"
#include "resource.h"
+#include "variant.h"
class VariantParser {
public:
-
struct Stream {
- virtual CharType get_char()=0;
- virtual bool is_utf8() const=0;
- virtual bool is_eof() const=0;
+ virtual CharType get_char() = 0;
+ virtual bool is_utf8() const = 0;
+ virtual bool is_eof() const = 0;
CharType saved;
- Stream() { saved=0; }
+ Stream() { saved = 0; }
virtual ~Stream() {}
};
@@ -56,8 +55,7 @@ public:
virtual bool is_utf8() const;
virtual bool is_eof() const;
- StreamFile() { f=NULL; }
-
+ StreamFile() { f = NULL; }
};
struct StreamString : public Stream {
@@ -69,11 +67,10 @@ public:
virtual bool is_utf8() const;
virtual bool is_eof() const;
- StreamString() { pos=0; }
-
+ StreamString() { pos = 0; }
};
- typedef Error (*ParseResourceFunc)(void* p_self, Stream* p_stream,Ref<Resource>& r_res,int &line,String &r_err_str);
+ typedef Error (*ParseResourceFunc)(void *p_self, Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str);
struct ResourceParser {
@@ -81,7 +78,6 @@ public:
ParseResourceFunc func;
ParseResourceFunc ext_func;
ParseResourceFunc sub_func;
-
};
enum TokenType {
@@ -121,47 +117,35 @@ public:
struct Tag {
String name;
- Map<String,Variant> fields;
+ Map<String, Variant> fields;
};
private:
- static const char * tk_name[TK_MAX];
+ static const char *tk_name[TK_MAX];
- 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);
+ 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);
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=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_value(Token& token,Variant &value, Stream *p_stream, int &line, String &r_err_str,ResourceParser *p_res_parser=NULL);
- 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_value(Token &token, Variant &value, Stream *p_stream, int &line, String &r_err_str, ResourceParser *p_res_parser = NULL);
+ 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);
};
-
-
-
class VariantWriter {
public:
+ typedef Error (*StoreStringFunc)(void *ud, const String &p_string);
+ typedef String (*EncodeResourceFunc)(void *ud, const RES &p_resource);
- 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);
-
-
+ 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