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-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::expressions::scanToken
28
29Description
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
43namespace Foam
44{
45namespace expressions
46{
47
48/*---------------------------------------------------------------------------*\
49 Class scanToken Declaration
50\*---------------------------------------------------------------------------*/
52struct scanToken
53{
54 //- Tagged union types
55 enum tokenType : unsigned char
56 {
57 LABEL = 0,
59 VECTOR,
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// ************************************************************************* //
scalar y
A class for handling words, derived from Foam::string.
Definition: word.H:68
Namespace for OpenFOAM.
A low-level input/scan token content. No defined constructors/destructors. All memory management is m...
Definition: exprScanToken.H:52
void setLabel(label val)
Assign type/value to be LABEL. Does not call destroy().
Definition: exprScanToken.C:57
void setWord(const word &val)
Assign type/value to be WORD (name). Does not call destroy().
Definition: exprScanToken.C:85
void setScalar(scalar val)
Assign type/value to be SCALAR. Does not call destroy().
Definition: exprScanToken.C:64
tokenType
Tagged union types.
Definition: exprScanToken.H:55
void destroy()
Manual deletion of pointer types.
Definition: exprScanToken.C:42
static scanToken null()
Return a null token - in lieu of a default constructor.
Definition: exprScanToken.C:32
tokenType type_
The token type.
Definition: exprScanToken.H:77
void setVector(scalar x, scalar y, scalar z)
Assign type/value to be VECTOR. Does not call destroy().
Definition: exprScanToken.C:71