1 #ifndef __casac_variant_h__
2 #define __casac_variant_h__
16 enum TYPE {
RECORD,
BOOL,
INT,
UINT,
LONG,
DOUBLE,
COMPLEX,
STRING,
BOOLVEC,
INTVEC,
UINTVEC,
LONGVEC,
DOUBLEVEC,
COMPLEXVEC,
STRINGVEC };
46 {
val.s =
new std::string(arg); }
48 {
val.s =
new std::string(arg); }
51 {
val.bv =
new std::vector<bool>(
arg); }
53 {
val.bv =
new std::vector<bool>(
arg); }
60 {
val.iv =
new std::vector<int>(
arg); }
62 {
val.iv =
new std::vector<int>(
arg); }
69 {
val.uiv =
new std::vector<unsigned int>(
arg); }
71 {
val.uiv =
new std::vector<unsigned int>(
arg); }
79 {
val.lv =
new std::vector<long long>(
arg); }
81 {
val.lv =
new std::vector<long long>(
arg); }
88 {
val.dv =
new std::vector<double>(
arg); }
90 {
val.dv =
new std::vector<double>(
arg); }
97 {
val.cv =
new std::vector<std::complex<double> >(
arg); }
99 {
val.cv =
new std::vector<std::complex<double> >(
arg); }
106 {
val.sv =
new std::vector<std::string>(
arg); }
108 {
val.sv =
new std::vector<std::string>(
arg); }
123 unsigned int touInt( )
const;
124 long long toLong( )
const;
127 std::string
toString(
bool no_brackets=
false )
const;
130 std::vector<unsigned int>
touIntVec( )
const;
131 std::vector<long long>
toLongVec( )
const;
133 std::vector<std::complex<double> >
toComplexVec( )
const;
160 bool getBool( )
const throw(error);
161 int getInt( ) const throw(error);
162 unsigned int getuInt( ) const throw(error);
163 long long getLong( ) const throw(error);
165 const std::complex<
double> &
getComplex( ) const throw(error);
166 const std::
string &
getString( ) const throw(error);
167 const std::vector<
int> &
getIntVec( ) const throw(error);
168 const std::vector<
unsigned int> &
getuIntVec( ) const throw(error);
169 const std::vector<
long long> &
getLongVec( ) const throw(error);
170 const std::vector<
bool> &
getBoolVec( ) const throw(error);
171 const std::vector<
double> &
getDoubleVec( ) const throw(error);
172 const std::vector<std::complex<
double> > &
getComplexVec( ) const throw(error);
173 const std::vector<std::
string> &
getStringVec( ) const throw(error);
175 const std::vector<
int> &
shape() const;
193 std::vector<
int> &
shape();
199 void push(
bool,
bool conform =
true);
200 void push(
int,
bool conform =
true);
201 void push(
unsigned int,
bool conform =
true);
202 void push(
long long,
bool conform =
true);
203 void push(
double,
bool conform =
true);
204 void push(std::vector<long long>,
bool conform =
true);
205 void push(std::complex<double>,
bool conform =
true);
206 void push(
const std::string&,
bool conform =
true);
208 void place(
bool,
unsigned int index,
bool conform =
true);
209 void place(
int,
unsigned int index,
bool conform =
true);
210 void place(
unsigned int,
unsigned int index,
bool conform =
true);
211 void place(
long long,
unsigned int index,
bool conform =
true);
212 void place(
double,
unsigned int index,
bool conform =
true);
213 void place(std::vector<long long>,
unsigned int index,
bool conform =
true);
214 void place(std::complex<double>,
unsigned int index,
bool conform =
true);
215 void place(
const std::string&,
unsigned int index,
bool conform =
true);
239 std::vector<bool> *
bv;
243 std::vector<int> *
iv;
244 std::vector<unsigned int> *
uiv;
245 std::vector<long long> *
lv;
247 std::vector<double> *
dv;
248 std::complex<double> *
c;
249 std::vector<std::complex<double> > *
cv;
251 std::vector<std::string> *
sv;
std::vector< double > * dv
std::vector< int > & getIntVecMod()
std::vector< bool > & getBoolVecMod()
variant(unsigned int arg)
const std::vector< long long > & getLongVec() const
std::vector< std::string > & asStringVec(int size=-1)
unsigned int getuInt() const
variant(const std::vector< double > &arg, const std::vector< int > &theshape)
LatticeExprNode arg(const LatticeExprNode &expr)
variant(const std::vector< int > &arg)
std::complex< double > & getComplexMod()
std::vector< unsigned int > & asuIntVec(int size=-1)
std::vector< std::complex< double > > & asComplexVec(int size=-1)
const std::vector< int > & arrayshape() const
std::complex< double > toComplex() const
const std::vector< unsigned int > & getuIntVec() const
std::complex< double > & asComplex()
variant(std::vector< int > *arg, std::vector< int > &theshape)
variant(const std::vector< bool > &arg)
variant(std::vector< long long > *arg, std::vector< int > &theshape)
std::string & getStringMod()
variant(std::vector< int > *arg)
bool & asBool()
Yet to be implemented.
const std::vector< double > & getDoubleVec() const
const std::vector< int > & getIntVec() const
bool & getBoolMod()
Modify
std::complex< double > * c
unsigned int touInt() const
todo: o create python to/from record functions o implement compare() o implement record_to_string() o...
variant(std::complex< double > arg)
variant(std::vector< unsigned int > *arg)
int compare(const variant *) const
std::vector< std::string > toStringVec() const
variant(const std::vector< long long > &arg)
std::vector< unsigned int > * uiv
int shape_size() const
what size does the shape imply
void place(bool, unsigned int index, bool conform=true)
variant & operator=(const variant &other)
overflow(std::string lbl)
std::vector< bool > & asBoolVec(int size=-1)
std::vector< std::string > * sv
void push(bool, bool conform=true)
std::string toString(bool no_brackets=false) const
std::vector< long long > toLongVec() const
variant(std::vector< std::complex< double > > *arg, std::vector< int > &theshape)
long long getLong() const
variant(std::vector< unsigned int > *arg, std::vector< int > &theshape)
std::vector< int > & asIntVec(int size=-1)
bool getBool() const
Const
std::vector< int > shape_
union casac::variant::@67 val
const std::string & typeString() const
const std::vector< bool > & getBoolVec() const
std::vector< double > & asDoubleVec(int size=-1)
variant(const std::vector< long long > &arg, const std::vector< int > &theshape)
std::vector< int > toIntVec() const
std::string create_message(const std::string s) const
variant initialize_variant(const std::string &)
variant(const std::vector< unsigned int > &arg, const std::vector< int > &theshape)
variant(std::vector< bool > *arg, std::vector< int > &theshape)
variant(std::vector< double > *arg)
variant(const std::vector< std::complex< double > > &arg, const std::vector< int > &theshape)
const std::string & message() const
variant(const std::string &arg)
std::vector< long long > & asLongVec(int size=-1)
const std::complex< double > & getComplex() const
variant(const std::vector< int > &arg, const std::vector< int > &theshape)
static TYPE compatible_type(TYPE one, TYPE two)
variant(std::vector< std::complex< double > > *arg)
std::vector< std::string > & getStringVecMod()
const std::string & getString() const
unsigned int & getuIntMod()
const std::vector< std::complex< double > > & getComplexVec() const
variant(const std::vector< std::string > &arg)
std::vector< unsigned int > touIntVec() const
const std::vector< int > & shape() const
std::vector< bool > toBoolVec() const
void as(TYPE t, int size=-1)
std::vector< unsigned int > & getuIntVecMod()
variant(std::vector< std::string > *arg)
variant(std::vector< long long > *arg)
variant(std::vector< std::string > *arg, std::vector< int > &theshape)
std::vector< std::complex< double > > toComplexVec() const
std::vector< double > toDoubleVec() const
const record & getRecord() const
std::vector< std::complex< double > > * cv
static unsigned int record_id_count
4294967295
variant(const std::vector< double > &arg)
variant(const std::vector< std::complex< double > > &arg)
variant(std::vector< double > *arg, std::vector< int > &theshape)
std::vector< long long > * lv
std::vector< double > & getDoubleVecMod()
const std::vector< std::string > & getStringVec() const
bool empty() const
return true if empty string, empty record, or size 0 vector.
variant(const std::vector< bool > &arg, const std::vector< int > &theshape)
variant(std::vector< bool > *arg)
casac::record & asRecord()
variant(const std::vector< unsigned int > &arg)
variant(const std::vector< std::string > &arg, const std::vector< int > &theshape)
std::vector< std::complex< double > > & getComplexVecMod()