libpressio 0.93.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
pressio_options Struct Referencefinal

#include <options.h>

Public Types

using key_type = std::string
 
using mapped_type = pressio_option
 
using iterator = typename decltype(options)::iterator
 
using const_iterator = typename decltype(options)::const_iterator
 
using value_type = typename decltype(options)::value_type
 

Public Member Functions

 pressio_options ()=default
 
 pressio_options (pressio_options const &rhs)=default
 
 pressio_options (pressio_options &&rhs) DEFAULTED_NOEXCEPT=default
 
pressio_optionsoperator= (pressio_options const &rhs)=default
 
pressio_optionsoperator= (pressio_options &&rhs) DEFAULTED_NOEXCEPT=default
 
 pressio_options (std::initializer_list< std::pair< const std::string, pressio_option > > opts)
 
pressio_options_key_status key_status (std::string const &key) const
 
template<class StringType >
pressio_options_key_status key_status (StringType const &name, std::string const &key) const
 
template<class StringType >
void set (StringType &&key, pressio_option const &value)
 
template<class StringType , class StringType2 >
void set (StringType const &name, StringType2 const &key, pressio_option const &value)
 
template<class StringType >
enum pressio_options_key_status cast_set (StringType &&key, pressio_option const &value, enum pressio_conversion_safety safety=pressio_conversion_implicit)
 
template<class StringType , class StringType2 >
enum pressio_options_key_status cast_set (StringType const &name, StringType2 const &key, pressio_option const &value, enum pressio_conversion_safety safety=pressio_conversion_implicit)
 
template<class StringType >
void set_type (StringType &&key, pressio_option_type type)
 
template<class StringType , class StringType2 >
void set_type (StringType const &name, StringType2 const &key, pressio_option_type type)
 
template<class StringType >
pressio_option const & get (StringType const &key) const
 
template<class StringType , class StringType2 >
pressio_option const & get (compat::string_view const &name, StringType2 const &key) const
 
template<class PointerType , class StringType >
enum pressio_options_key_status get (StringType const &key, compat::optional< PointerType > *value) const
 
template<class PointerType , class StringType >
enum pressio_options_key_status get (StringType const &key, PointerType value) const
 
template<class PointerType , class StringType , class StringType2 >
enum pressio_options_key_status get (StringType const &name, StringType2 const &key, PointerType value) const
 
template<class PointerType , class StringType >
enum pressio_options_key_status cast (StringType const &key, PointerType value, enum pressio_conversion_safety safety) const
 
template<class PointerType , class StringType , class StringType2 >
enum pressio_options_key_status cast (StringType const &name, StringType2 const &key, PointerType value, enum pressio_conversion_safety safety) const
 
void clear () noexcept
 
void copy_from (pressio_options const &o, bool ignore_empty=false)
 
iterator insert (const_iterator it, value_type const &value)
 
template<class InputIt >
void insert (InputIt begin, InputIt end)
 
template<class InputIt >
void insert_or_assign (InputIt begin, InputIt end, bool ignore_empty)
 
auto begin () const -> decltype(std::begin(options))
 
auto end () const -> decltype(std::end(options))
 
auto begin () -> decltype(std::begin(options))
 
auto end () -> decltype(std::end(options))
 
size_t size () const
 
iterator find (key_type const &key)
 
const_iterator find (key_type const &key) const
 
size_t erase (key_type const &key)
 
auto insert (value_type const &value) -> decltype(options.insert(value))
 
bool operator== (pressio_options const &rhs) const
 
size_t num_set () const
 

Static Public Member Functions

static std::vector< compat::string_view > search (compat::string_view const &value)
 

Detailed Description

represents a map of dynamically typed objects

Member Typedef Documentation

◆ const_iterator

using pressio_options::const_iterator = typename decltype(options)::const_iterator

type of the const iterators

◆ iterator

using pressio_options::iterator = typename decltype(options)::iterator

type of the returned iterator

◆ key_type

using pressio_options::key_type = std::string

type of the keys for pressio_options, useful for lua

◆ mapped_type

type of the mapped_type for pressio_options, useful for lua

◆ value_type

using pressio_options::value_type = typename decltype(options)::value_type

the map's value_type

Constructor & Destructor Documentation

◆ pressio_options() [1/4]

pressio_options::pressio_options ( )
default

create an empty pressio_options structure

◆ pressio_options() [2/4]

pressio_options::pressio_options ( pressio_options const &  rhs)
default

copy a pressio_options structure

Parameters
[in]rhsthe structure to copy from

◆ pressio_options() [3/4]

pressio_options::pressio_options ( pressio_options &&  rhs)
default

move a pressio_options structure

Parameters
[in]rhsthe structure to move from

◆ pressio_options() [4/4]

pressio_options::pressio_options ( std::initializer_list< std::pair< const std::string, pressio_option > >  opts)
inline

create a literal pressio_options structure from a std::initializer_list

Parameters
[in]optsthe options to put into the map

Member Function Documentation

◆ begin() [1/2]

auto pressio_options::begin ( ) -> decltype(std::begin(options))
inline
Returns
an begin iterator over the keys

◆ begin() [2/2]

auto pressio_options::begin ( ) const -> decltype(std::begin(options))
inline
Returns
an begin iterator over the keys

◆ cast() [1/2]

template<class PointerType , class StringType >
enum pressio_options_key_status pressio_options::cast ( StringType const &  key,
PointerType  value,
enum pressio_conversion_safety  safety 
) const
inline

gets a key if it is set, attepts to cast it the specified type and stores it into the pointer value

Parameters
[in]keythe option to retrieve
[out]valuethe value that is in the option
[in]safetythe level of conversions to allow
See also
pressio_conversion_safety
Returns
pressio_options_key_does_not_exist if the key does not exist pressio_options_key_exists if the key exists but has no value pressio_options_key_set if the key exists and is set

◆ cast() [2/2]

template<class PointerType , class StringType , class StringType2 >
enum pressio_options_key_status pressio_options::cast ( StringType const &  name,
StringType2 const &  key,
PointerType  value,
enum pressio_conversion_safety  safety 
) const
inline

gets a key if it is set, attepts to cast it the specified type and stores it into the pointer value

Parameters
[in]namethe name to use. Checks for the named version first, then the unnamed
[in]keythe option to retrieve
[out]valuethe value that is in the option
[in]safetythe level of conversions to allow
See also
pressio_conversion_safety
Returns
pressio_options_key_does_not_exist if the key does not exist pressio_options_key_exists if the key exists but has no value pressio_options_key_set if the key exists and is set

◆ cast_set() [1/2]

template<class StringType >
enum pressio_options_key_status pressio_options::cast_set ( StringType &&  key,
pressio_option const &  value,
enum pressio_conversion_safety  safety = pressio_conversion_implicit 
)
inline

converts value according the conversion safety to the type of the option at the stored key specified and stores the result if the cast succeeds

Parameters
[in]keythe option key
[in]valuethe option to assign to this option
[in]safetythe specified safety to use
See also
pressio_conversion_safety

◆ cast_set() [2/2]

template<class StringType , class StringType2 >
enum pressio_options_key_status pressio_options::cast_set ( StringType const &  name,
StringType2 const &  key,
pressio_option const &  value,
enum pressio_conversion_safety  safety = pressio_conversion_implicit 
)
inline

converts value according the conversion safety to the type of the option at the stored key specified and stores the result if the cast succeeds

Parameters
[in]namethe name to use
[in]keythe option key
[in]valuethe option to assign to this option
[in]safetythe specified safety to use
See also
pressio_conversion_safety

◆ clear()

void pressio_options::clear ( )
inlinenoexcept

removes all options

◆ copy_from()

void pressio_options::copy_from ( pressio_options const &  o,
bool  ignore_empty = false 
)
inline

copies all of the options from o

Parameters
[in]othe options to copy from

◆ end() [1/2]

auto pressio_options::end ( ) -> decltype(std::end(options))
inline
Returns
an end iterator over the keys

◆ end() [2/2]

auto pressio_options::end ( ) const -> decltype(std::end(options))
inline
Returns
an end iterator over the keys

◆ erase()

size_t pressio_options::erase ( key_type const &  key)
inline

erase a key from the container, useful for lua

Parameters
[in]keythe key to search for
Returns
the number of elements erased

◆ find() [1/2]

iterator pressio_options::find ( key_type const &  key)
inline

find an element of the container. if it is not found, return end(). Useful for lua

Parameters
[in]keythe key to search for
Returns
an iterator to the found key

◆ find() [2/2]

const_iterator pressio_options::find ( key_type const &  key) const
inline

find an element of the container. if it is not found, return end(). Useful for lua

Parameters
[in]keythe key to search for
Returns
an iterator to the found key

◆ get() [1/5]

template<class StringType , class StringType2 >
pressio_option const & pressio_options::get ( compat::string_view const &  name,
StringType2 const &  key 
) const
inline
Parameters
[in]namethe name to use
[in]keywhich option to get
Returns
the option at the specified key

◆ get() [2/5]

template<class StringType >
pressio_option const & pressio_options::get ( StringType const &  key) const
inline
Parameters
[in]keywhich option to get
Returns
the option at the specified key

◆ get() [3/5]

template<class PointerType , class StringType >
enum pressio_options_key_status pressio_options::get ( StringType const &  key,
compat::optional< PointerType > *  value 
) const
inline

gets a key if it is set and stores it into the pointer value

Parameters
[in]keythe option to retrieve
[out]valuethe value that is in the option
Returns
pressio_options_key_does_not_exist if the key does not exist pressio_options_key_exists if the key exists but has no value pressio_options_key_set if the key exists and is set

◆ get() [4/5]

template<class PointerType , class StringType >
enum pressio_options_key_status pressio_options::get ( StringType const &  key,
PointerType  value 
) const
inline

gets a key if it is set and stores it into the pointer value

Parameters
[in]keythe option to retrieve
[out]valuethe value that is in the option
Returns
pressio_options_key_does_not_exist if the key does not exist pressio_options_key_exists if the key exists but has no value pressio_options_key_set if the key exists and is set

◆ get() [5/5]

template<class PointerType , class StringType , class StringType2 >
enum pressio_options_key_status pressio_options::get ( StringType const &  name,
StringType2 const &  key,
PointerType  value 
) const
inline

gets a key if it is set and stores it into the pointer value

Parameters
[in]namethe name to use. Checks for the named version first, then the unnamed
[in]keythe option to retrieve
[out]valuethe value that is in the option
Returns
pressio_options_key_does_not_exist if the key does not exist pressio_options_key_exists if the key exists but has no value pressio_options_key_set if the key exists and is set

◆ insert() [1/3]

iterator pressio_options::insert ( const_iterator  it,
value_type const &  value 
)
inline

function to insert new values into the map

◆ insert() [2/3]

template<class InputIt >
void pressio_options::insert ( InputIt  begin,
InputIt  end 
)
inline

insert a collection of iterator

Parameters
[in]beginthe iterator to the beginning
[in]endthe iterator to the end

◆ insert() [3/3]

auto pressio_options::insert ( value_type const &  value) -> decltype(options.insert(value))
inline

insert a new key-value pair into the options, useful for lua

Parameters
[in]valuethe value to insert
Returns
the number of elements erased

◆ insert_or_assign()

template<class InputIt >
void pressio_options::insert_or_assign ( InputIt  begin,
InputIt  end,
bool  ignore_empty 
)
inline

insert or assign a collection from an iterator

Parameters
[in]beginthe iterator to the beginning
[in]endthe iterator to the end

◆ key_status() [1/2]

pressio_options_key_status pressio_options::key_status ( std::string const &  key) const
inline

checks the status of a key in a option set

Returns
pressio_options_key_does_not_exist if the key does not exist pressio_options_key_exists if the key exists but has no value pressio_options_key_set if the key exists and is set

◆ key_status() [2/2]

template<class StringType >
pressio_options_key_status pressio_options::key_status ( StringType const &  name,
std::string const &  key 
) const
inline

checks the status of a key in a option set with a given name

Returns
pressio_options_key_does_not_exist if the key does not exist pressio_options_key_exists if the key exists but has no value pressio_options_key_set if the key exists and is set

◆ num_set()

size_t pressio_options::num_set ( ) const
inline
Returns
the number of set options

◆ operator=() [1/2]

pressio_options & pressio_options::operator= ( pressio_options &&  rhs)
default

move a pressio_options structure

Parameters
[in]rhsthe structure to move from

◆ operator=() [2/2]

pressio_options & pressio_options::operator= ( pressio_options const &  rhs)
default

copy a pressio_options structure

Parameters
[in]rhsthe structure to copy from

◆ operator==()

bool pressio_options::operator== ( pressio_options const &  rhs) const
inline
Parameters
[in]rhsthe object to compare against
Returns
true if the options are equal

◆ search()

static std::vector< compat::string_view > pressio_options::search ( compat::string_view const &  value)
static

returns a vector containing the search order for a given string

◆ set() [1/2]

template<class StringType >
void pressio_options::set ( StringType &&  key,
pressio_option const &  value 
)
inline

sets a key to the specified value

Parameters
[in]keythe key to use
[in]valuethe value to use

◆ set() [2/2]

template<class StringType , class StringType2 >
void pressio_options::set ( StringType const &  name,
StringType2 const &  key,
pressio_option const &  value 
)
inline

sets a key to the specified value

Parameters
[in]namethe name to use
[in]keythe key to use
[in]valuethe value to use

◆ set_type() [1/2]

template<class StringType >
void pressio_options::set_type ( StringType &&  key,
pressio_option_type  type 
)
inline

set only the type of the option

Parameters
[in]keywhich option to set
[in]typethe type to set the option to

◆ set_type() [2/2]

template<class StringType , class StringType2 >
void pressio_options::set_type ( StringType const &  name,
StringType2 const &  key,
pressio_option_type  type 
)
inline

set only the type of the option

Parameters
[in]namethe name to use
[in]keywhich option to set
[in]typethe type to set the option to

◆ size()

size_t pressio_options::size ( ) const
inline
Returns
the number of set and existing options

The documentation for this struct was generated from the following file: