pnode Class Reference

pnode Class Reference#

Reference API: gko::config::pnode Class Reference
Reference API
gko::config::pnode Class Referencefinal

#include <ginkgo/core/config/property_tree.hpp>

Public Types

enum class  tag_t {
  empty , array , boolean , real ,
  integer , string , map
}
 
using key_type = std::string
 
using map_type = std::map< key_type, pnode >
 
using array_type = std::vector< pnode >
 

Public Member Functions

 pnode ()
 
 pnode (bool boolean)
 
template<typename T , std::enable_if_t< std::is_integral< T >::value > * = nullptr>
 pnode (T integer)
 
 pnode (const std::string &str)
 
 pnode (const char *str)
 
 pnode (double real)
 
 pnode (const array_type &array)
 
 pnode (const map_type &map)
 
 operator bool () const noexcept
 
bool operator== (const pnode &rhs) const
 
bool operator!= (const pnode &rhs) const
 
tag_t get_tag () const
 
const array_type & get_array () const
 
const map_type & get_map () const
 
bool get_boolean () const
 
std::int64_t get_integer () const
 
double get_real () const
 
const std::string & get_string () const
 
const pnodeget (const std::string &key) const
 
const pnodeget (int index) const
 

Detailed Description

pnode describes a tree of properties.

A pnode can either be empty, hold a value (a string, integer, real, or bool), contain an array of pnode., or contain a mapping between strings and pnodes.

Member Enumeration Documentation

◆ tag_t

enum class gko::config::pnode::tag_t
strong

tag_t is the indicator for the current node storage.

Constructor & Destructor Documentation

◆ pnode() [1/8]

gko::config::pnode::pnode ( )
explicit

Default constructor: create an empty node

◆ pnode() [2/8]

gko::config::pnode::pnode ( bool  boolean)
explicit

Constructor for bool

Parameters
booleanthe bool type value

◆ pnode() [3/8]

template<typename T , std::enable_if_t< std::is_integral< T >::value > * >
gko::config::pnode::pnode ( integer)
explicit

Constructor for integer with all integer type

Template Parameters
Tinput type
Parameters
integerthe integer type value

◆ pnode() [4/8]

gko::config::pnode::pnode ( const std::string &  str)
explicit

Constructor for string

Parameters
strstring type value

◆ pnode() [5/8]

gko::config::pnode::pnode ( const char *  str)
explicit

Constructor for char* (otherwise, it will use bool)

Parameters
strthe string like "..."

◆ pnode() [6/8]

gko::config::pnode::pnode ( double  real)
explicit

Constructor for double (and also float)

Parameters
realthe floating point type value

◆ pnode() [7/8]

gko::config::pnode::pnode ( const array_type &  array)
explicit

Constructor for array

Parameters
arrayan pnode array

◆ pnode() [8/8]

gko::config::pnode::pnode ( const map_type &  map)
explicit

Constructor for map

Parameters
mapa (string, pnode)-map

Member Function Documentation

◆ get() [1/2]

const pnode & gko::config::pnode::get ( const std::string &  key) const

This function is to access the data under the map. It will throw error when it does not hold a map. When access non-existent key in the map, it will return an empty node.

Parameters
keythe key for the node of the map
Returns
node. If the map does not have the key, return an empty node.

◆ get() [2/2]

const pnode & gko::config::pnode::get ( int  index) const

This function is to access the data under the array. It will throw error when it does not hold an array or access out-of-bound index.

Parameters
indexthe node index in array
Returns
node.

◆ get_array()

const array_type & gko::config::pnode::get_array ( ) const

Access the array stored in this property node. Throws gko::InvalidStateError if the property node does not store an array.

Returns
the array

◆ get_boolean()

bool gko::config::pnode::get_boolean ( ) const

Access the boolean value stored in this property node. Throws gko::InvalidStateError if the property node does not store a boolean value.

Returns
the boolean value

◆ get_integer()

std::int64_t gko::config::pnode::get_integer ( ) const
  • Access the integer value stored in this property node. Throws gko::InvalidStateError if the property node does not store an integer value.
Returns
the integer value

◆ get_map()

const map_type & gko::config::pnode::get_map ( ) const

Access the map stored in this property node. Throws gko::InvalidStateError if the property node does not store a map.

Returns
the map

◆ get_real()

double gko::config::pnode::get_real ( ) const

Access the real floating point value stored in this property node. Throws gko::InvalidStateError if the property node does not store a real value

Returns
the real floating point value

◆ get_string()

const std::string & gko::config::pnode::get_string ( ) const

Access the string stored in this property node. Throws gko::InvalidStateError if the property node does not store a string.

Returns
the string

◆ get_tag()

tag_t gko::config::pnode::get_tag ( ) const

Get the current node tag.

Returns
the tag

◆ operator bool()

gko::config::pnode::operator bool ( ) const
explicitnoexcept

bool conversion. It's true if and only if it is not empty.

◆ operator!=()

bool gko::config::pnode::operator!= ( const pnode rhs) const

Check whether the representing data of two pnodes are different.

◆ operator==()

bool gko::config::pnode::operator== ( const pnode rhs) const

Check whether the representing data of two pnodes are the same


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