GRASP rci-qed
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
cpptoml::table Class Reference

#include <cpptoml.h>

Inheritance diagram for cpptoml::table:
Inheritance graph
[legend]
Collaboration diagram for cpptoml::table:
Collaboration graph
[legend]

Public Types

using iterator = string_to_base_map::iterator
 
using const_iterator = string_to_base_map::const_iterator
 

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
 
bool empty () const
 
bool contains (const std::string &key) const
 
bool contains_qualified (const std::string &key) const
 
std::shared_ptr< baseget (const std::string &key) const
 
std::shared_ptr< baseget_qualified (const std::string &key) const
 
std::shared_ptr< tableget_table (const std::string &key) const
 
std::shared_ptr< tableget_table_qualified (const std::string &key) const
 
std::shared_ptr< arrayget_array (const std::string &key) const
 
std::shared_ptr< arrayget_array_qualified (const std::string &key) const
 
std::shared_ptr< table_arrayget_table_array (const std::string &key) const
 
std::shared_ptr< table_arrayget_table_array_qualified (const std::string &key) const
 
template<class T >
option< T > get_as (const std::string &key) const
 
template<class T >
option< T > get_qualified_as (const std::string &key) const
 
template<class T >
array_of_trait< T >::return_type get_array_of (const std::string &key) const
 
template<class T >
array_of_trait< T >::return_type get_qualified_array_of (const std::string &key) const
 
void insert (const std::string &key, const std::shared_ptr< base > &value)
 
template<class T >
void insert (const std::string &key, T &&val, typename value_traits< T >::type *=0)
 
void erase (const std::string &key)
 
template<>
array_of_trait< array >::return_type get_array_of (const std::string &key) const
 
template<>
array_of_trait< array >::return_type get_qualified_array_of (const std::string &key) const
 
- Public Member Functions inherited from cpptoml::base
virtual ~base ()=default
 
virtual bool is_value () const
 
std::shared_ptr< tableas_table ()
 
virtual bool is_array () const
 
std::shared_ptr< arrayas_array ()
 
virtual bool is_table_array () const
 
std::shared_ptr< table_arrayas_table_array ()
 
template<class T >
std::shared_ptr< value< T > > as ()
 
template<class T >
std::shared_ptr< const value< T > > as () const
 
template<class Visitor , class... Args>
void accept (Visitor &&visitor, Args &&... args) const
 
template<>
std::shared_ptr< value< double > > as ()
 
template<>
std::shared_ptr< const value< double > > as () const
 

Private Member Functions

 table ()
 
 table (const table &obj)=delete
 
tableoperator= (const table &rhs)=delete
 
std::vector< std::string > split (const std::string &value, char separator) const
 
bool resolve_qualified (const std::string &key, std::shared_ptr< base > *p=nullptr) const
 

Private Attributes

string_to_base_map map_
 

Friends

class table_array
 
std::shared_ptr< tablemake_table ()
 

Additional Inherited Members

- Protected Member Functions inherited from cpptoml::base
 base ()
 

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.

◆ iterator

using cpptoml::table::iterator = string_to_base_map::iterator

tables can be iterated over.

Constructor & Destructor Documentation

◆ table() [1/2]

cpptoml::table::table ( )
inlineprivate

◆ table() [2/2]

cpptoml::table::table ( const table obj)
privatedelete

Member Function Documentation

◆ begin() [1/2]

iterator cpptoml::table::begin ( )
inline
Here is the caller graph for this function:

◆ begin() [2/2]

const_iterator cpptoml::table::begin ( ) const
inline

◆ clone()

std::shared_ptr< base > cpptoml::table::clone ( ) const
inlineoverridevirtual

Implements cpptoml::base.

Here is the call graph for this function:

◆ contains()

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

Determines if this key table contains the given key.

Here is the caller graph for this function:

◆ 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".

Here is the caller graph for this function:

◆ empty()

bool cpptoml::table::empty ( ) const
inline
Here is the caller graph for this function:

◆ end() [1/2]

iterator cpptoml::table::end ( )
inline
Here is the caller graph for this function:

◆ end() [2/2]

const_iterator cpptoml::table::end ( ) const
inline

◆ erase()

void cpptoml::table::erase ( const std::string &  key)
inline

Removes an element from the table.

◆ 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
Here is the caller graph for this function:

◆ get_array()

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

Obtains an array for a given key.

◆ 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_as()

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

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

◆ 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".

Here is the caller graph for this function:

◆ get_table()

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

Obtains a table for a given key, if possible.

◆ get_table_array()

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

Obtains a table_array for a given key, if possible.

◆ 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".

◆ insert() [1/2]

void cpptoml::table::insert ( const std::string &  key,
const std::shared_ptr< base > &  value 
)
inline

Adds an element to the keytable.

Here is the caller graph for this function:

◆ insert() [2/2]

template<class T >
void cpptoml::table::insert ( const std::string &  key,
T &&  val,
typename value_traits< T >::type *  = 0 
)
inline

Convenience shorthand for adding a simple element to the keytable.

Here is the call graph for this function:

◆ is_table()

bool cpptoml::table::is_table ( ) const
inlineoverridevirtual

Determines if the given TOML element is a table.

Reimplemented from cpptoml::base.

◆ operator=()

table& cpptoml::table::operator= ( const table rhs)
privatedelete

◆ resolve_qualified()

bool cpptoml::table::resolve_qualified ( const std::string &  key,
std::shared_ptr< base > *  p = nullptr 
) const
inlineprivate

◆ split()

std::vector<std::string> cpptoml::table::split ( const std::string &  value,
char  separator 
) const
inlineprivate

Friends And Related Function Documentation

◆ make_table

std::shared_ptr<table> make_table ( )
friend

◆ table_array

friend class table_array
friend

Member Data Documentation

◆ map_

string_to_base_map cpptoml::table::map_
private

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