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
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:35
Index mn
Definition: token.h:96
Numeric mx
Definition: token.h:97
The Vector class.
Definition: matpackI.h:556
TokValType
The different token value types.
Definition: token.h:27
ArrayOfIndex mnv
Definition: token.h:99
TokVal(ArrayOfString sv)
To set TokVal from an array of Strings.
Definition: token.h:57
TokVal(Numeric x)
To set TokVal from a Numeric.
Definition: token.h:53
TokVal(const String &s)
To set TokVal from String (C++ - style).
Definition: token.h:45
Array< Index > ArrayOfIndex
An array of Index.
Definition: array.h:40
This file contains the definition of Array.
TokVal(const char s[])
To set TokVal from String (C - style).
Definition: token.h:41
TokVal(Index n)
To set TokVal from an integer.
Definition: token.h:49
String ms
Definition: token.h:95
TokVal(Matrix m)
To set TokVal from a Matrix.
Definition: token.h:69
Definition: token.h:27
Vector mxv
Definition: token.h:100
Definition: token.h:28
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:29
The Matrix class.
Definition: matpackI.h:788
TokVal(ArrayOfIndex nv)
To set TokVal from an array of integers.
Definition: token.h:61
Array< String > ArrayOfString
An array of Strings.
Definition: mystring.h:321
friend std::ostream & operator<<(std::ostream &os, const TokVal &a)
Output operator.
Matrix mm
Definition: token.h:101
ArrayOfString msv
Definition: token.h:98
TokValType mtype
Definition: token.h:94
TokVal()
Default Constructor.
Definition: token.h:37
Definition: token.h:28
TokVal(Vector xv)
To set TokVal from a Vector.
Definition: token.h:65
This stores arbitrary token values and remembers the type.
Definition: token.h:33
Definition: token.h:27
my_basic_string< char > String
The String type for ARTS.
Definition: mystring.h:318
This file contains the definition of String, the ARTS string class.