ARTS  2.4.0(git:4fb77825)
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 "array.h"
22 #include "matpackI.h"
23 #include "mystring.h"
24 
27 enum TokValType {
36 };
37 
40 class TokVal {
41  public:
44  : mtype(undefined_t), ms(), mn(-1), mx(0.), msv(), mnv(), mxv(), mm() {}
45 
47  TokVal(const char s[])
48  : mtype(String_t), ms(s), mn(-1), mx(0.), msv(), mnv(), mxv(), mm() {}
49 
51  TokVal(const String& s)
52  : mtype(String_t), ms(s), mn(-1), mx(0.), msv(), mnv(), mxv(), mm() {}
53 
56  : mtype(Index_t), ms(), mn(n), mx(0.), msv(), mnv(), mxv(), mm() {}
57 
60  : mtype(Numeric_t), ms(), mn(-1), mx(x), msv(), mnv(), mxv(), mm() {}
61 
65  ms(),
66  mn(-1),
67  mx(0.),
68  msv(sv),
69  mnv(),
70  mxv(),
71  mm() {}
72 
76  ms(),
77  mn(-1),
78  mx(0.),
79  msv(),
80  mnv(nv),
81  mxv(),
82  mm() {}
83 
86  : mtype(Vector_t), ms(), mn(-1), mx(0.), msv(), mnv(), mxv(xv), mm() {}
87 
90  : mtype(Matrix_t), ms(), mn(-1), mx(0.), msv(), mnv(), mxv(), mm(m) {}
91 
92  // Conversion functions to return TokVal for the 6 different types:
93 
95  operator String() const;
97  operator Index() const;
99  operator Numeric() const;
100 
102  operator ArrayOfString() const;
104  operator ArrayOfIndex() const;
106  operator Vector() const;
108  operator Matrix() const;
109 
111  friend std::ostream& operator<<(std::ostream& os, const TokVal& a);
112 
113  private:
122 };
123 
124 // typedef Array<TokValType> TokValTypeVector;
125 // typedef Array<TokVal> TokValVector;
126 
127 #endif // token_h
Matrix
The Matrix class.
Definition: matpackI.h:1193
TokVal
This stores arbitrary token values and remembers the type.
Definition: token.h:40
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:85
oem::Matrix
invlib::Matrix< ArtsMatrix > Matrix
invlib wrapper type for ARTS matrices.
Definition: oem.h:34
TokVal::TokVal
TokVal(Index n)
To set TokVal from an integer.
Definition: token.h:55
Array_Index_t
@ Array_Index_t
Definition: token.h:32
Vector_t
@ Vector_t
Definition: token.h:33
TokVal::TokVal
TokVal(ArrayOfIndex nv)
To set TokVal from an array of integers.
Definition: token.h:74
array.h
This file contains the definition of Array.
Index_t
@ Index_t
Definition: token.h:29
TokVal::TokVal
TokVal(ArrayOfString sv)
To set TokVal from an array of Strings.
Definition: token.h:63
matpackI.h
Implementation of Matrix, Vector, and such stuff.
Array< String >
String_t
@ String_t
Definition: token.h:28
TokVal::mnv
ArrayOfIndex mnv
Definition: token.h:119
my_basic_string< char >
ArrayOfString
Array< String > ArrayOfString
An array of Strings.
Definition: mystring.h:283
Matrix_t
@ Matrix_t
Definition: token.h:34
ArrayOfIndex
Array< Index > ArrayOfIndex
An array of Index.
Definition: array.h:40
TokVal::mm
Matrix mm
Definition: token.h:121
TokVal::TokVal
TokVal(const String &s)
To set TokVal from String (C++ - style).
Definition: token.h:51
Numeric
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
Numeric_t
@ Numeric_t
Definition: token.h:30
TokVal::ms
String ms
Definition: token.h:115
oem::Vector
invlib::Vector< ArtsVector > Vector
invlib wrapper type for ARTS vectors.
Definition: oem.h:32
TokVal::msv
ArrayOfString msv
Definition: token.h:118
undefined_t
@ undefined_t
Definition: token.h:35
TokVal::TokVal
TokVal(Numeric x)
To set TokVal from a Numeric.
Definition: token.h:59
String
my_basic_string< char > String
The String type for ARTS.
Definition: mystring.h:280
TokVal::mxv
Vector mxv
Definition: token.h:120
TokVal::TokVal
TokVal(const char s[])
To set TokVal from String (C - style).
Definition: token.h:47
Array_String_t
@ Array_String_t
Definition: token.h:31
TokVal::mx
Numeric mx
Definition: token.h:117
TokVal::TokVal
TokVal()
Default Constructor.
Definition: token.h:43
TokVal::mtype
TokValType mtype
Definition: token.h:114
ARTS::Var::x
Vector x(Workspace &ws) noexcept
Definition: autoarts.h:7346
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
Vector
The Vector class.
Definition: matpackI.h:860
TokVal::TokVal
TokVal(Matrix m)
To set TokVal from a Matrix.
Definition: token.h:89
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:116