GMP 0.4.0
Generative Metaprogramming library for C++
Loading...
Searching...
No Matches
gmp Namespace Reference

Namespaces

namespace  dp
 

Classes

struct  any
 A placeholder type implicitly convertible to any type. More...
 
class  basic_deserializer
 
class  basic_serializer
 
struct  constant_arg_t
 Wrap a compile-time value as a distinct function argument type. More...
 
struct  deserialization_options
 
struct  enum_traits
 Customize the reflection range or explicit values for an enumeration. More...
 
struct  filter
 Internal placeholder used during type-list filtering machinery. More...
 
struct  fixed_string
 A compile-time string type with fixed length and constexpr operations. More...
 
struct  json_read_options
 
struct  json_write_options
 
class  object_factory
 A singleton-backed runtime factory that creates products by string key. More...
 
struct  pretty_type_name
 Format a type name for documentation-friendly display. More...
 
struct  pretty_type_name< std::array< T, N > >
 Formatter specialization for std::array<T, N>. More...
 
struct  pretty_type_name< std::string >
 Formatter specialization for std::string. More...
 
struct  pretty_type_name< std::string_view >
 Formatter specialization for std::string_view. More...
 
struct  pretty_type_name< std::vector< T > >
 Formatter specialization for std::vector<T>. More...
 
struct  serialization_error
 
class  serialization_exception
 
struct  serialization_field
 
struct  serialization_options
 
class  serialization_result
 
class  serialization_result< void >
 
struct  serialization_schema
 
struct  serialization_traits
 
struct  serialization_unexpected
 
class  serialization_value
 
class  singleton
 CRTP-based singleton helper with optional dead-reference recovery. More...
 
class  singleton< T, false >
 Default singleton specialization using a function-local static object. More...
 
class  singleton< T, true >
 Singleton specialization with dead-reference recovery support. More...
 
struct  type_list
 A variadic template structure representing a list of types. More...
 
struct  type_list_concat
 Concatenate multiple type lists into a single type list. More...
 
struct  type_list_concat< type_list< LTypes... >, type_list< RTypes... > >
 
struct  type_list_contains
 Test whether a type list contains a specific type. More...
 
struct  type_list_contains< U, type_list< Types... > >
 
struct  type_list_element
 Select the type at a given index within a type list. More...
 
struct  type_list_element< 0, type_list< Head, Types... > >
 
struct  type_list_element< Idx, type_list< Head, Types... > >
 
struct  type_list_filter
 Filter a type list by a unary type predicate. More...
 
struct  type_list_filter< type_list< Head, Types... >, Pred >
 
struct  type_list_filter< type_list<>, Pred >
 
struct  type_list_insert
 Insert a new type at a given position in a type list. More...
 
struct  type_list_insert< 0, NewType, type_list< Types... > >
 
struct  type_list_insert< Idx, NewType, type_list< Head, Types... > >
 
struct  type_list_remove
 Remove the type at a given index from a type list. More...
 
struct  type_list_remove< 0, type_list< Head, Types... > >
 
struct  type_list_remove< Idx, type_list< Head, Types... > >
 Public implementation of type-list element removal. More...
 
struct  type_list_reverse
 Reverse the order of types in a type list. More...
 
struct  type_list_reverse< type_list< Types... > >
 
struct  type_list_reverse< type_list<> >
 
struct  type_list_size
 Compute the number of types stored in a type list. More...
 
struct  type_list_size< type_list< Types... > >
 
struct  type_list_tail
 Remove the first element from a type list. More...
 
struct  type_list_tail< type_list< Head, Types... > >
 
struct  type_list_unique
 Remove duplicate types while preserving first occurrence order. More...
 
struct  type_list_unique< type_list< Head, Types... > >
 
struct  type_list_unique< type_list<> >
 
struct  type_tag
 
class  value_reader
 
class  value_writer
 
struct  xml_read_options
 
struct  xml_write_options
 

Concepts

concept  reflectable
 Constraint for aggregate types supported by the reflection helpers.
 
concept  type_list_like
 Concept to check if a type is type_list-like.
 
concept  serialization_writer
 
concept  serialization_reader
 

Typedefs

template<std::size_t I, typename T >
using member_type_t = std::remove_cvref_t< decltype(*detail::field_getter< I, T >(constant_arg< member_count< T >()>))>
 Alias for the type of the I-th member of an aggregate type.
 
template<std::size_t Idx, typename T >
using type_list_element_t = type_list_element< Idx, T >::type
 
template<type_list_like T>
using type_list_head = type_list_element_t< 0, T >
 
template<type_list_like T>
using type_list_last = type_list_element_t< type_list_size_v< T > - 1, T >
 Alias for the last element type in a type list.
 
template<typename T >
using type_list_tail_t = type_list_tail< T >::type
 
template<type_list_like... TypeLists>
using type_list_concat_t = type_list_concat< TypeLists... >::type
 
template<std::size_t Idx, type_list_like T>
using type_list_remove_t = type_list_remove< Idx, T >::type
 
template<type_list_like T>
using type_list_pop_front = type_list_remove_t< 0, T >
 
template<type_list_like T>
using type_list_pop_back = type_list_remove_t< type_list_size_v< T > - 1, T >
 
template<std::size_t Idx, typename NewType , type_list_like T>
using type_list_insert_t = type_list_insert< Idx, NewType, T >::type
 
template<typename NewType , type_list_like T>
using type_list_push_front = type_list_insert_t< 0, NewType, T >
 
template<typename NewType , type_list_like T>
using type_list_push_back = type_list_insert_t< type_list_size_v< T >, NewType, T >
 
template<type_list_like T>
using type_list_reverse_t = type_list_reverse< T >::type
 
template<typename T >
using type_list_unique_t = type_list_unique< T >::type
 
template<type_list_like T, template< typename > class Pred>
using type_list_filter_t = type_list_filter< T, Pred >::type
 

Enumerations

enum class  serialization_kind {
  null , boolean , signed_integer , unsigned_integer ,
  floating , string , array , object
}
 
enum class  serialization_errc {
  none , unexpected_end , invalid_syntax , invalid_escape ,
  invalid_utf8 , invalid_number , type_mismatch , missing_field ,
  unknown_field , duplicate_field , duplicate_element , ambiguous_field ,
  invalid_enum , integer_overflow , value_out_of_range , size_limit_exceeded ,
  depth_limit_exceeded , unsupported_type , custom_error
}
 
enum class  unknown_field_policy { reject , ignore }
 
enum class  duplicate_field_policy { reject , keep_first , keep_last }
 
enum class  duplicate_element_policy { reject , ignore }
 
enum class  enum_encoding { name , underlying }
 
enum class  enum_decoding { name , underlying , name_or_underlying }
 

Functions

template<std::size_t N>
 fixed_string (char const(&)[N]) -> fixed_string< N - 1 >
 Deduce fixed_string length from a string literal.
 
template<std::size_t N1, std::size_t N2>
consteval fixed_string< N1+N2operator+ (fixed_string< N1 > const &s1, fixed_string< N2 > const &s2)
 Concatenate two fixed strings at compile time.
 
template<fixed_string FirstValue, fixed_string... RestValues, auto String>
consteval auto remove_all (constant_arg_t< String >)
 Remove all occurrences of one or more compile-time substrings.
 
template<typename E , fixed_string P = type_name<E>() + fixed_string("::")>
consteval auto enum_values ()
 Get all enumerator values of an enumeration type at compile-time.
 
template<typename E , fixed_string P = type_name<E>() + fixed_string("::")>
consteval auto enum_count ()
 Count the number of enumerators in an enumeration type at compile-time.
 
template<auto E, fixed_string P = fixed_string("::")>
consteval auto enum_name ()
 Get the name of an enumerator at compile-time.
 
template<typename E >
consteval auto enum_names ()
 Get all enumerator names of an enumeration type at compile-time.
 
template<typename E >
consteval auto enum_entries ()
 Get all enumerator entries (value, name) of an enumeration type at compile-time.
 
template<typename E >
constexpr auto enum_index (E value) -> std::optional< std::size_t >
 Get the index of an enumerator value in enum_values<E>().
 
template<typename E >
constexpr auto enum_cast (std::string_view name) -> std::optional< E >
 Cast an enumerator name to its corresponding enumerator value.
 
template<typename E >
requires std::is_enum_v<E>
constexpr auto enum_underlying (E value) noexcept -> std::underlying_type_t< E >
 Return the underlying integer value of an enumerator.
 
template<typename E >
requires std::is_enum_v<E>
constexpr bool enum_contains (E value)
 Test whether an enumerator is present in the reflected set.
 
template<typename E , typename U >
requires std::is_enum_v<E> && std::is_integral_v<U>
constexpr bool enum_contains (U value)
 Test whether an underlying integer value is a reflected enumerator.
 
template<typename T , typename... Args>
requires std::is_aggregate_v<std::remove_cvref_t<T>>
consteval int member_count ()
 Count the number of members in an aggregate type at compile-time.
 
template<std::size_t I, typename T >
requires std::is_aggregate_v<T> && (I < member_count<T>()) && (member_count<T>() <= GMP_MAX_SUPPORTED_FIELDS)
consteval auto member_name () noexcept
 Get the name of a specific member of an aggregate type at compile-time.
 
template<typename T >
consteval auto member_names ()
 Get all member names of an aggregate type at compile-time.
 
template<typename T >
requires reflectable<T>
constexpr auto member_index (std::string_view name) -> std::optional< std::size_t >
 Find a reflected member by name.
 
template<typename T >
requires reflectable<T>
constexpr bool has_member (std::string_view name)
 Test whether an aggregate has a reflected member with the given name.
 
template<typename T >
constexpr auto member_type_names ()
 Returns an array of string_view containing the type names of all members of aggregate type T.
 
template<std::size_t I, typename T , typename UnqualifiedT = std::remove_cvref_t<T>>
requires std::is_aggregate_v<UnqualifiedT> && (I < member_count<UnqualifiedT>()) && (member_count<UnqualifiedT>() <= GMP_MAX_SUPPORTED_FIELDS)
decltype(automember_ref (T &&value) noexcept
 Get a reference to the I-th member of an aggregate object.
 
template<typename T >
requires reflectable<T>
constexpr auto tie_members (T &value) noexcept
 Return a tuple of references to all members of an aggregate.
 
template<typename T , typename F >
requires reflectable<T>
constexpr decltype(autoapply_members (T &value, F &&func) noexcept(noexcept(std::apply(std::forward< F >(func), tie_members(value))))
 Invoke a callable with all aggregate members as separate arguments.
 
template<typename T , typename F >
requires reflectable<T>
constexpr void for_each_member (T &&value, F &&func) noexcept(noexcept(detail::for_each_member_impl(std::forward< T >(value), std::forward< F >(func), std::make_index_sequence< member_count_v< std::remove_cvref_t< T > > >{})))
 Visit each member of an aggregate object together with its member name.
 
template<typename T , typename F >
requires reflectable<T>
constexpr bool visit_member (T &&value, std::string_view name, F &&func)
 Visit a member selected by name.
 
template<typename Func >
constexpr auto make_named_operator (Func &&f)
 Create a token that lets a callable be used as a named infix operator.
 
constexpr bool is_equal (const char *lhs, const char *rhs) noexcept
 
template<typename T >
consteval auto type_name ()
 Get the string representation of a type at compile-time.
 
template<typename T >
consteval std::size_t type_size ()
 Calculate the actual payload size of a type without aggregate padding.
 
template<typename T >
consteval const T & as_value () noexcept
 Expose a default-constructed value of type T as a compile-time reference.
 
serialization_error make_serialization_error (serialization_errc code, std::string message, std::string path={}, std::size_t offset=serialization_error::unknown_offset)
 
serialization_error prepend_serialization_path (serialization_error error, std::string_view segment)
 
serialization_result< serialization_valueparse_json (std::string_view input, json_read_options options={})
 
serialization_result< std::string > write_json (const serialization_value &value, json_write_options options={})
 
template<typename T >
serialization_result< std::string > to_json (const T &value, serialization_options serialization={}, json_write_options json={})
 
template<typename T >
serialization_result< T > from_json (std::string_view input, deserialization_options deserialization={}, json_read_options json={})
 
template<typename T >
std::string to_json_or_throw (const T &value, serialization_options serialization={}, json_write_options json={})
 
template<typename T >
from_json_or_throw (std::string_view input, deserialization_options deserialization={}, json_read_options json={})
 
template<typename T >
serialization_result< serialization_valueto_serialization_value (const T &value, serialization_options options={})
 
template<typename T >
serialization_result< T > from_serialization_value (const serialization_value &value, deserialization_options options={})
 
template<typename... Fields>
consteval auto define_schema (Fields... fields)
 

Variables

template<typename E >
constexpr int enum_min_v
 The minimum reflection scan value for enumeration type E.
 
template<typename E >
constexpr int enum_max_v
 The maximum reflection scan value for enumeration type E.
 
template<typename T >
constexpr auto member_count_v
 Number of members in an aggregate type as an inline constant.
 
template<std::intmax_t N>
static constexpr auto to_fixed_string_v
 
template<typename T >
constexpr std::size_t type_list_size_v
 
template<typename U , type_list_like T>
constexpr bool type_list_contains_v
 
template<auto V>
constexpr constant_arg_t< Vconstant_arg
 A ready-to-use constant_arg_t<V> object for a compile-time value.
 
template<fixed_string Member>
constexpr serialization_field< Memberfield
 

Enumeration Type Documentation

◆ duplicate_element_policy

Enumerator
reject 
ignore 

Definition at line 23 of file options.hpp.

◆ duplicate_field_policy

Enumerator
reject 
keep_first 
keep_last 

Definition at line 21 of file options.hpp.

◆ enum_decoding

Enumerator
name 
underlying 
name_or_underlying 

Definition at line 27 of file options.hpp.

◆ enum_encoding

Enumerator
name 
underlying 

Definition at line 25 of file options.hpp.

◆ serialization_errc

Enumerator
none 
unexpected_end 
invalid_syntax 
invalid_escape 
invalid_utf8 
invalid_number 
type_mismatch 
missing_field 
unknown_field 
duplicate_field 
duplicate_element 
ambiguous_field 
invalid_enum 
integer_overflow 
value_out_of_range 
size_limit_exceeded 
depth_limit_exceeded 
unsupported_type 
custom_error 

Definition at line 26 of file error.hpp.

◆ serialization_kind

Enumerator
null 
boolean 
signed_integer 
unsigned_integer 
floating 
string 
array 
object 

Definition at line 26 of file archive.hpp.

◆ unknown_field_policy

Enumerator
reject 
ignore 

Definition at line 19 of file options.hpp.

Function Documentation

◆ define_schema()

template<typename... Fields>
consteval auto gmp::define_schema ( Fields...  fields)

Definition at line 109 of file traits.hpp.

References enum_values().

◆ from_json()

template<typename T >
serialization_result< T > gmp::from_json ( std::string_view  input,
deserialization_options  deserialization = {},
json_read_options  json = {} 
)

Definition at line 722 of file json.hpp.

◆ from_json_or_throw()

template<typename T >
T gmp::from_json_or_throw ( std::string_view  input,
deserialization_options  deserialization = {},
json_read_options  json = {} 
)

Definition at line 743 of file json.hpp.

◆ from_serialization_value()

template<typename T >
serialization_result< T > gmp::from_serialization_value ( const serialization_value value,
deserialization_options  options = {} 
)

Definition at line 39 of file serialization.hpp.

◆ make_serialization_error()

serialization_error gmp::make_serialization_error ( serialization_errc  code,
std::string  message,
std::string  path = {},
std::size_t  offset = serialization_error::unknown_offset 
)
inline

◆ parse_json()

serialization_result< serialization_value > gmp::parse_json ( std::string_view  input,
json_read_options  options = {} 
)
inline

Definition at line 694 of file json.hpp.

◆ prepend_serialization_path()

serialization_error gmp::prepend_serialization_path ( serialization_error  error,
std::string_view  segment 
)
inline

◆ to_json()

template<typename T >
serialization_result< std::string > gmp::to_json ( const T &  value,
serialization_options  serialization = {},
json_write_options  json = {} 
)

Definition at line 710 of file json.hpp.

◆ to_json_or_throw()

template<typename T >
std::string gmp::to_json_or_throw ( const T &  value,
serialization_options  serialization = {},
json_write_options  json = {} 
)

Definition at line 733 of file json.hpp.

◆ to_serialization_value()

template<typename T >
serialization_result< serialization_value > gmp::to_serialization_value ( const T &  value,
serialization_options  options = {} 
)

Definition at line 28 of file serialization.hpp.

◆ write_json()

serialization_result< std::string > gmp::write_json ( const serialization_value value,
json_write_options  options = {} 
)
inline

Definition at line 699 of file json.hpp.

Variable Documentation

◆ field

template<fixed_string Member>
constexpr serialization_field<Member> gmp::field
inlineconstexpr

Definition at line 107 of file traits.hpp.