zep
Public Types | Public Member Functions | Friends | List of all members
cpptoml::table Class Reference

Represents a TOML keytable. More...

#include <cpptoml.h>

Inheritance diagram for cpptoml::table:
cpptoml::base

Public Types

using iterator = string_to_base_map::iterator
 tables can be iterated over.
 
using const_iterator = string_to_base_map::const_iterator
 tables can be iterated over. More...
 

Public Member Functions

std::shared_ptr< baseclone () const override
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
bool is_table () const override
 Determines if the given TOML element is a table.
 
bool empty () const
 
bool contains (const std::string &key) const
 Determines if this key table contains the given key.
 
bool contains_qualified (const std::string &key) const
 Determines if this key table contains the given key. More...
 
std::shared_ptr< baseget (const std::string &key) const
 Obtains the base for a given key. More...
 
std::shared_ptr< baseget_qualified (const std::string &key) const
 Obtains the base for a given key. More...
 
std::shared_ptr< tableget_table (const std::string &key) const
 Obtains a table for a given key, if possible.
 
std::shared_ptr< tableget_table_qualified (const std::string &key) const
 Obtains a table for a given key, if possible. More...
 
std::shared_ptr< arrayget_array (const std::string &key) const
 Obtains an array for a given key.
 
std::shared_ptr< arrayget_array_qualified (const std::string &key) const
 Obtains an array for a given key. More...
 
std::shared_ptr< table_arrayget_table_array (const std::string &key) const
 Obtains a table_array for a given key, if possible.
 
std::shared_ptr< table_arrayget_table_array_qualified (const std::string &key) const
 Obtains a table_array for a given key, if possible. More...
 
template<class T >
option< T > get_as (const std::string &key) const
 Helper function that attempts to get a value corresponding to the template parameter from a given key.
 
template<class T >
option< T > get_qualified_as (const std::string &key) const
 Helper function that attempts to get a value corresponding to the template parameter from a given key. More...
 
template<class T >
array_of_trait< T >::return_type get_array_of (const std::string &key) const
 Helper function that attempts to get an array of values of a given type corresponding to the template parameter for a given key. More...
 
template<class T >
array_of_trait< T >::return_type get_qualified_array_of (const std::string &key) const
 Helper function that attempts to get an array of values of a given type corresponding to the template parameter for a given key. More...
 
void insert (const std::string &key, const std::shared_ptr< base > &value)
 Adds an element to the keytable.
 
template<class T >
void insert (const std::string &key, T &&val, typename value_traits< T >::type *=0)
 Convenience shorthand for adding a simple element to the keytable.
 
void erase (const std::string &key)
 Removes an element from the table.
 
template<>
array_of_trait< array >::return_type get_array_of (const std::string &key) const
 Helper function that attempts to get an array of arrays for a given key. More...
 
template<>
array_of_trait< array >::return_type get_qualified_array_of (const std::string &key) const
 Helper function that attempts to get an array of arrays for a given key. More...
 
- Public Member Functions inherited from cpptoml::base
virtual bool is_value () const
 Determines if the given TOML element is a value.
 
std::shared_ptr< tableas_table ()
 Converts the TOML element into a table.
 
virtual bool is_array () const
 Determines if the TOML element is an array of "leaf" elements.
 
std::shared_ptr< arrayas_array ()
 Converts the TOML element to an array.
 
virtual bool is_table_array () const
 Determines if the given TOML element is an array of tables.
 
std::shared_ptr< table_arrayas_table_array ()
 Converts the TOML element into a table array.
 
template<class T >
std::shared_ptr< value< T > > as ()
 Attempts to coerce the TOML element into a concrete TOML value of type T.
 
template<class T >
std::shared_ptr< const value< T > > as () const
 
template<class Visitor , class... Args>
void accept (Visitor &&visitor, Args &&... args) const
 base implementation of accept() that calls visitor.visit() on the concrete class.
 
template<>
std::shared_ptr< value< double > > as ()
 
template<>
std::shared_ptr< const value< double > > as () const
 

Friends

class table_array
 
std::shared_ptr< tablemake_table ()
 

Detailed Description

Represents a TOML keytable.

Member Typedef Documentation

§ const_iterator

using cpptoml::table::const_iterator = string_to_base_map::const_iterator

tables can be iterated over.

Const version.

Member Function Documentation

§ contains_qualified()

bool cpptoml::table::contains_qualified ( const std::string &  key) const
inline

Determines if this key table contains the given key.

Will resolve "qualified keys". Qualified keys are the full access path separated with dots like "grandparent.parent.child".

§ get()

std::shared_ptr<base> cpptoml::table::get ( const std::string &  key) const
inline

Obtains the base for a given key.

Exceptions
std::out_of_rangeif the key does not exist

§ get_array_of() [1/2]

template<class T >
array_of_trait<T>::return_type cpptoml::table::get_array_of ( const std::string &  key) const
inline

Helper function that attempts to get an array of values of a given type corresponding to the template parameter for a given key.

If the key doesn't exist, doesn't exist as an array type, or one or more keys inside the array type are not of type T, an empty option is returned. Otherwise, an option containing a vector of the values is returned.

§ get_array_of() [2/2]

template<>
array_of_trait<array>::return_type cpptoml::table::get_array_of ( const std::string &  key) const
inline

Helper function that attempts to get an array of arrays for a given key.

If the key doesn't exist, doesn't exist as an array type, or one or more keys inside the array type are not of type T, an empty option is returned. Otherwise, an option containing a vector of the values is returned.

§ get_array_qualified()

std::shared_ptr<array> cpptoml::table::get_array_qualified ( const std::string &  key) const
inline

Obtains an array for a given key.

Will resolve "qualified keys".

§ get_qualified()

std::shared_ptr<base> cpptoml::table::get_qualified ( const std::string &  key) const
inline

Obtains the base for a given key.

Will resolve "qualified keys". Qualified keys are the full access path separated with dots like "grandparent.parent.child".

Exceptions
std::out_of_rangeif the key does not exist

§ get_qualified_array_of() [1/2]

template<class T >
array_of_trait<T>::return_type cpptoml::table::get_qualified_array_of ( const std::string &  key) const
inline

Helper function that attempts to get an array of values of a given type corresponding to the template parameter for a given key.

Will resolve "qualified keys".

If the key doesn't exist, doesn't exist as an array type, or one or more keys inside the array type are not of type T, an empty option is returned. Otherwise, an option containing a vector of the values is returned.

§ get_qualified_array_of() [2/2]

template<>
array_of_trait<array>::return_type cpptoml::table::get_qualified_array_of ( const std::string &  key) const
inline

Helper function that attempts to get an array of arrays for a given key.

Will resolve "qualified keys".

If the key doesn't exist, doesn't exist as an array type, or one or more keys inside the array type are not of type T, an empty option is returned. Otherwise, an option containing a vector of the values is returned.

§ get_qualified_as()

template<class T >
option<T> cpptoml::table::get_qualified_as ( const std::string &  key) const
inline

Helper function that attempts to get a value corresponding to the template parameter from a given key.

Will resolve "qualified keys".

§ get_table_array_qualified()

std::shared_ptr<table_array> cpptoml::table::get_table_array_qualified ( const std::string &  key) const
inline

Obtains a table_array for a given key, if possible.

Will resolve "qualified keys".

§ get_table_qualified()

std::shared_ptr<table> cpptoml::table::get_table_qualified ( const std::string &  key) const
inline

Obtains a table for a given key, if possible.

Will resolve "qualified keys".


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