casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
casac::variant Class Reference

#include <variant.h>

Classes

class  error
 
class  overflow
 

Public Types

enum  TYPE {
  RECORD,
  BOOL,
  INT,
  UINT,
  LONG,
  DOUBLE,
  COMPLEX,
  STRING,
  BOOLVEC,
  INTVEC,
  UINTVEC,
  LONGVEC,
  DOUBLEVEC,
  COMPLEXVEC,
  STRINGVEC
}
 

Public Member Functions

variantclone () const
 
int compare (const variant *) const
 
 variant ()
 
 variant (const variant &)
 
 variant (bool arg)
 
 variant (int arg)
 
 variant (unsigned int arg)
 
 variant (long long arg)
 
 variant (double arg)
 
 variant (std::complex< double > arg)
 
 variant (const char *arg)
 
 variant (const std::string &arg)
 
 variant (const std::vector< bool > &arg)
 
 variant (const std::vector< bool > &arg, const std::vector< int > &theshape)
 
 variant (std::vector< bool > *arg)
 
 variant (std::vector< bool > *arg, std::vector< int > &theshape)
 
 variant (const std::vector< int > &arg)
 
 variant (const std::vector< int > &arg, const std::vector< int > &theshape)
 
 variant (std::vector< int > *arg)
 
 variant (std::vector< int > *arg, std::vector< int > &theshape)
 
 variant (const std::vector< unsigned int > &arg)
 
 variant (const std::vector< unsigned int > &arg, const std::vector< int > &theshape)
 
 variant (std::vector< unsigned int > *arg)
 
 variant (std::vector< unsigned int > *arg, std::vector< int > &theshape)
 
 variant (const std::vector< long long > &arg)
 
 variant (const std::vector< long long > &arg, const std::vector< int > &theshape)
 
 variant (std::vector< long long > *arg)
 
 variant (std::vector< long long > *arg, std::vector< int > &theshape)
 
 variant (const std::vector< double > &arg)
 
 variant (const std::vector< double > &arg, const std::vector< int > &theshape)
 
 variant (std::vector< double > *arg)
 
 variant (std::vector< double > *arg, std::vector< int > &theshape)
 
 variant (const std::vector< std::complex< double > > &arg)
 
 variant (const std::vector< std::complex< double > > &arg, const std::vector< int > &theshape)
 
 variant (std::vector< std::complex< double > > *arg)
 
 variant (std::vector< std::complex< double > > *arg, std::vector< int > &theshape)
 
 variant (const std::vector< std::string > &arg, const std::vector< int > &theshape)
 
 variant (const std::vector< std::string > &arg)
 
 variant (std::vector< std::string > *arg)
 
 variant (std::vector< std::string > *arg, std::vector< int > &theshape)
 
 variant (const record &arg)
 
 variant (record *arg)
 
 ~variant ()
 
variantoperator= (const variant &other)
 
bool toBool () const
 
int toInt () const
 
unsigned int touInt () const
 
long long toLong () const
 
double toDouble () const
 
std::complex< double > toComplex () const
 
std::string toString (bool no_brackets=false) const
 
std::vector< bool > toBoolVec () const
 
std::vector< int > toIntVec () const
 
std::vector< unsigned int > touIntVec () const
 
std::vector< long long > toLongVec () const
 
std::vector< double > toDoubleVec () const
 
std::vector< std::complex
< double > > 
toComplexVec () const
 
std::vector< std::string > toStringVec () const
 
bool & asBool ()
 Yet to be implemented. More...
 
int & asInt ()
 
unsigned int & asuInt ()
 
long long & asLong ()
 
double & asDouble ()
 
std::complex< double > & asComplex ()
 
std::string & asString ()
 
std::vector< int > & asIntVec (int size=-1)
 
std::vector< unsigned int > & asuIntVec (int size=-1)
 
std::vector< long long > & asLongVec (int size=-1)
 
std::vector< bool > & asBoolVec (int size=-1)
 
std::vector< double > & asDoubleVec (int size=-1)
 
std::vector< std::complex
< double > > & 
asComplexVec (int size=-1)
 
std::vector< std::string > & asStringVec (int size=-1)
 
casac::recordasRecord ()
 
void as (TYPE t, int size=-1)
 
bool getBool () const throw (error)
 

Const

More...
 
int getInt () const throw (error)
 
unsigned int getuInt () const throw (error)
 
long long getLong () const throw (error)
 
double getDouble () const throw (error)
 
const std::complex< double > & getComplex () const throw (error)
 
const std::string & getString () const throw (error)
 
const std::vector< int > & getIntVec () const throw (error)
 
const std::vector< unsigned int > & getuIntVec () const throw (error)
 
const std::vector< long long > & getLongVec () const throw (error)
 
const std::vector< bool > & getBoolVec () const throw (error)
 
const std::vector< double > & getDoubleVec () const throw (error)
 
const std::vector
< std::complex< double > > & 
getComplexVec () const throw (error)
 
const std::vector< std::string > & getStringVec () const throw (error)
 
const recordgetRecord () const throw (error)
 
const std::vector< int > & shape () const
 
const std::vector< int > & arrayshape () const
 
bool & getBoolMod () throw (error)
 

Modify

More...
 
int & getIntMod () throw (error)
 
unsigned int & getuIntMod () throw (error)
 
double & getDoubleMod () throw (error)
 
std::complex< double > & getComplexMod () throw (error)
 
std::string & getStringMod () throw (error)
 
std::vector< int > & getIntVecMod () throw (error)
 
std::vector< unsigned int > & getuIntVecMod () throw (error)
 
std::vector< bool > & getBoolVecMod () throw (error)
 
std::vector< double > & getDoubleVecMod () throw (error)
 
std::vector< std::complex
< double > > & 
getComplexVecMod () throw (error)
 
std::vector< std::string > & getStringVecMod () throw (error)
 
recordgetRecordMod () throw (error)
 
std::vector< int > & shape ()
 
std::vector< int > & arrayshape ()
 
const std::string & typeString () const
 
TYPE type () const
 
void push (bool, bool conform=true)
 
void push (int, bool conform=true)
 
void push (unsigned int, bool conform=true)
 
void push (long long, bool conform=true)
 
void push (double, bool conform=true)
 
void push (std::vector< long long >, bool conform=true)
 
void push (std::complex< double >, bool conform=true)
 
void push (const std::string &, bool conform=true)
 
void place (bool, unsigned int index, bool conform=true)
 
void place (int, unsigned int index, bool conform=true)
 
void place (unsigned int, unsigned int index, bool conform=true)
 
void place (long long, unsigned int index, bool conform=true)
 
void place (double, unsigned int index, bool conform=true)
 
void place (std::vector< long long >, unsigned int index, bool conform=true)
 
void place (std::complex< double >, unsigned int index, bool conform=true)
 
void place (const std::string &, unsigned int index, bool conform=true)
 
int size () const
 
void resize (int size)
 
void dump () const
 
bool empty () const
 return true if empty string, empty record, or size 0 vector. More...
 

Static Public Member Functions

static TYPE compatible_type (TYPE one, TYPE two)
 

Private Member Functions

void freeStorage ()
 
int shape_size () const
 what size does the shape imply More...
 
int vec_size () const
 
std::string create_message (const std::string s) const
 

Private Attributes

TYPE typev
 
union {
   bool   b
 
   std::vector< bool > *   bv
 
   int   i
 
   unsigned int   ui
 
   long long   l
 
   std::vector< int > *   iv
 
   std::vector< unsigned int > *   uiv
 
   std::vector< long long > *   lv
 
   double   d
 
   std::vector< double > *   dv
 
   std::complex< double > *   c
 
   std::vector< std::complex
< double > > *   cv
 
   std::string *   s
 
   std::vector< std::string > *   sv
 
   record *   recordv
 
val
 
std::vector< int > shape_
 

Static Private Attributes

static unsigned int record_id_count
 4294967295 More...
 

Detailed Description

Definition at line 12 of file variant.h.

Member Enumeration Documentation

Enumerator
RECORD 
BOOL 
INT 
UINT 
LONG 
DOUBLE 
COMPLEX 
STRING 
BOOLVEC 
INTVEC 
UINTVEC 
LONGVEC 
DOUBLEVEC 
COMPLEXVEC 
STRINGVEC 

Definition at line 16 of file variant.h.

Constructor & Destructor Documentation

casac::variant::variant ( )

Referenced by clone().

casac::variant::variant ( const variant )
casac::variant::variant ( bool  arg)
inline

Definition at line 39 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( int  arg)
inline

Definition at line 40 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( unsigned int  arg)
inline

Definition at line 41 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( long long  arg)
inline

Definition at line 42 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( double  arg)
inline

Definition at line 43 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( std::complex< double >  arg)
inline

Definition at line 44 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( const char *  arg)
inline

Definition at line 45 of file variant.h.

References val.

casac::variant::variant ( const std::string &  arg)
inline

Definition at line 47 of file variant.h.

References val.

casac::variant::variant ( const std::vector< bool > &  arg)
inline

Definition at line 50 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( const std::vector< bool > &  arg,
const std::vector< int > &  theshape 
)
inline

Definition at line 52 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( std::vector< bool > *  arg)
inline

Definition at line 54 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( std::vector< bool > *  arg,
std::vector< int > &  theshape 
)
inline

Definition at line 56 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( const std::vector< int > &  arg)
inline

Definition at line 59 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( const std::vector< int > &  arg,
const std::vector< int > &  theshape 
)
inline

Definition at line 61 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( std::vector< int > *  arg)
inline

Definition at line 63 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( std::vector< int > *  arg,
std::vector< int > &  theshape 
)
inline

Definition at line 65 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( const std::vector< unsigned int > &  arg)
inline

Definition at line 68 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( const std::vector< unsigned int > &  arg,
const std::vector< int > &  theshape 
)
inline

Definition at line 70 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( std::vector< unsigned int > *  arg)
inline

Definition at line 72 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( std::vector< unsigned int > *  arg,
std::vector< int > &  theshape 
)
inline

Definition at line 74 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( const std::vector< long long > &  arg)
inline

Definition at line 78 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( const std::vector< long long > &  arg,
const std::vector< int > &  theshape 
)
inline

Definition at line 80 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( std::vector< long long > *  arg)
inline

Definition at line 82 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( std::vector< long long > *  arg,
std::vector< int > &  theshape 
)
inline

Definition at line 84 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( const std::vector< double > &  arg)
inline

Definition at line 87 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( const std::vector< double > &  arg,
const std::vector< int > &  theshape 
)
inline

Definition at line 89 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( std::vector< double > *  arg)
inline

Definition at line 91 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( std::vector< double > *  arg,
std::vector< int > &  theshape 
)
inline

Definition at line 93 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( const std::vector< std::complex< double > > &  arg)
inline

Definition at line 96 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( const std::vector< std::complex< double > > &  arg,
const std::vector< int > &  theshape 
)
inline

Definition at line 98 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( std::vector< std::complex< double > > *  arg)
inline

Definition at line 100 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( std::vector< std::complex< double > > *  arg,
std::vector< int > &  theshape 
)
inline

Definition at line 102 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( const std::vector< std::string > &  arg,
const std::vector< int > &  theshape 
)
inline

Definition at line 105 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( const std::vector< std::string > &  arg)
inline

Definition at line 107 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( std::vector< std::string > *  arg)
inline

Definition at line 109 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( std::vector< std::string > *  arg,
std::vector< int > &  theshape 
)
inline

Definition at line 111 of file variant.h.

References casacore::arg(), and val.

casac::variant::variant ( const record arg)
casac::variant::variant ( record arg)
casac::variant::~variant ( )

Member Function Documentation

const std::vector<int>& casac::variant::arrayshape ( ) const
inline

Definition at line 176 of file variant.h.

References shape().

std::vector<int>& casac::variant::arrayshape ( )
inline

Definition at line 194 of file variant.h.

References shape().

void casac::variant::as ( TYPE  t,
int  size = -1 
)
bool& casac::variant::asBool ( )

Yet to be implemented.

Modify

std::vector<bool>& casac::variant::asBoolVec ( int  size = -1)
std::complex<double>& casac::variant::asComplex ( )
std::vector<std::complex<double> >& casac::variant::asComplexVec ( int  size = -1)
double& casac::variant::asDouble ( )
std::vector<double>& casac::variant::asDoubleVec ( int  size = -1)
int& casac::variant::asInt ( )
std::vector<int>& casac::variant::asIntVec ( int  size = -1)
long long& casac::variant::asLong ( )
std::vector<long long>& casac::variant::asLongVec ( int  size = -1)
casac::record& casac::variant::asRecord ( )
std::string& casac::variant::asString ( )
std::vector<std::string>& casac::variant::asStringVec ( int  size = -1)
unsigned int& casac::variant::asuInt ( )
std::vector<unsigned int>& casac::variant::asuIntVec ( int  size = -1)
variant* casac::variant::clone ( ) const
inline

Definition at line 33 of file variant.h.

References variant().

int casac::variant::compare ( const variant ) const
static TYPE casac::variant::compatible_type ( TYPE  one,
TYPE  two 
)
static
std::string casac::variant::create_message ( const std::string  s) const
private
void casac::variant::dump ( ) const
bool casac::variant::empty ( ) const

return true if empty string, empty record, or size 0 vector.

always returns false if object is a non-array bool or numerical type

void casac::variant::freeStorage ( )
private
bool casac::variant::getBool ( ) const
throw (error
)

Const

bool& casac::variant::getBoolMod ( )
throw (error
)

Modify

const std::vector<bool>& casac::variant::getBoolVec ( ) const
throw (error
)
std::vector<bool>& casac::variant::getBoolVecMod ( )
throw (error
)
const std::complex<double>& casac::variant::getComplex ( ) const
throw (error
)
std::complex<double>& casac::variant::getComplexMod ( )
throw (error
)
const std::vector<std::complex<double> >& casac::variant::getComplexVec ( ) const
throw (error
)
std::vector<std::complex<double> >& casac::variant::getComplexVecMod ( )
throw (error
)
double casac::variant::getDouble ( ) const
throw (error
)
double& casac::variant::getDoubleMod ( )
throw (error
)
const std::vector<double>& casac::variant::getDoubleVec ( ) const
throw (error
)
std::vector<double>& casac::variant::getDoubleVecMod ( )
throw (error
)
int casac::variant::getInt ( ) const
throw (error
)
int& casac::variant::getIntMod ( )
throw (error
)
const std::vector<int>& casac::variant::getIntVec ( ) const
throw (error
)
std::vector<int>& casac::variant::getIntVecMod ( )
throw (error
)
long long casac::variant::getLong ( ) const
throw (error
)
const std::vector<long long>& casac::variant::getLongVec ( ) const
throw (error
)
const record& casac::variant::getRecord ( ) const
throw (error
)
record& casac::variant::getRecordMod ( )
throw (error
)
const std::string& casac::variant::getString ( ) const
throw (error
)
std::string& casac::variant::getStringMod ( )
throw (error
)
const std::vector<std::string>& casac::variant::getStringVec ( ) const
throw (error
)
std::vector<std::string>& casac::variant::getStringVecMod ( )
throw (error
)
unsigned int casac::variant::getuInt ( ) const
throw (error
)
unsigned int& casac::variant::getuIntMod ( )
throw (error
)
const std::vector<unsigned int>& casac::variant::getuIntVec ( ) const
throw (error
)
std::vector<unsigned int>& casac::variant::getuIntVecMod ( )
throw (error
)
variant& casac::variant::operator= ( const variant other)
void casac::variant::place ( bool  ,
unsigned int  index,
bool  conform = true 
)
void casac::variant::place ( int  ,
unsigned int  index,
bool  conform = true 
)
void casac::variant::place ( unsigned  int,
unsigned int  index,
bool  conform = true 
)
void casac::variant::place ( long  long,
unsigned int  index,
bool  conform = true 
)
void casac::variant::place ( double  ,
unsigned int  index,
bool  conform = true 
)
void casac::variant::place ( std::vector< long long >  ,
unsigned int  index,
bool  conform = true 
)
void casac::variant::place ( std::complex< double >  ,
unsigned int  index,
bool  conform = true 
)
void casac::variant::place ( const std::string &  ,
unsigned int  index,
bool  conform = true 
)
void casac::variant::push ( bool  ,
bool  conform = true 
)
void casac::variant::push ( int  ,
bool  conform = true 
)
void casac::variant::push ( unsigned  int,
bool  conform = true 
)
void casac::variant::push ( long  long,
bool  conform = true 
)
void casac::variant::push ( double  ,
bool  conform = true 
)
void casac::variant::push ( std::vector< long long >  ,
bool  conform = true 
)
void casac::variant::push ( std::complex< double >  ,
bool  conform = true 
)
void casac::variant::push ( const std::string &  ,
bool  conform = true 
)
void casac::variant::resize ( int  size)
const std::vector<int>& casac::variant::shape ( ) const

Referenced by arrayshape().

std::vector<int>& casac::variant::shape ( )
int casac::variant::shape_size ( ) const
private

what size does the shape imply

int casac::variant::size ( ) const
inline

Definition at line 217 of file variant.h.

References BOOLVEC, typev, and vec_size().

bool casac::variant::toBool ( ) const
std::vector<bool> casac::variant::toBoolVec ( ) const
std::complex<double> casac::variant::toComplex ( ) const
std::vector<std::complex<double> > casac::variant::toComplexVec ( ) const
double casac::variant::toDouble ( ) const
std::vector<double> casac::variant::toDoubleVec ( ) const
int casac::variant::toInt ( ) const
std::vector<int> casac::variant::toIntVec ( ) const
long long casac::variant::toLong ( ) const
std::vector<long long> casac::variant::toLongVec ( ) const
std::string casac::variant::toString ( bool  no_brackets = false) const
std::vector<std::string> casac::variant::toStringVec ( ) const
unsigned int casac::variant::touInt ( ) const
std::vector<unsigned int> casac::variant::touIntVec ( ) const
TYPE casac::variant::type ( ) const
inline

Definition at line 197 of file variant.h.

References typev.

const std::string& casac::variant::typeString ( ) const
int casac::variant::vec_size ( ) const
private

Referenced by size().

Member Data Documentation

bool casac::variant::b

Definition at line 238 of file variant.h.

std::vector<bool>* casac::variant::bv

Definition at line 239 of file variant.h.

std::complex<double>* casac::variant::c

Definition at line 248 of file variant.h.

std::vector<std::complex<double> >* casac::variant::cv

Definition at line 249 of file variant.h.

double casac::variant::d

Definition at line 246 of file variant.h.

std::vector<double>* casac::variant::dv

Definition at line 247 of file variant.h.

int casac::variant::i

Definition at line 240 of file variant.h.

std::vector<int>* casac::variant::iv

Definition at line 243 of file variant.h.

long long casac::variant::l

Definition at line 242 of file variant.h.

std::vector<long long>* casac::variant::lv

Definition at line 245 of file variant.h.

unsigned int casac::variant::record_id_count
staticprivate

4294967295

Definition at line 233 of file variant.h.

record* casac::variant::recordv

Definition at line 252 of file variant.h.

std::string* casac::variant::s

Definition at line 250 of file variant.h.

std::vector<int> casac::variant::shape_
private

Definition at line 254 of file variant.h.

std::vector<std::string>* casac::variant::sv

Definition at line 251 of file variant.h.

TYPE casac::variant::typev
private

Definition at line 236 of file variant.h.

Referenced by size(), and type().

unsigned int casac::variant::ui

Definition at line 241 of file variant.h.

std::vector<unsigned int>* casac::variant::uiv

Definition at line 244 of file variant.h.

union { ... } casac::variant::val

Referenced by variant().


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