b2api
B2000++ API Reference Manual, VERSION 4.6
 
Loading...
Searching...
No Matches
b2000::Dictionary Class Referenceabstract

#include "b2dictionary.H"

Inheritance diagram for b2000::Dictionary:
Collaboration diagram for b2000::Dictionary:

Public Member Functions

virtual bool has_key (const std::string &key) const =0
 
virtual bool get_bool (const std::string &key) const =0
 
virtual bool get_bool (const std::string &key, bool default_) const
 
virtual int get_int (const std::string &key) const =0
 
virtual int get_int (const std::string &key, int default_) const
 
virtual double get_double (const std::string &key) const =0
 
virtual double get_double (const std::string &key, double default_) const
 
virtual b2000::csda< double > get_csda_double (const std::string &key) const =0
 
virtual b2000::csda< double > get_csda_double (const std::string &key, b2000::csda< double > default_) const
 
virtual std::complex< double > get_complex_double (const std::string &key) const =0
 
virtual std::complex< double > get_complex_double (const std::string &key, std::complex< double > default_) const
 
virtual std::string get_string (const std::string &key) const =0
 
virtual std::string get_string (const std::string &key, const std::string &default_) const
 
template<typename T >
get (const std::string &key) const
 
template<typename T >
get (const std::string &key, const T &default_) const
 
virtual void get (const std::string &key, std::vector< int > &v) const =0
 
virtual void get (const std::string &key, std::vector< double > &v) const =0
 
virtual void get (const std::string &key, std::vector< b2000::csda< double > > &v) const =0
 
virtual void get (const std::string &key, std::vector< std::complex< double > > &v) const =0
 
virtual void warn_on_non_used_key () const =0
 
- Public Member Functions inherited from b2000::Object
virtual const std::string & get_object_name () const
 
virtual ~Object ()
 

Static Public Member Functions

static Dictionaryget_empty ()
 

Additional Inherited Members

- Static Public Attributes inherited from b2000::Object
static ObjectType type
 

Detailed Description

A dictionary is a collection of (key, value) pairs. The keys are unique (there is only one value for a given key, or none).

The values can be of type bool, int, double, std::complex<double>, std::string, std::vector of int, std::vector of double, and std::vector of std::complex<double>.

In derived classes, the get_* functions should throw KeyError if the key does not exist, and TypeError if the value cannot be converted to the specified type.

Member Function Documentation

◆ get() [1/6]

template<typename T >
T b2000::Dictionary::get ( const std::string &  key) const
inline
Returns
A value of type T

◆ get() [2/6]

template<typename T >
T b2000::Dictionary::get ( const std::string &  key,
const T &  default_ 
) const
inline
Returns
A value of type T. If the key does not exist, return the specified default value.

◆ get() [3/6]

virtual void b2000::Dictionary::get ( const std::string &  key,
std::vector< b2000::csda< double > > &  v 
) const
pure virtual

Extract a vector of csda values.

Implemented in b2000::cmdline::CmdOptDictionary.

◆ get() [4/6]

virtual void b2000::Dictionary::get ( const std::string &  key,
std::vector< double > &  v 
) const
pure virtual

Extract a vector of double values.

Implemented in b2000::cmdline::CmdOptDictionary.

◆ get() [5/6]

virtual void b2000::Dictionary::get ( const std::string &  key,
std::vector< int > &  v 
) const
pure virtual

Extract a vector of int values.

Implemented in b2000::cmdline::CmdOptDictionary.

◆ get() [6/6]

virtual void b2000::Dictionary::get ( const std::string &  key,
std::vector< std::complex< double > > &  v 
) const
pure virtual

Extract a vector of complex values.

Implemented in b2000::cmdline::CmdOptDictionary.

◆ get_bool() [1/2]

virtual bool b2000::Dictionary::get_bool ( const std::string &  key) const
pure virtual
Returns
A bool value.

Implemented in b2000::cmdline::CmdOptDictionary.

◆ get_bool() [2/2]

virtual bool b2000::Dictionary::get_bool ( const std::string &  key,
bool  default_ 
) const
inlinevirtual
Returns
A bool value. If the key does not exist, return the specified default value.

◆ get_complex_double() [1/2]

virtual std::complex< double > b2000::Dictionary::get_complex_double ( const std::string &  key) const
pure virtual
Returns
A complex value.

Implemented in b2000::cmdline::CmdOptDictionary.

◆ get_complex_double() [2/2]

virtual std::complex< double > b2000::Dictionary::get_complex_double ( const std::string &  key,
std::complex< double >  default_ 
) const
inlinevirtual
Returns
A complex value. If the key does not exist, return the specified default value.

◆ get_csda_double() [1/2]

virtual b2000::csda< double > b2000::Dictionary::get_csda_double ( const std::string &  key) const
pure virtual
Returns
A csda value.

Implemented in b2000::cmdline::CmdOptDictionary.

◆ get_csda_double() [2/2]

virtual b2000::csda< double > b2000::Dictionary::get_csda_double ( const std::string &  key,
b2000::csda< double >  default_ 
) const
inlinevirtual
Returns
A csda value. If the key does not exist, return the specified default value.

◆ get_double() [1/2]

virtual double b2000::Dictionary::get_double ( const std::string &  key) const
pure virtual
Returns
A double value.

Implemented in b2000::cmdline::CmdOptDictionary.

◆ get_double() [2/2]

virtual double b2000::Dictionary::get_double ( const std::string &  key,
double  default_ 
) const
inlinevirtual
Returns
A double value. If the key does not exist, return the specified default value.

◆ get_empty()

b2000::Dictionary & b2000::Dictionary::get_empty ( )
static
Returns
A reference to a static instance of an empty dictionary.

◆ get_int() [1/2]

virtual int b2000::Dictionary::get_int ( const std::string &  key) const
pure virtual
Returns
An integer value.

Implemented in b2000::cmdline::CmdOptDictionary.

◆ get_int() [2/2]

virtual int b2000::Dictionary::get_int ( const std::string &  key,
int  default_ 
) const
inlinevirtual
Returns
An integer value. If the key does not exist, return the specified default value.

◆ get_string() [1/2]

virtual std::string b2000::Dictionary::get_string ( const std::string &  key) const
pure virtual
Returns
A string.

Implemented in b2000::cmdline::CmdOptDictionary.

◆ get_string() [2/2]

virtual std::string b2000::Dictionary::get_string ( const std::string &  key,
const std::string &  default_ 
) const
inlinevirtual
Returns
A string. If the key does not exist, return the specified default string.

◆ has_key()

virtual bool b2000::Dictionary::has_key ( const std::string &  key) const
pure virtual
Returns
Whether a key is present in the dictionary.

Implemented in b2000::cmdline::CmdOptDictionary.

◆ warn_on_non_used_key()

virtual void b2000::Dictionary::warn_on_non_used_key ( ) const
pure virtual

Can be used to give a warning on keys that were not set in the dictionary.

Implemented in b2000::cmdline::CmdOptDictionary.


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