libdonut  2.3.2
Application framework for cross-platform game development in C++20
Classes | Namespaces | Typedefs | Enumerations | Functions
json.hpp File Reference
#include <donut/Variant.hpp>
#include <donut/reflection.hpp>
#include <donut/unicode.hpp>
#include <algorithm>
#include <array>
#include <charconv>
#include <cmath>
#include <compare>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <fmt/format.h>
#include <initializer_list>
#include <istream>
#include <iterator>
#include <limits>
#include <numeric>
#include <optional>
#include <ostream>
#include <span>
#include <sstream>
#include <stdexcept>
#include <string>
#include <string_view>
#include <system_error>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

Go to the source code of this file.

Classes

struct  donut::json::SourceLocation
 Line and column numbers of a location in a JSON source string. More...
 
struct  donut::json::Error
 Exception type for errors originating from the JSON API. More...
 
struct  donut::json::SerializationOptions
 Options for JSON serialization. More...
 
struct  donut::json::DeserializationOptions
 Options for JSON deserialization. More...
 
class  donut::json::Object
 JSON object type whose API mimics that of std::multimap<String, Value>. More...
 
class  donut::json::Array
 JSON array type whose API mimics that of std::vector<Value>. More...
 
class  donut::json::Value
 JSON value type. More...
 
struct  donut::json::Token
 Token data scanned from JSON. More...
 
class  donut::json::Lexer< It >
 Lexical analyzer for scanning and tokenizing input in the JSON5 format. More...
 
class  donut::json::Parser< It >
 Syntactic analyzer for parsing input in the JSON5 format obtained from a json::Lexer. More...
 
class  donut::json::Parser< It >::ValueVisitor
 Polymorphic interface for visitation-based parsing of JSON values. More...
 
struct  donut::json::Parser< It >::ConcreteValueVisitor< Visitor >
 Implementation of ValueVisitor for freestanding classes that implement all or parts of its interface without directly inheriting from it. More...
 
class  donut::json::Parser< It >::PropertyVisitor
 Polymorphic interface for visitation-based parsing of JSON object properties. More...
 
struct  donut::json::Parser< It >::ConcretePropertyVisitor< Visitor >
 Implementation of PropertyVisitor for freestanding classes that implement all or parts of its interface without directly inheriting from it. More...
 
struct  donut::json::Parser< It >::SkipValueVisitor
 Implementation of ValueVisitor that skips over the parsed value and discards the result. More...
 
struct  donut::json::Parser< It >::SkipPropertyVisitor
 Implementation of PropertyVisitor that skips over the parsed property and discards the result. More...
 
struct  donut::json::Writer
 Stateful wrapper object of an output stream for JSON serialization. More...
 
struct  donut::json::Reader
 Stateful wrapper object of an input stream for JSON deserialization. More...
 
struct  donut::json::Serializer< T >
 Base template to specialize in order to implement JSON serialization for a specific type. More...
 
struct  donut::json::Deserializer< T >
 Base template to specialize in order to implement JSON deserialization for a specific type. More...
 

Namespaces

 donut
 
 donut::json
 

Typedefs

using donut::json::Null = Monostate
 JSON null type. More...
 
using donut::json::Boolean = bool
 JSON boolean type. More...
 
using donut::json::String = std::string
 JSON string type. More...
 
using donut::json::Number = double
 JSON number type. More...
 
using donut::json::StringParser = Parser< const char8_t * >
 Parser for reading contiguous UTF-8-encoded JSON strings. More...
 
using donut::json::StreamParser = Parser< std::istreambuf_iterator< char > >
 Parser for reading UTF-8-encoded JSON input stream buffers. More...
 

Enumerations

enum class  donut::json::TokenType : std::uint8_t {
  donut::json::END_OF_FILE , donut::json::IDENTIFIER_NULL , donut::json::IDENTIFIER_FALSE , donut::json::IDENTIFIER_TRUE ,
  donut::json::IDENTIFIER_NAME , donut::json::PUNCTUATOR_COMMA , donut::json::PUNCTUATOR_COLON , donut::json::PUNCTUATOR_OPEN_SQUARE_BRACKET ,
  donut::json::PUNCTUATOR_CLOSE_SQUARE_BRACKET , donut::json::PUNCTUATOR_OPEN_CURLY_BRACE , donut::json::PUNCTUATOR_CLOSE_CURLY_BRACE , donut::json::STRING ,
  donut::json::NUMBER_BINARY , donut::json::NUMBER_OCTAL , donut::json::NUMBER_DECIMAL , donut::json::NUMBER_HEXADECIMAL ,
  donut::json::NUMBER_POSITIVE_INFINITY , donut::json::NUMBER_NEGATIVE_INFINITY , donut::json::NUMBER_POSITIVE_NAN , donut::json::NUMBER_NEGATIVE_NAN
}
 Type of a scanned JSON5 token. More...
 

Functions

constexpr bool donut::json::isWhitespaceCharacter (char32_t codePoint) noexcept
 Check if a Unicode code point is considered to be whitespace in JSON5. More...
 
constexpr bool donut::json::isPunctuationCharacter (char32_t codePoint) noexcept
 Check if a Unicode code point is considered to be punctuation in JSON5. More...
 
constexpr bool donut::json::isLineTerminatorCharacter (char32_t codePoint) noexcept
 Check if a Unicode code point marks the beginning of a line terminator sequence in JSON5. More...
 
template<typename T >
void donut::json::serialize (std::ostream &stream, const T &value, const SerializationOptions &options={})
 Serialize a value of any JSON-serializable type to an output stream. More...
 
template<typename T >
void donut::json::deserialize (std::istream &stream, T &value, const DeserializationOptions &options={})
 Deserialize a value of any JSON-serializable type from an input stream. More...
 
std::ostream & donut::json::operator<< (std::ostream &stream, const Value &value)
 Write a JSON value to an output stream using the default serialization options. More...
 
std::istream & donut::json::operator>> (std::istream &stream, Value &value)
 Read a JSON value from an input stream using the default deserialization options. More...
 
template<typename Callback >
auto donut::json::onNull (Callback callback)
 Build a Parser::ValueVisitor that handles Null values with a given callback function. More...
 
template<typename Callback >
auto donut::json::onBoolean (Callback callback)
 Build a Parser::ValueVisitor that handles Boolean values with a given callback function. More...
 
template<typename Callback >
auto donut::json::onString (Callback callback)
 Build a Parser::ValueVisitor that handles String values with a given callback function. More...
 
template<typename Callback >
auto donut::json::onNumber (Callback callback)
 Build a Parser::ValueVisitor that handles Number values with a given callback function. More...
 
template<typename Callback >
auto donut::json::onObject (Callback callback)
 Build a Parser::ValueVisitor that handles objects with a given callback function. More...
 
template<typename Callback >
auto donut::json::onArray (Callback callback)
 Build a Parser::ValueVisitor that handles arrays with a given callback function. More...
 
template<typename Callback >
auto donut::json::onProperty (Callback callback)
 Build a Parser::PropertyVisitor that handles object properties with a given callback function. More...
 
void donut::json::swap (Object &a, Object &b) noexcept
 
template<typename Predicate >
Object::size_type donut::json::erase_if (Object &container, Predicate predicate)
 
void donut::json::swap (Array &a, Array &b) noexcept
 
template<typename U >
Array::size_type donut::json::erase (Array &container, const U &value)
 
template<typename Predicate >
Array::size_type donut::json::erase_if (Array &container, Predicate predicate)