// BlockyFroggy
// Copyright © 2017 John Ryland.
// All rights reserved.
#pragma once
#ifndef JSON_VALUE_H
#define JSON_VALUE_H
#include <string>
#include "rapidjson/document.h"
typedef rapidjson::Value JsonValue;
typedef rapidjson::Type JsonType;
class ConstJsonValueRef
{
public:
ConstJsonValueRef(const JsonValue& refVal);
const JsonValue& value();
void setName(const char* name);
std::string getName();
int operator()(int def);
const char* operator()(const char* def);
ConstJsonValueRef operator[](const char* n);
struct ConstJsonValueRefIterator
{
ConstJsonValueRefIterator(JsonType t);
std::string GetName();
ConstJsonValueRef operator*();
void operator++();
bool operator!=(ConstJsonValueRefIterator other);
JsonType m_type;
size_t m_index;
union {
JsonValue::ConstMemberIterator m_objectIterator;
JsonValue::ConstValueIterator m_arrayIterator;
};
};
ConstJsonValueRefIterator begin();
ConstJsonValueRefIterator end();
private:
ConstJsonValueRef() = delete;
ConstJsonValueRef& operator=(JsonValue&& other) = delete;
const JsonValue& m_val;
std::string m_name;
static const JsonValue s_null;
};
#endif // JSON_VALUE_H