ARTS  2.2.66
token.h
Go to the documentation of this file.
1 /* Copyright (C) 2000-2012 Stefan Buehler <sbuehler@ltu.se>
2 
3  This program is free software; you can redistribute it and/or modify it
4  under the terms of the GNU General Public License as published by the
5  Free Software Foundation; either version 2, or (at your option) any
6  later version.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16  USA. */
17 
18 #ifndef token_h
19 #define token_h
20 
21 #include "matpackI.h"
22 #include "array.h"
23 #include "mystring.h"
24 
30 
33 class TokVal {
34 public:
35 
37  TokVal() : mtype(undefined_t), ms(), mn(-1), mx(0.), msv(), mnv(),
38  mxv(), mm() { }
39 
41  TokVal(const char s[]) : mtype(String_t), ms(s), mn(-1), mx(0.),
42  msv(), mnv(), mxv(), mm() { }
43 
45  TokVal(const String& s) : mtype(String_t), ms(s), mn(-1), mx(0.),
46  msv(), mnv(), mxv(), mm() { }
47 
49  TokVal(Index n) : mtype(Index_t), ms(), mn(n), mx(0.),
50  msv(), mnv(), mxv(), mm() { }
51 
53  TokVal(Numeric x) : mtype(Numeric_t), ms(), mn(-1), mx(x),
54  msv(), mnv(), mxv(), mm() { }
55 
58  msv(sv), mnv(), mxv(), mm() { }
59 
61  TokVal(ArrayOfIndex nv) : mtype(Array_Index_t), ms(), mn(-1), mx(0.),
62  msv(), mnv(nv), mxv(), mm() { }
63 
65  TokVal(Vector xv) : mtype(Vector_t), ms(), mn(-1), mx(0.),
66  msv(), mnv(), mxv(xv), mm() { }
67 
69  TokVal(Matrix m) : mtype(Matrix_t), ms(), mn(-1), mx(0.),
70  msv(), mnv(), mxv(), mm(m) { }
71 
72  // Conversion functions to return TokVal for the 6 different types:
73 
75  operator String() const;
77  operator Index() const;
79  operator Numeric() const;
80 
82  operator ArrayOfString() const;
84  operator ArrayOfIndex() const;
86  operator Vector() const;
88  operator Matrix() const;
89 
91  friend std::ostream& operator<<(std::ostream& os, const TokVal& a);
92 
93 private:
102 };
103 
104 
105 // typedef Array<TokValType> TokValTypeVector;
106 // typedef Array<TokVal> TokValVector;
107 
108 
109 
110 #endif // token_h
Matrix
The Matrix class.
Definition: matpackI.h:788
TokVal
This stores arbitrary token values and remembers the type.
Definition: token.h:33
TokValType
TokValType
The different token value types.
Definition: token.h:27
TokVal::TokVal
TokVal(Vector xv)
To set TokVal from a Vector.
Definition: token.h:65
TokVal::TokVal
TokVal(Index n)
To set TokVal from an integer.
Definition: token.h:49
Array_Index_t
@ Array_Index_t
Definition: token.h:28
Vector_t
@ Vector_t
Definition: token.h:28
TokVal::TokVal
TokVal(ArrayOfIndex nv)
To set TokVal from an array of integers.
Definition: token.h:61
array.h
This file contains the definition of Array.
Index_t
@ Index_t
Definition: token.h:27
TokVal::TokVal
TokVal(ArrayOfString sv)
To set TokVal from an array of Strings.
Definition: token.h:57
matpackI.h
Array< String >
String_t
@ String_t
Definition: token.h:27
TokVal::mnv
ArrayOfIndex mnv
Definition: token.h:99
my_basic_string< char >
ArrayOfString
Array< String > ArrayOfString
An array of Strings.
Definition: mystring.h:321
Matrix_t
@ Matrix_t
Definition: token.h:28
ArrayOfIndex
Array< Index > ArrayOfIndex
An array of Index.
Definition: array.h:40
TokVal::mm
Matrix mm
Definition: token.h:101
TokVal::TokVal
TokVal(const String &s)
To set TokVal from String (C++ - style).
Definition: token.h:45
Numeric
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:29
Numeric_t
@ Numeric_t
Definition: token.h:27
TokVal::ms
String ms
Definition: token.h:95
TokVal::msv
ArrayOfString msv
Definition: token.h:98
undefined_t
@ undefined_t
Definition: token.h:29
TokVal::TokVal
TokVal(Numeric x)
To set TokVal from a Numeric.
Definition: token.h:53
String
my_basic_string< char > String
The String type for ARTS.
Definition: mystring.h:318
TokVal::mxv
Vector mxv
Definition: token.h:100
TokVal::TokVal
TokVal(const char s[])
To set TokVal from String (C - style).
Definition: token.h:41
Array_String_t
@ Array_String_t
Definition: token.h:28
TokVal::mx
Numeric mx
Definition: token.h:97
TokVal::TokVal
TokVal()
Default Constructor.
Definition: token.h:37
TokVal::mtype
TokValType mtype
Definition: token.h:94
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:35
Vector
The Vector class.
Definition: matpackI.h:556
TokVal::TokVal
TokVal(Matrix m)
To set TokVal from a Matrix.
Definition: token.h:69
mystring.h
This file contains the definition of String, the ARTS string class.
TokVal::operator<<
friend std::ostream & operator<<(std::ostream &os, const TokVal &a)
Output operator.
TokVal::mn
Index mn
Definition: token.h:96