#pragma once

#include "ehs/EHS.h"
#include "ehs/Str.h"

#include "JsonBase.h"

namespace ehs
{
	class JsonVar;

	class JsonObj : public JsonBase
	{
	protected:
		UInt_64 size;
		UInt_64 extra;
		UInt_64 rawSize;
		JsonVar* vars;

	public:
		virtual ~JsonObj();

		JsonObj();

		JsonObj(const UInt_64 size, const UInt_64 extra);

		JsonObj(const UInt_64 extra);

		JsonObj(JsonObj&& value) noexcept;

		JsonObj(const JsonObj& value);

		JsonObj& operator=(JsonObj&& value) noexcept;

		JsonObj& operator=(const JsonObj& value);

		operator const JsonVar*() const;

		operator JsonVar*();

		UInt_64 Size() const;

		UInt_64 Extra() const;

		UInt_64 RawSize() const;

		bool HasVar(const UInt_64 hashId) const;

		bool HasVar(const Str_8& identifier) const;

		bool AddVar(const JsonVar& var);

		const JsonVar* GetVar(const UInt_64 hashId) const;

		const JsonVar* GetVar(const Str_8& identifier) const;

		JsonVar* GetVar(const UInt_64 hashId);

		JsonVar* GetVar(const Str_8& identifier);

		Str_8 ToStr(const UInt_64 level, const bool compact) const;
	};
}