Newer
Older
Import / applications / HighwayDash / ports / Framework / Json.h
#ifndef JSON_VALUE_H
#define JSON_VALUE_H


#include <string>
#include "rapidjson/document.h"
using namespace rapidjson;


class ConstJsonValueRef
{
public:
  ConstJsonValueRef(const Value& refVal);
  const Value& 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(rapidjson::Type t);
    std::string GetName();
    ConstJsonValueRef operator*();
    void operator++();
    bool operator!=(ConstJsonValueRefIterator other);
    rapidjson::Type  m_type;
    size_t           m_index;
    union {
      Value::ConstMemberIterator m_objectIterator;
      Value::ConstValueIterator  m_arrayIterator;
    };
  };

  ConstJsonValueRefIterator begin();
  ConstJsonValueRefIterator end();
private:
  ConstJsonValueRef() = delete;
  ConstJsonValueRef& operator=(Value&& other) = delete;
  const Value& m_val;
  std::string m_name;
  static const Value s_null;
};


#endif // JSON_VALUE_H