#ifndef JSON_HPP #define JSON_HPP #include #include #include #include #include #include namespace json { enum class Type { Null = 1, False = 2, True = 3, Int = 4, Float = 5, String = 6, Array = 7, Object = 8, }; class Underlying; class Value { public: Value(const Value&) = delete; Value(Value&&) = delete; Value& operator=(const Value&) = delete; Value& operator=(Value&&) = delete; explicit Value(std::unique_ptr underlying) : m_underlying(std::move(underlying)) { }; ~Value() = default; auto is(Type type) const -> bool; auto get_type() const -> Type; auto get_bool() const -> bool; auto get_int() const -> std::int64_t; auto get_float() const -> double; auto get_string() const -> std::string_view; void set_null(); void set_bool(bool val); void set_int(int64_t val); void set_float(double val); void set_string(std::string_view val); auto count() const -> std::size_t; auto get(std::size_t idx) -> std::unique_ptr; auto get(std::size_t idx) const -> std::unique_ptr; void push(std::unique_ptr value); auto get(std::string_view key) -> std::unique_ptr; auto get(std::string_view key) const -> std::unique_ptr; void set(std::string_view key, std::unique_ptr value); auto query(const std::string& query) -> std::unique_ptr; private: std::unique_ptr m_underlying; }; auto parse(std::string_view text) -> std::unique_ptr; } #endif