From efab1c3707b1d6f6fae82411639ca436639a0403 Mon Sep 17 00:00:00 2001 From: Jordan Cristiano Date: Mon, 31 Aug 2015 22:16:06 -0400 Subject: [PATCH] Fixed compilation of jsonfile on gcc/clang --- demboyz/base/jsonfile.h | 94 ++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 49 deletions(-) diff --git a/demboyz/base/jsonfile.h b/demboyz/base/jsonfile.h index e9ac163..2f94afc 100644 --- a/demboyz/base/jsonfile.h +++ b/demboyz/base/jsonfile.h @@ -52,60 +52,53 @@ namespace base FILE* m_fp; }; - class JsonReaderObject; - class JsonReaderIterator - { - public: - using JsonValue = rapidjson::GenericValue>; - - public: - explicit JsonReaderIterator(JsonValue* value, bool& hasReadError); - - JsonReaderObject operator*() const; - JsonReaderIterator& operator++(); - bool operator==(const JsonReaderIterator& other) const; - bool operator!=(const JsonReaderIterator& other) const; - - private: - JsonValue* m_value; - bool& m_hasReadError; - }; - - class JsonReaderArray - { - public: - using JsonValue = rapidjson::GenericValue>; - - public: - explicit JsonReaderArray(JsonValue& value, bool& parseError); - - bool HasReadError() const; - - std::size_t size() const; - JsonReaderIterator begin(); - JsonReaderIterator end(); - - template - void TransformTo(Container& c, Fn fn) - { - c.resize(m_value.Size()); - std::size_t index = 0; - for (base::JsonReaderObject obj : *this) - { - fn(obj, c[index++]); - } - } - - private: - JsonValue& m_value; - bool& m_hasReadError; - }; - class JsonReaderObject { public: using JsonValue = rapidjson::GenericValue>; + class JsonReaderIterator + { + public: + explicit JsonReaderIterator(JsonValue* value, bool& hasReadError); + + JsonReaderObject operator*() const; + JsonReaderIterator& operator++(); + bool operator==(const JsonReaderIterator& other) const; + bool operator!=(const JsonReaderIterator& other) const; + + private: + JsonValue* m_value; + bool& m_hasReadError; + }; + + class JsonReaderArray + { + public: + explicit JsonReaderArray(JsonValue& value, bool& parseError); + + bool HasReadError() const; + + std::size_t size() const; + JsonReaderIterator begin(); + JsonReaderIterator end(); + + template + void TransformTo(Container& c, Fn fn) + { + c.resize(m_value.Size()); + std::size_t index = 0; + for (base::JsonReaderObject obj : *this) + { + fn(obj, c[index++]); + } + } + + private: + JsonValue& m_value; + bool& m_hasReadError; + }; + public: explicit JsonReaderObject(JsonValue& value, bool& parseError); @@ -132,6 +125,9 @@ namespace base bool& m_hasReadError; }; + using JsonReaderIterator = JsonReaderObject::JsonReaderIterator; + using JsonReaderArray = JsonReaderObject::JsonReaderArray; + class JsonReaderFile { public: