Loading...
Searching...
No Matches
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-2023 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 Foam_expressions_scanToken_H
37#define Foam_expressions_scanToken_H
38
39#include "scalar.H"
40#include "vector.H"
41#include "word.H"
42
43// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44
45namespace Foam
46{
47namespace expressions
48{
49
50/*---------------------------------------------------------------------------*\
51 Class scanToken Declaration
52\*---------------------------------------------------------------------------*/
53
56 //- Tagged union types
57 enum tokenType : unsigned char
58 {
59 LABEL = 0,
60 SCALAR,
61 VECTOR,
62 WORD
63 };
64
65
66 // Data
67
68 //- The data content (as a union).
69 // For memory alignment have this appear as the first member.
70 union
71 {
72 Foam::label labelValue;
73 Foam::scalar scalarValue;
77 };
78
79 //- The token type
81
82
83 // Member Functions
84
85 //- Return a null token (label = 0) - in lieu of a default constructor
86 static scanToken null();
87
88 //- Assign type/value to be LABEL. Does not call destroy().
89 void setLabel(label val);
90
91 //- Assign type/value to be SCALAR. Does not call destroy().
92 void setScalar(scalar val);
93
94 //- Assign type/value to be VECTOR. Does not call destroy().
95 void setVector(scalar x, scalar y, scalar z);
96
97 //- Assign type/value to be VECTOR. Does not call destroy().
98 void setVector(const vector& val);
99
100 //- Assign type/value to be WORD (name). Does not call destroy().
101 void setWord(const word& val);
102
103 //- True if a pointer type
104 bool is_pointer() const noexcept
105 {
107 }
108
109 //- Manual deletion of pointer types
110 void destroy();
111};
112
113
114// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
115
116} // End namespace expressions
117} // End namespace Foam
119
120// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121
122#endif
123
124// ************************************************************************* //
scalar y
A class for handling words, derived from Foam::string.
Definition word.H:66
A namespace for expression-related classes/traits etc.
Namespace for OpenFOAM.
const direction noexcept
Definition scalarImpl.H:265
Vector< scalar > vector
Definition vector.H:57
A low-level input/scan token content. No defined constructors/destructors. All memory management is m...
void setLabel(label val)
Assign type/value to be LABEL. Does not call destroy().
void setWord(const word &val)
Assign type/value to be WORD (name). Does not call destroy().
void setScalar(scalar val)
Assign type/value to be SCALAR. Does not call destroy().
bool is_pointer() const noexcept
True if a pointer type.
tokenType
Tagged union types.
void destroy()
Manual deletion of pointer types.
static scanToken null()
Return a null token (label = 0) - in lieu of a default constructor.
tokenType type_
The token type.
void setVector(scalar x, scalar y, scalar z)
Assign type/value to be VECTOR. Does not call destroy().