exprScanToken.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2019-2021 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::expressions::scanToken
28 
29 Description
30  A low-level input/scan token content.
31  No defined constructors/destructors.
32  All memory management is manual!
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef expressions_scanToken_H
37 #define expressions_scanToken_H
38 
39 #include "scalar.H"
40 #include "vector.H"
41 #include "word.H"
42 
43 namespace Foam
44 {
45 namespace expressions
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class scanToken Declaration
50 \*---------------------------------------------------------------------------*/
51 
52 struct scanToken
53 {
54  //- Tagged union types
55  enum tokenType : unsigned char
56  {
57  LABEL = 0,
60  WORD
61  };
62 
63 
64  // Data
65 
66  //- The data content (as a union).
67  // For memory alignment have this appear as the first member.
68  union
69  {
70  Foam::label labelValue;
71  Foam::scalar scalarValue;
75  };
76 
77  //- The token type
79 
80 
81  // Member Functions
82 
83  //- Return a null token - in lieu of a default constructor
84  static scanToken null();
85 
86  //- Assign type/value to be LABEL. Does not call destroy().
87  void setLabel(label val);
88 
89  //- Assign type/value to be SCALAR. Does not call destroy().
90  void setScalar(scalar val);
91 
92  //- Assign type/value to be VECTOR. Does not call destroy().
93  void setVector(scalar x, scalar y, scalar z);
94 
95  //- Assign type/value to be VECTOR. Does not call destroy().
96  void setVector(const vector& val);
97 
98  //- Assign type/value to be WORD (name). Does not call destroy().
99  void setWord(const word& val);
100 
101  //- Manual deletion of pointer types
102  void destroy();
103 };
104 
105 
106 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
107 
108 } // End namespace expressions
109 } // End namespace Foam
110 
111 
112 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
113 
114 #endif
115 
116 // ************************************************************************* //
Foam::expressions::scanToken::setScalar
void setScalar(scalar val)
Assign type/value to be SCALAR. Does not call destroy().
Definition: exprScanToken.C:64
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::expressions::scanToken::tokenType
tokenType
Tagged union types.
Definition: exprScanToken.H:54
Foam::expressions::scanToken::WORD
Definition: exprScanToken.H:59
Foam::expressions::scanToken::wordPtr
Foam::word * wordPtr
Definition: exprScanToken.H:72
Foam::expressions::scanToken::type_
tokenType type_
The token type.
Definition: exprScanToken.H:77
Foam::expressions::scanToken::name_
Foam::word * name_
Definition: exprScanToken.H:73
Foam::expressions::scanToken
A low-level input/scan token content. No defined constructors/destructors. All memory management is m...
Definition: exprScanToken.H:51
Foam::expressions::scanToken::setWord
void setWord(const word &val)
Assign type/value to be WORD (name). Does not call destroy().
Definition: exprScanToken.C:85
Foam::expressions::scanToken::VECTOR
Definition: exprScanToken.H:58
Foam::expressions::scanToken::SCALAR
Definition: exprScanToken.H:57
Foam::expressions::scanToken::setLabel
void setLabel(label val)
Assign type/value to be LABEL. Does not call destroy().
Definition: exprScanToken.C:57
Foam::expressions::scanToken::setVector
void setVector(scalar x, scalar y, scalar z)
Assign type/value to be VECTOR. Does not call destroy().
Definition: exprScanToken.C:71
scalar.H
Foam::expressions::scanToken::destroy
void destroy()
Manual deletion of pointer types.
Definition: exprScanToken.C:42
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::expressions::scanToken::scalarValue
Foam::scalar scalarValue
Definition: exprScanToken.H:70
Foam::expressions::scanToken::labelValue
Foam::label labelValue
Definition: exprScanToken.H:69
Foam::Vector< scalar >
Foam::expressions::scanToken::LABEL
Definition: exprScanToken.H:56
x
x
Definition: LISASMDCalcMethod2.H:52
vector.H
word.H
Foam::expressions::scanToken::vectorPtr
Foam::vector * vectorPtr
Definition: exprScanToken.H:71
y
scalar y
Definition: LISASMDCalcMethod1.H:14