symbols.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::symbols
26 
27 Description
28  ...
29 
30 SourceFiles
31  ...
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef symbols_H
36 #define symbols_H
37 
38 #include "List.H"
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 namespace symbols
45 {
46 
47 /*---------------------------------------------------------------------------*\
48  Class tokeniser Declaration
49 \*---------------------------------------------------------------------------*/
50 
51 class tokeniser
52 {
53  // Private Data
54 
55  //- Reference to the stream
56  Istream& is_;
57 
58  //- List of tokens
59  List<token> tokens_;
60 
61  //- Index of the first token
62  label start_;
63 
64  //- Total number of tokens
65  label size_;
66 
67 
68  // Private Member Functions
69 
70  //- Add a token to the end of the stack
71  void push(const token&);
72 
73  //- Remove a token from the end of the stack
74  token pop();
75 
76  //- Add a popped token back to the end of the stack
77  void unpop(const token&);
78 
79 
80 public:
81 
82  // Constructors
83 
84  //- Construct for an input stream
86 
87 
88  // Member Functions
89 
90  //- Access the stream
91  Istream& stream();
92 
93  //- ...
94  bool hasToken() const;
95 
96  //- ...
97  token nextToken();
98 
99  //- ...
100  void putBack(const token&);
101 
102  //- ...
103  void splitWord(const word&);
104 
105  //- ...
106  static bool valid(char c);
107 
108  //- ...
109  static label priority(const token& t);
110 };
111 
112 
113 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
114 
115 
116 //- Parse tokens into a dimension set or unit conversion, assuming that the '['
117 // has already been read
118 template<class Type>
119 Type parseNoBegin
120 (
121  const label lastPrior,
122  tokeniser& tis,
123  const Type& identity,
124  const HashTable<Type>& table
125 );
126 
127 //- Parse a dimension set or unit conversion, assuming that the '[' has already
128 // been read
129 template<class Type>
130 Type parseNoBegin
131 (
132  Istream& is,
133  const Type& identity,
134  const HashTable<Type>& table
135 );
136 
137 
138 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
139 
140 } // End namespace symbols
141 } // End namespace Foam
142 
143 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
144 
145 #ifdef NoRepository
146  #include "symbolsTemplates.C"
147 #endif
148 
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150 
151 #endif
152 
153 // ************************************************************************* //
An STL-conforming hash table.
Definition: HashTable.H:127
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:91
token nextToken()
...
Definition: symbols.C:88
bool hasToken() const
...
Definition: symbols.C:82
static bool valid(char c)
...
Definition: symbols.C:171
tokeniser(Istream &)
Construct for an input stream.
Definition: symbols.C:65
static label priority(const token &t)
...
Definition: symbols.C:192
void splitWord(const word &)
...
Definition: symbols.C:123
Istream & stream()
Access the stream.
Definition: symbols.C:76
void putBack(const token &)
...
Definition: symbols.C:110
A token holds items read from Istream.
Definition: token.H:73
A class for handling words, derived from string.
Definition: word.H:62
const dimensionedScalar c
Speed of light in a vacuum.
Type parseNoBegin(const label lastPrior, tokeniser &tis, const Type &identity, const HashTable< Type > &table)
Parse tokens into a dimension set or unit conversion, assuming that the '['.
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59