Types#
Note
Declared in <god/types.hpp>
-
class list : public std::vector<value>#
Represents a God list, consisting of elements (god::values).
-
class map : public std::vector::vector#
Represents a God map, consisting of fields
Warning
doxygenvariable: Cannot find variable “god::value_t” in doxygen xml output for project “libgod” from directory: doxygen/xml
-
class value#
An convenience wrapper for any of the valid internal value types
Methods
-
bool operator==(const value &other) const = default#
Boolean comparison operator.
- Parameters:
other – Another value to compare
- Returns:
true if they are identical
-
template<typename T>
inline T &as()# Get an underlying value.
- Returns:
A mutable reference to the value as type T
-
template<typename T>
inline const T &as() const# Get an underlying value.
- Returns:
A constant reference to the value as type T
-
template<typename T>
inline bool is() const# Verify the underlying type of a value.
- Returns:
True if the underlying value is of type T, false otherwise
-
bool operator==(const value &other) const = default#
-
class field#
Represents a God field, consisting of an identifier and an opaque value object
Constructors
-
class document#
The top-level data structure of the God format.
Methods
-
bool operator==(const document &other) const = default#
Boolean comparison operator.
- Parameters:
other – Another document to compare.
- Returns:
true when they are identical, false otherwise.
-
void load(const std::string &inputfile)#
Populate a document by parsing an input file.
- Parameters:
inputfile – A path to the file to read
-
void load(std::istream &is)#
Populate a document by parsing input from a stream.
- Parameters:
is – The input stream to read from
-
std::string json() const noexcept#
Get the document in JSON string representation.
- Returns:
The resulting string in JSON format
-
std::expected<const value*, error> lookup(std::string_view qry) const noexcept#
Search for a field using path syntax as a specific type.
- Parameters:
qry – The period separated path to search for
- Returns:
A constant pointer to an value or an error
-
std::string string() const noexcept#
Get the document in canonical string representation.
- Returns:
The resulting string
-
template<typename t>
inline std::expected<t, error> query(std::string_view path)# Search for a field using path syntax as a specific type.
- Parameters:
path – The period separated path to search for
- Returns:
A constant pointer to an underlying value (of type t) or an error
-
std::expected<const value*, error> operator[](std::string_view name) const noexcept#
Search for a field using array subscript syntax.
- Parameters:
name – The field name to search for
- Returns:
A constant pointer to a value or an error
-
bool operator==(const document &other) const = default#