Fixed compilation of jsonfile on gcc/clang
This commit is contained in:
parent
4d4a751e75
commit
efab1c3707
@ -52,60 +52,53 @@ namespace base
|
||||
FILE* m_fp;
|
||||
};
|
||||
|
||||
class JsonReaderObject;
|
||||
class JsonReaderIterator
|
||||
{
|
||||
public:
|
||||
using JsonValue = rapidjson::GenericValue<rapidjson::ASCII<>>;
|
||||
|
||||
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<rapidjson::ASCII<>>;
|
||||
|
||||
public:
|
||||
explicit JsonReaderArray(JsonValue& value, bool& parseError);
|
||||
|
||||
bool HasReadError() const;
|
||||
|
||||
std::size_t size() const;
|
||||
JsonReaderIterator begin();
|
||||
JsonReaderIterator end();
|
||||
|
||||
template<typename Container, typename Fn>
|
||||
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<rapidjson::ASCII<>>;
|
||||
|
||||
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<typename Container, typename Fn>
|
||||
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:
|
||||
|
Loading…
Reference in New Issue
Block a user