cpptoml
A C++11 parser for TOML
Loading...
Searching...
No Matches
cpptoml::array Class Reference
Inheritance diagram for cpptoml::array:
cpptoml::base

Public Types

using size_type = std::size_t
using iterator = std::vector<std::shared_ptr<base>>::iterator
 arrays can be iterated over
using const_iterator = std::vector<std::shared_ptr<base>>::const_iterator
 arrays can be iterated over.

Public Member Functions

std::shared_ptr< base > clone () const override
virtual bool is_array () const override
 Determines if the TOML element is an array of "leaf" elements.
iterator begin ()
const_iterator begin () const
iterator end ()
const_iterator end () const
std::vector< std::shared_ptr< base > > & get ()
 Obtains the array (vector) of base values.
const std::vector< std::shared_ptr< base > > & get () const
 Obtains the array (vector) of base values.
std::shared_ptr< base > at (size_t idx) const
template<class T>
std::vector< std::shared_ptr< value< T > > > array_of () const
 Obtains an array of value<T>s.
template<class T>
array_of_trait< T >::return_type get_array_of () const
 Obtains a option<vector<T>>.
std::vector< std::shared_ptr< array > > nested_array () const
 Obtains an array of arrays.
template<class T>
void push_back (const std::shared_ptr< value< T > > &val)
 Add a value to the end of the array.
void push_back (const std::shared_ptr< array > &val)
 Add an array to the end of the array.
template<class T>
void push_back (T &&val, typename value_traits< T >::type *=0)
 Convenience function for adding a simple element to the end of the array.
template<class T>
iterator insert (iterator position, const std::shared_ptr< value< T > > &value)
 Insert a value into the array.
iterator insert (iterator position, const std::shared_ptr< array > &value)
 Insert an array into the array.
template<class T>
iterator insert (iterator position, T &&val, typename value_traits< T >::type *=0)
 Convenience function for inserting a simple element in the array.
iterator erase (iterator position)
 Erase an element from the array.
void clear ()
 Clear the array.
void reserve (size_type n)
 Reserve space for n values.
template<>
array_of_trait< array >::return_type get_array_of () const
 Obtains a option<vector<T>>.
Public Member Functions inherited from cpptoml::base
virtual bool is_value () const
 Determines if the given TOML element is a value.
virtual bool is_table () const
 Determines if the given TOML element is a table.
std::shared_ptr< tableas_table ()
 Converts the TOML element into a table.
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

Private Member Functions

template<class InputIterator>
 array (InputIterator begin, InputIterator end)
 array (const array &obj)=delete
array & operator= (const array &obj)=delete

Private Attributes

std::vector< std::shared_ptr< base > > values_

Friends

std::shared_ptr< array > make_array ()

Member Typedef Documentation

◆ const_iterator

using cpptoml::array::const_iterator = std::vector<std::shared_ptr<base>>::const_iterator

arrays can be iterated over.

Const version.

Member Function Documentation

◆ clone()

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

Implements cpptoml::base.

◆ is_array()

virtual bool cpptoml::array::is_array ( ) const
inlineoverridevirtual

Determines if the TOML element is an array of "leaf" elements.

Reimplemented from cpptoml::base.

◆ get()

const std::vector< std::shared_ptr< base > > & cpptoml::array::get ( ) const
inline

Obtains the array (vector) of base values.

Const version.

◆ array_of()

template<class T>
std::vector< std::shared_ptr< value< T > > > cpptoml::array::array_of ( ) const
inline

Obtains an array of value<T>s.

Note that elements may be nullptr if they cannot be converted to a value<T>.

◆ get_array_of() [1/2]

template<class T>
array_of_trait< T >::return_type cpptoml::array::get_array_of ( ) const
inline

Obtains a option<vector<T>>.

The option will be empty if the array contains values that are not of type T.

◆ nested_array()

std::vector< std::shared_ptr< array > > cpptoml::array::nested_array ( ) const
inline

Obtains an array of arrays.

Note that elements may be nullptr if they cannot be converted to a array.

◆ get_array_of() [2/2]

template<>
array_of_trait< array >::return_type cpptoml::array::get_array_of ( ) const
inline

Obtains a option<vector<T>>.

The option will be empty if the array contains values that are not of type T.


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