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

#include "b2rtable.H"

Inheritance diagram for b2000::RTable:

Public Member Functions

bool has_key (const std::string &key) const
 
void remove_key (const std::string &key)
 Remove entry "key".
 
const RDataoperator() (const std::string &key) const
 
RDataoperator() (const std::string &key)
 
void update (const RTable &o)
 Update with all (key,value) pairs from another RTable.
 
template<typename T >
void set (const std::string &key, const T &v, const bool new_key=false)
 Assign a single value. If new_key is true, the key must not exist.
 
template<typename T >
void set (const std::string &key, const std::vector< T > &v, const bool new_key=false)
 Copy a vector. If new_key is true, the key must not exist.
 
template<typename InputIterator >
void set (const std::string &key, InputIterator first, InputIterator last, const bool new_key=false)
 Copy a range. If new_key is true, the key must not exist.
 
void set (const std::string &key, const std::string &s, const bool new_key=false)
 Copy a string. If new_key is true, the key must not exist.
 
bool get_bool (const std::string &key) const
 
bool get_bool (const std::string &key, const bool default_) const
 
int get_int (const std::string &key) const
 
int get_int (const std::string &key, const int default_) const
 
double get_double (const std::string &key) const
 
double get_double (const std::string &key, const double default_) const
 
std::complex< double > get_complex_double (const std::string &key) const
 
b2000::csda< double > get_csda_double (const std::string &key) const
 
std::complex< double > get_complex_double (const std::string &key, const std::complex< double > &default_) const
 
b2000::csda< double > get_csda_double (const std::string &key, const b2000::csda< double > &default_) const
 
std::string get_string (const std::string &key) const
 
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
 
void get (const std::string &key, std::vector< int > &v) const
 
void get (const std::string &key, std::vector< double > &v) const
 
void get (const std::string &key, std::vector< std::complex< double > > &v) const
 
void get (const std::string &key, std::vector< b2000::csda< double > > &v) const
 
void get (const std::string &key, const size_t size_, int *v) const
 
void get (const std::string &key, const size_t size_, double *v) const
 
void get (const std::string &key, const size_t size_, std::complex< double > *v) const
 
void append_to_array (std::vector< char > &a) const
 
const char * update_from_array (const char *abegin, const char *aend)
 

Public Attributes

std::string errmsg_context
 Will be pre-pended to error messages.
 

Detailed Description

A map of strings to RData objects.

It may be used like any STL map. In addition, it contains setter and getter functions that perform error checking; in case of an error, an Exception is thrown. The getter functions are alike to those in the abstract Dictionary class.

Member Function Documentation

◆ append_to_array()

void b2000::RTable::append_to_array ( std::vector< char > &  a) const

Stream an RTable instance into a vector of characters (appending to it), according to the MemCom convention for relational tables.

Parameters
aAn STL vector of characters, to which the data will be appended.

◆ get() [1/9]

template<typename T >
T b2000::RTable::get ( const std::string &  key) const
inline

Extract the first element. The key must exist, the RData must be of type T, and its size must be non-zero.

◆ get() [2/9]

void b2000::RTable::get ( const std::string &  key,
const size_t  size_,
double *  v 
) const
inline

Extract a number of elements into an array. The key must exist, the RData must be of type DOUBLE, and its size must be greater than or equal to the size_ parameter.

◆ get() [3/9]

void b2000::RTable::get ( const std::string &  key,
const size_t  size_,
int *  v 
) const
inline

Extract a number of elements into an array. The key must exist, the RData must be of type INT, and its size must be greater than or equal to the size_ parameter.

◆ get() [4/9]

void b2000::RTable::get ( const std::string &  key,
const size_t  size_,
std::complex< double > *  v 
) const
inline

Extract a number of elements into an array of complex numbers or csda numbers. The key must exist, the RData must be of type DOUBLE or COMPLEX_DOUBLE, and its size must be greater than or equal to the size_ parameter.

◆ get() [5/9]

template<typename T >
T b2000::RTable::get ( const std::string &  key,
const T &  default_ 
) const
inline

Extract the first element. If the key does not exist, the default value is returned. If the key exists, the RData must be of type T, and its size must be non-zero.

◆ get() [6/9]

void b2000::RTable::get ( const std::string &  key,
std::vector< b2000::csda< double > > &  v 
) const
inline

Extract all elements into an STL vector of csda numbers. The key must exist and the RData must be of type DOUBLE or COMPLEX_DOUBLE.

◆ get() [7/9]

void b2000::RTable::get ( const std::string &  key,
std::vector< double > &  v 
) const
inline

Extract all elements into an STL vector. The key must exist and the RData must be of type DOUBLE or COMPLEX_DOUBLE.

◆ get() [8/9]

void b2000::RTable::get ( const std::string &  key,
std::vector< int > &  v 
) const
inline

Extract all elements into an STL vector. The key must exist and the RData must be of type INT.

◆ get() [9/9]

void b2000::RTable::get ( const std::string &  key,
std::vector< std::complex< double > > &  v 
) const
inline

Extract all elements into an STL vector of complex numbers. The key must exist and the RData must be of type DOUBLE or COMPLEX_DOUBLE.

◆ get_bool() [1/2]

bool b2000::RTable::get_bool ( const std::string &  key) const
inline

Return the bool value. The key must exist and the RData must be of type BOOL.

◆ get_bool() [2/2]

bool b2000::RTable::get_bool ( const std::string &  key,
const bool  default_ 
) const
inline

Return the bool value. Extract the first element. If the key does not exist, the default value is returned. If the key exists and the RData must be of type BOOL.

◆ get_complex_double() [1/2]

std::complex< double > b2000::RTable::get_complex_double ( const std::string &  key) const
inline

Extract the first element. The key must exist, the RData must be of type COMPLEX_DOUBLE or DOUBLE, and its size must be non-zero.

◆ get_complex_double() [2/2]

std::complex< double > b2000::RTable::get_complex_double ( const std::string &  key,
const std::complex< double > &  default_ 
) const
inline

Extract the first element. If the key does not exist, the default value is returned. If the key exists, the RData must be of type COMPLEX_DOUBLE or DOUBLE, and its size must be non-zero.

◆ get_csda_double() [1/2]

b2000::csda< double > b2000::RTable::get_csda_double ( const std::string &  key) const
inline

Extract the first element and return a csda number. The key must exist, the RData must be of type COMPLEX_DOUBLE or DOUBLE, and its size must be non-zero.

◆ get_csda_double() [2/2]

b2000::csda< double > b2000::RTable::get_csda_double ( const std::string &  key,
const b2000::csda< double > &  default_ 
) const
inline

Extract the first element and return a csda number. If the key does not exist, the default value is returned. If the key exists, the RData must be of type COMPLEX_DOUBLE or DOUBLE, and its size must be non-zero.

◆ get_double() [1/2]

double b2000::RTable::get_double ( const std::string &  key) const
inline

Extract the first element. The key must exist, the RData must be of type DOUBLE, and its size must be non-zero.

◆ get_double() [2/2]

double b2000::RTable::get_double ( const std::string &  key,
const double  default_ 
) const
inline

Extract the first element. If the key does not exist, the default value is returned. If the key exists, the RData must be of type DOUBLE or COMPLEX_DOUBLE, and its size must be non-zero.

◆ get_int() [1/2]

int b2000::RTable::get_int ( const std::string &  key) const
inline

Extract the first element. The key must exist, the RData must be of type INT, and its size must be non-zero.

◆ get_int() [2/2]

int b2000::RTable::get_int ( const std::string &  key,
const int  default_ 
) const
inline

Extract the first element. If the key does not exist, the default value is returned. If the key exists, the RData must be of type INT, and its size must be non-zero.

◆ get_string() [1/2]

std::string b2000::RTable::get_string ( const std::string &  key) const
inline

Extract a string. The key must exist and the RData must be of type STRING.

◆ get_string() [2/2]

std::string b2000::RTable::get_string ( const std::string &  key,
const std::string &  default_ 
) const
inline

Extract a string. If the key does not exist, the default string is returned. If the key exists, the RData must be of type STRING.

◆ has_key()

bool b2000::RTable::has_key ( const std::string &  key) const
inline
Returns
true if an RData instance with that key exists.

◆ operator()() [1/2]

RData & b2000::RTable::operator() ( const std::string &  key)
inline
Returns
the RData instance corresponding to the key (must exist).

◆ operator()() [2/2]

const RData & b2000::RTable::operator() ( const std::string &  key) const
inline
Returns
the RData instance corresponding to the key (must exist).

◆ update_from_array()

const char * b2000::RTable::update_from_array ( const char *  abegin,
const char *  aend 
)

Initialize or update an RTable instance from an array of characters, according to the MemCom convention for relational tables.

Parameters
abeginA pointer to the beginning of the character array.
aendA pointer past the end of the character array.
Returns
A pointer past the last character that was read.

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