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

#include "b2rtable.H"

Public Types

enum  
 Identifiers for the data types.
 

Public Member Functions

 RData ()
 Create an RData instance of type NONE.
 
 RData (const bool v)
 Create an RData instance by assigning a single element.
 
 RData (const int v)
 Create an RData instance by assigning a single element.
 
 RData (const double v)
 Create an RData instance by assigning a single element.
 
 RData (const std::complex< double > v)
 Create an RData instance by assigning a single element.
 
template<typename InputIterator >
 RData (InputIterator first, InputIterator last)
 Create an RData instance by copying a range.
 
template<typename T >
 RData (const std::vector< T > &v)
 Create an RData instance by copying a vector.
 
void set ()
 Assign NONE.
 
void set (const bool v)
 Assign a single bool value.
 
void set (const int v)
 Assign a single integer value.
 
void set (const double v)
 Assign a single double value.
 
void set (const std::complex< double > v)
 Assign a single complex-double value.
 
void set (const std::string &data)
 Assign a string.
 
void set (const char *data)
 Assign a 0-terminated array of characters.
 
template<typename T >
void set (const std::vector< T > &v)
 Copy a vector.
 
template<typename InputIterator >
void set (InputIterator first, InputIterator last)
 Copy a range.
 
bool get_bool () const
 
const std::vector< int > & get_int () const
 
const std::vector< double > & get_double () const
 
const std::vector< std::complex< double > > & get_complex_double () const
 
template<typename T >
const std::vector< T > & get () const
 
const std::string & get_string () const
 
int type () const
 
const std::type_info & type_info () const
 Return the typeid() of the data type.
 
size_t size () const
 
bool empty () const
 true if the number of elements is 0.
 
size_t get_data_size () const
 
const void * get_data () const
 
bool operator== (const bool o) const
 Comparison with a bool. The data type must be of type BOOL.
 
bool operator== (const int &o) const
 Comparison with an int. The data type must be of type INT.
 
bool operator== (const std::vector< int > &o) const
 Comparison with a vector of int. The data type must be of type INT.
 
bool operator== (const double &o) const
 Comparison with a double. The data type must be of type DOUBLE.
 
bool operator== (const std::vector< double > &o) const
 Comparison with a vector of double. The data type must be of type DOUBLE.
 
bool operator== (const std::complex< double > &o) const
 
bool operator== (const std::vector< std::complex< double > > &o) const
 
bool operator== (const std::string &o) const
 
bool operator== (const char *o) const
 

Static Public Member Functions

static size_t get_data_size (const int type, const size_t num_elements)
 

Static Public Attributes

static const char * type_to_string [6]
 

Detailed Description

What is stored in RTable objects (the RTable::data_type).

Contains either of a std::vector of int, double, or complex-double values, or a std::string. The internal fields are protected such that the object retains a valid state. Manipulation is done via the constructors and the setter and getter methods. For efficiency, the getter methods return const references; this means that some care is required if the RTable is being modified.

Member Function Documentation

◆ get()

template<typename T >
const std::vector< T > & b2000::RData::get ( ) const
inline
Returns
a const reference to the underlying vector of int/double or complex-doubles.

◆ get_bool()

bool b2000::RData::get_bool ( ) const
inline
Returns
the bool value.

◆ get_complex_double()

const std::vector< std::complex< double > > & b2000::RData::get_complex_double ( ) const
inline
Returns
a const reference to the underlying vector of complex-doubles.

◆ get_data()

const void * b2000::RData::get_data ( ) const
inline
Returns
a void pointer to the array of data (for compatibility with C functons)

◆ get_data_size() [1/2]

size_t b2000::RData::get_data_size ( ) const
inline
Returns
the number of bytes required to store the RData instance in an array of characters.

◆ get_data_size() [2/2]

static size_t b2000::RData::get_data_size ( const int  type,
const size_t  num_elements 
)
inlinestatic
Returns
the number of bytes required to store an array.
Parameters
typeThe data type as returned by type().
num_elementsThe size of the array.

◆ get_double()

const std::vector< double > & b2000::RData::get_double ( ) const
inline
Returns
a const reference to the underlying vector of doubles.

◆ get_int()

const std::vector< int > & b2000::RData::get_int ( ) const
inline
Returns
a const reference to the underlying vector of integers.

◆ get_string()

const std::string & b2000::RData::get_string ( ) const
inline
Returns
a const reference to the underlying string object.

◆ operator==() [1/4]

bool b2000::RData::operator== ( const char *  o) const
inline

Comparison with a 0-terminated character array. The data type must be of type STRING.

◆ operator==() [2/4]

bool b2000::RData::operator== ( const std::complex< double > &  o) const
inline

Comparison with a complex double. The data type must be of type COMPLEX_DOUBLE.

◆ operator==() [3/4]

bool b2000::RData::operator== ( const std::string &  o) const
inline

Comparison with a string. The data type must be of type STRING.

◆ operator==() [4/4]

bool b2000::RData::operator== ( const std::vector< std::complex< double > > &  o) const
inline

Comparison with a vector of complex double. The data type must be of type COMPLEX_DOUBLE.

◆ size()

size_t b2000::RData::size ( ) const
inline
Returns
the number of elements.

◆ type()

int b2000::RData::type ( ) const
inline
Returns
the data type.

Member Data Documentation

◆ type_to_string

const char * b2000::RData::type_to_string
static
Initial value:
= {"NONE", "BOOL", "INT",
"DOUBLE", "COMPLEX_DOUBLE", "STRING"}

Maps data type identifiers to strings (e.g. for error messages).


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