token.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) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2017-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::token
29
30Description
31 A token holds an item read from Istream.
32
33SourceFiles
34 tokenI.H
35 token.C
36 tokenIO.C
37
38\*---------------------------------------------------------------------------*/
39
40#ifndef Foam_token_H
41#define Foam_token_H
42
43#include "label.H"
44#include "uLabel.H"
45#include "scalar.H"
46#include "word.H"
47#include "InfoProxy.H"
48#include "refCount.H"
49#include "typeInfo.H"
51#define NoHashTableC
53
54#include <iostream>
55
56// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57
58namespace Foam
59{
60
61// Forward Declarations
62class token;
63Ostream& operator<<(Ostream& os, const token& tok);
64
65/*---------------------------------------------------------------------------*\
66 Class token Declaration
67\*---------------------------------------------------------------------------*/
69class token
70{
71public:
72
73 //- Enumeration defining the types of token.
74 // Since the enumeration is used to tag content in Pstream, it is of
75 // type \c char and shall have values that do not overlap with regular
76 // punctuation characters.
77 enum tokenType : char
78 {
79 UNDEFINED = '\0',
80 ERROR = '\x80',
81
82 // Fundamental types
88 DOUBLE,
89
90 // Pointer types
93 COMPOUND,
94
103
104 // Aliases
108 };
109
110
111 //- Stream or output control flags (1-byte width)
112 enum flagType
115 ASCII = 1,
117 };
118
119
120 //- Standard punctuation tokens (a character)
121 enum punctuationToken : char
123 NULL_TOKEN = '\0',
124 TAB = '\t',
125 NL = '\n',
126 SPACE = ' ',
128 COLON = ':',
129 SEMICOLON = ';',
130 COMMA = ',',
131 HASH = '#',
132 DOLLAR = '$',
133 QUESTION = '?',
134 ATSYM = '@',
135 SQUOTE = '\'',
136 DQUOTE = '"',
138 ASSIGN = '=',
139 PLUS = '+',
140 MINUS = '-',
141 MULTIPLY = '*',
142 DIVIDE = '/',
144 LPAREN = '(',
145 RPAREN = ')',
146 LSQUARE = '[',
147 RSQUARE = ']',
148 LBRACE = '{',
149 RBRACE = '}',
150
151 // With semantically meaning
161 END_BLOCK = RBRACE,
165 };
166
167
168 //- Abstract base class for complex tokens
169 class compound
170 :
171 public refCount
172 {
173 //- Has compound token already been transferred
174 bool moved_;
175
176 //- No copy construct
177 compound(const compound&) = delete;
178
179 //- No copy assignment
180 compound& operator=(const compound&) = delete;
181
182 public:
183
184 //- Declare type-name, virtual type (with debug switch)
185 TypeName("compound");
186
187 //- Declare run-time constructor selection table
189 (
190 autoPtr,
191 compound,
192 Istream,
193 (Istream& is),
194 (is)
195 );
196
197
198 // Constructors
199
200 //- Default construct
201 constexpr compound() noexcept
202 :
203 moved_(false)
204 {}
205
206 //- Construct compound from Istream
207 static autoPtr<compound> New(const word& type, Istream& is);
208
209
210 //- Destructor
211 virtual ~compound() noexcept = default;
212
213
214 // Member Functions
215
216 //- Test if name is a known (registered) compound type
217 static bool isCompound(const word& name);
218
219 //- Get compound transferred status
220 bool moved() const noexcept
221 {
222 return moved_;
223 }
224
225 //- Set compound transferred status
226 void moved(bool b) noexcept
227 {
228 moved_ = b;
229 }
230
231 //- The size of the underlying content
232 virtual label size() const = 0;
233
234 //- Redirect write to underlying content
235 virtual void write(Ostream& os) const = 0;
236
237
238 // Operators
239
240 //- Output operator
241 friend Ostream& operator<<(Ostream& os, const compound& ct);
242 };
243
244
245 //- A templated class for holding compound tokens
246 template<class T>
247 class Compound
248 :
249 public token::compound,
250 public T
251 {
252 public:
253
254 //- Declare type-name, virtual type (with debug switch)
255 TypeName("Compound<T>");
256
257 // Constructors
258
259 //- Copy construct
260 explicit Compound(const T& val)
261 :
262 T(val)
263 {}
264
265 //- Move construct
266 explicit Compound(T&& val)
267 :
268 T(std::move(val))
269 {}
270
271 //- Read construct from Istream
272 explicit Compound(Istream& is)
273 :
274 T(is)
275 {}
276
277
278 // Member Functions
279
280 //- The size of the underlying content
281 virtual label size() const
282 {
283 return T::size();
284 }
285
286 //- Redirect write to underlying content
287 virtual void write(Ostream& os) const
288 {
289 operator<<(os, static_cast<const T&>(*this));
290 }
291 };
292
293
294 //- An undefined token
295 static const token undefinedToken;
296
297
298private:
299
300 //- A %union of token types
301 union content
302 {
303 // Fundamental values. Largest first for any {} initialization.
304 int64_t int64Val;
305 int32_t int32Val;
306
307 int flagVal; // bitmask - stored as int, not enum
308 punctuationToken punctuationVal;
309 label labelVal;
310 floatScalar floatVal;
311 doubleScalar doubleVal;
312
313 // Pointers
314 word* wordPtr;
315 string* stringPtr;
316 mutable compound* compoundPtr;
317 };
318
319
320 // Private Data
321
322 //- The data content (as a union).
323 // For memory alignment this should appear as the first member.
324 content data_;
325
326 //- The token type
327 tokenType type_;
328
329 //- Line number in the file the token was read from
330 label line_;
331
332
333 // Private Member Functions
334
335 //- Set as UNDEFINED and zero the union content without any checking
336 inline void setUndefined() noexcept;
337
338 // Parse error, expected 'expected', found ...
339 void parseError(const char* expected) const;
340
341
342public:
343
344 // Static Data Members
345
346 //- The type name is "token"
347 static constexpr const char* const typeName = "token";
348
349
350 // Constructors
351
352 //- Default construct, initialized to an UNDEFINED token.
353 inline constexpr token() noexcept;
354
355 //- Copy construct
356 inline token(const token& t);
357
358 //- Move construct. The original token is left as UNDEFINED.
359 inline token(token&& t) noexcept;
360
361 //- Construct punctuation character token
362 inline explicit token(punctuationToken p, label lineNum=0) noexcept;
363
364 //- Construct label token
365 inline explicit token(const label val, label lineNum=0) noexcept;
366
367 //- Construct float token
368 inline explicit token(const floatScalar val, label lineNum=0) noexcept;
369
370 //- Construct double token
371 inline explicit token(const doubleScalar val, label lineNum=0) noexcept;
372
373 //- Copy construct word token
374 inline explicit token(const word& w, label lineNum=0);
375
376 //- Copy construct string token
377 inline explicit token(const string& str, label lineNum=0);
378
379 //- Move construct word token
380 inline explicit token(word&& w, label lineNum=0);
381
382 //- Move construct string token
383 inline explicit token(string&& str, label lineNum=0);
384
385 //- Construct from a compound pointer, taking ownership
386 inline explicit token(token::compound* ptr, label lineNum=0);
387
388 //- Construct from Istream
389 explicit token(Istream& is);
390
391
392 //- Destructor
393 inline ~token();
394
395
396 // Static Functions
397
398 //- Create a bool token.
399 inline static token boolean(bool on) noexcept;
400
401 //- Create a token with stream flags, no sanity check
402 //
403 // \param bitmask the flags to set
404 inline static token flag(int bitmask) noexcept;
405
406 //- True if the character is a punctuation separator (eg, in ISstream).
407 // Since it could also start a number, SUBTRACT is not included as
408 // a separator.
409 //
410 // \param c the character to test, passed as int for consistency with
411 // isdigit, isspace etc.
412 inline static bool isseparator(int c) noexcept;
413
414
415 // Member Functions
416
417 // Status
418
419 //- Return the name of the token type
420 word name() const;
421
422 //- Return the token type
423 inline tokenType type() const noexcept;
424
425 //- Change the token type, for similar types.
426 // This can be used to change between string-like variants
427 // (eg, STRING, VARIABLE, etc)
428 // To change types entirely (eg, STRING to DOUBLE),
429 // use the corresponding assignment operator.
430 //
431 // \return true if the change was successful or no change was required
432 inline bool setType(const tokenType tokType) noexcept;
433
434 //- The line number for the token
435 inline label lineNumber() const noexcept;
436
437 //- Change token line number, return old value
438 inline label lineNumber(const label lineNum) noexcept;
439
440 //- True if token is not UNDEFINED or ERROR
441 inline bool good() const noexcept;
442
443 //- Token is UNDEFINED
444 inline bool undefined() const noexcept;
445
446 //- Token is ERROR
447 inline bool error() const noexcept;
448
449 //- Token is BOOL
450 inline bool isBool() const noexcept;
451
452 //- Token is FLAG
453 inline bool isFlag() const noexcept;
454
455 //- Token is PUNCTUATION
456 inline bool isPunctuation() const noexcept;
457
458 //- True if token is PUNCTUATION and equal to parameter
459 inline bool isPunctuation(const punctuationToken p) const noexcept;
460
461 //- Token is PUNCTUATION and isseparator
462 inline bool isSeparator() const noexcept;
463
464 //- Token is LABEL
465 inline bool isLabel() const noexcept;
466
467 //- True if token is LABEL and equal to parameter
468 inline bool isLabel(const label val) const noexcept;
469
470 //- Token is FLOAT
471 inline bool isFloat() const noexcept;
472
473 //- Token is DOUBLE
474 inline bool isDouble() const noexcept;
475
476 //- Token is FLOAT or DOUBLE
477 inline bool isScalar() const noexcept;
478
479 //- Token is LABEL, FLOAT or DOUBLE
480 inline bool isNumber() const noexcept;
481
482 //- Token is word-variant (WORD, DIRECTIVE)
483 inline bool isWord() const noexcept;
484
485 //- Token is word-variant and equal to parameter
486 inline bool isWord(const std::string& s) const;
487
488 //- Token is DIRECTIVE (word variant)
489 inline bool isDirective() const noexcept;
490
491 //- Token is (quoted) STRING (string variant)
492 inline bool isQuotedString() const noexcept;
493
494 //- Token is string-variant (STRING, EXPRESSION, VARIABLE, VERBATIM)
495 inline bool isString() const noexcept;
496
497 //- Token is EXPRESSION (string variant)
498 inline bool isExpression() const noexcept;
499
500 //- Token is VARIABLE (string variant)
501 inline bool isVariable() const noexcept;
502
503 //- Token is VERBATIM string (string variant)
504 inline bool isVerbatim() const noexcept;
505
506 //- Token is word-variant or string-variant
507 //- (WORD, DIRECTIVE, STRING, EXPRESSION, VARIABLE, VERBATIM)
508 inline bool isStringType() const noexcept;
509
510 //- Token is COMPOUND
511 inline bool isCompound() const noexcept;
512
513
514 // Access
515
516 //- Return boolean token value.
517 // Report FatalIOError and return false if token is not BOOL or LABEL
518 inline bool boolToken() const;
519
520 //- Return flag bitmask value.
521 // Report FatalIOError and return NO_FLAG if token is not FLAG
522 inline int flagToken() const;
523
524 //- Return punctuation character.
525 // Report FatalIOError and return \b \\0 if token is not PUNCTUATION
526 inline punctuationToken pToken() const;
527
528 //- Return label value.
529 // Report FatalIOError and return \b 0 if token is not LABEL
530 inline label labelToken() const;
531
532 //- Return float value.
533 // Report FatalIOError and return \b 0 if token is not FLOAT
534 inline floatScalar floatToken() const;
535
536 //- Return double value.
537 // Report FatalIOError and return \b 0 if token is not DOUBLE
538 inline doubleScalar doubleToken() const;
539
540 //- Return float or double value.
541 // Report FatalIOError and return \b 0 if token is not a
542 // FLOAT or DOUBLE
543 inline scalar scalarToken() const;
544
545 //- Return label, float or double value.
546 // Report FatalIOError and return \b 0 if token is not a
547 // LABEL, FLOAT or DOUBLE
548 inline scalar number() const;
549
550 //- Return const reference to the word contents.
551 // Report FatalIOError and return \b "" if token is not a
552 // WORD or DIRECTIVE
553 inline const word& wordToken() const;
554
555 //- Return const reference to the string contents.
556 // Report FatalIOError and return \b "" if token is not a
557 // STRING, EXPRESSION, VARIABLE, VERBATIM
558 // or an upcast WORD or DIRECTIVE
559 inline const string& stringToken() const;
560
561 //- Read access for compound token
562 inline const compound& compoundToken() const;
563
564 //- Return reference to compound and mark internally as \em released.
566
567 //- Return reference to compound and mark internally as \em released.
568 // The Istream is used for reference error messages only.
570
571
572 // Edit
573
574 //- Reset token to UNDEFINED and clear any allocated storage
575 inline void reset();
576
577 //- Clear token and set to be ERROR.
578 inline void setBad();
579
580 //- Swap token contents: type, data, line-number
581 inline void swap(token& tok);
582
583
584 // Info
585
586 //- Return info proxy for printing token information to a stream
587 InfoProxy<token> info() const
588 {
589 return *this;
590 }
591
592
593 // Member Operators
594
595 // Assignment
596
597 //- Copy assign
598 inline void operator=(const token& tok);
599
600 //- Move assign
601 inline void operator=(token&& tok);
602
603 //- Copy assign from punctuation
604 inline void operator=(const punctuationToken p);
605
606 //- Copy assign from label
607 inline void operator=(const label val);
608
609 //- Copy assign from float
610 inline void operator=(const floatScalar val);
611
612 //- Copy assign from double
613 inline void operator=(const doubleScalar val);
614
615 //- Copy assign from word content
616 inline void operator=(const word& w);
617
618 //- Copy assign from string content
619 inline void operator=(const string& str);
620
621 //- Move assign from word content
622 inline void operator=(word&& w);
623
624 //- Move assign from string content
625 inline void operator=(string&& str);
626
627 //- Assign compound with reference counting to token
628 inline void operator=(token::compound* ptr);
629
630 //- Move assign from compound pointer
631 inline void operator=(autoPtr<token::compound>&& ptr);
632
633
634 // Equality
635
636 inline bool operator==(const token& tok) const;
637 inline bool operator==(const punctuationToken p) const noexcept;
638 inline bool operator==(const label val) const noexcept;
639 inline bool operator==(const floatScalar val) const noexcept;
640 inline bool operator==(const doubleScalar val) const noexcept;
641 inline bool operator==(const std::string& s) const;
642
643
644 // Inequality
645
646 inline bool operator!=(const token& tok) const;
647 inline bool operator!=(const punctuationToken p) const noexcept;
648 inline bool operator!=(const label val) const noexcept;
649 inline bool operator!=(const floatScalar val) const noexcept;
650 inline bool operator!=(const doubleScalar val) const noexcept;
651 inline bool operator!=(const std::string& s) const;
652
653
654 // IOstream Operators
656 friend Ostream& operator<<(Ostream& os, const token& tok);
659 friend ostream& operator<<(ostream& os, const punctuationToken& pt);
661 friend ostream& operator<<(ostream& os, const InfoProxy<token>& ct);
662
663
664 // Housekeeping
665
666 //- Write access for the token line number
667 // \deprecated(2021-03) - use lineNumber(label)
668 label& lineNumber() noexcept { return line_; }
669
670 //- Token is FLOAT
671 // \deprecated(2020-01) - isFloat()
672 bool isFloatScalar() const { return isFloat(); };
673
674 //- Token is DOUBLE
675 // \deprecated(2020-01) - isDouble()
676 bool isDoubleScalar() const { return isDouble(); }
677
678 //- Return float value.
679 // \deprecated(2020-01) - floatToken()
680 floatScalar floatScalarToken() const { return floatToken(); }
681
682 //- Return double value.
683 // \deprecated(2020-01) - doubleToken()
684 doubleScalar doubleScalarToken() const { return doubleToken(); }
685
686 //- Deprecated(2017-11) transfer word pointer to the token
687 // \deprecated(2017-11) - use move assign from word
688 void operator=(word*) = delete;
689
690 //- Deprecated(2017-11) transfer string pointer to the token
691 // \deprecated(2017-11) - use move assign from string
692 void operator=(string*) = delete;
693};
694
695// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
696
697// IOstream Operators
698
699Istream& operator>>(Istream& is, token& tok);
701ostream& operator<<(ostream& os, const token::punctuationToken& pt);
703
704ostream& operator<<(ostream& os, const InfoProxy<token>& ip);
705
706template<>
708
709
710// Handling of compound types
711
712//- Define compound using \a Type for its name
713#define defineCompoundTypeName(Type, UnusedTag) \
714 defineTemplateTypeNameAndDebugWithName(token::Compound<Type>, #Type, 0);
715
716//- Define compound using \a Name for its name
717#define defineNamedCompoundTypeName(Type, Name) \
718 defineTemplateTypeNameAndDebugWithName(token::Compound<Type>, #Name, 0);
719
720//- Add compound to selection table, lookup using typeName
721#define addCompoundToRunTimeSelectionTable(Type, Tag) \
722 token::compound::addIstreamConstructorToTable<token::Compound<Type>> \
723 add##Tag##IstreamConstructorToTable_;
724
725//- Add compound to selection table, lookup as \a Name
726#define addNamedCompoundToRunTimeSelectionTable(Type, Tag, Name) \
727 token::compound::addIstreamConstructorToTable<token::Compound<Type>> \
728 add##Tag##IstreamConstructorToTable_(#Name);
729
730
731// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
732
733} // End namespace Foam
734
735// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
736
737#include "tokenI.H"
738#include "Istream.H"
739
740// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
741
742#endif
743
744// ************************************************************************* //
A helper class for outputting values to Ostream.
Definition: InfoProxy.H:52
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
The TAB Method for Numerical Calculation of Spray Droplet Breakup.
Definition: TAB.H:69
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
Class to handle errors and exceptions in a simple, consistent stream-based manner.
Definition: error.H:77
Reference counter for various OpenFOAM components.
Definition: refCount.H:51
A templated class for holding compound tokens.
Definition: token.H:250
virtual label size() const
The size of the underlying content.
Definition: token.H:280
virtual void write(Ostream &os) const
Redirect write to underlying content.
Definition: token.H:286
Compound(Istream &is)
Read construct from Istream.
Definition: token.H:271
TypeName("Compound<T>")
Declare type-name, virtual type (with debug switch)
Compound(const T &val)
Copy construct.
Definition: token.H:259
Compound(T &&val)
Move construct.
Definition: token.H:265
Abstract base class for complex tokens.
Definition: token.H:171
void moved(bool b) noexcept
Set compound transferred status.
Definition: token.H:225
TypeName("compound")
Declare type-name, virtual type (with debug switch)
constexpr compound() noexcept
Default construct.
Definition: token.H:200
friend Ostream & operator<<(Ostream &os, const compound &ct)
Output operator.
bool moved() const noexcept
Get compound transferred status.
Definition: token.H:219
static autoPtr< compound > New(const word &type, Istream &is)
Construct compound from Istream.
Definition: token.C:56
virtual ~compound() noexcept=default
Destructor.
virtual label size() const =0
The size of the underlying content.
declareRunTimeSelectionTable(autoPtr, compound, Istream,(Istream &is),(is))
Declare run-time constructor selection table.
virtual void write(Ostream &os) const =0
Redirect write to underlying content.
A token holds an item read from Istream.
Definition: token.H:69
doubleScalar doubleScalarToken() const
Return double value.
Definition: token.H:683
bool isNumber() const noexcept
Token is LABEL, FLOAT or DOUBLE.
Definition: tokenI.H:587
compound & transferCompoundToken()
Return reference to compound and mark internally as released.
Definition: token.C:90
friend ostream & operator<<(ostream &os, const InfoProxy< token > &ct)
floatScalar floatToken() const
Return float value.
Definition: tokenI.H:531
friend Ostream & operator<<(Ostream &os, const punctuationToken &pt)
bool isDoubleScalar() const
Token is DOUBLE.
Definition: token.H:675
tokenType
Enumeration defining the types of token.
Definition: token.H:77
@ LABEL
label (integer) type
Definition: token.H:85
@ ERROR
Token error encountered.
Definition: token.H:79
@ DOUBLE
double (double-precision) type
Definition: token.H:87
@ VARIABLE
Definition: token.H:98
@ FLAG
stream flag (1-byte bitmask)
Definition: token.H:82
@ WORD
Foam::word.
Definition: token.H:90
@ EXPRESSION
Definition: token.H:96
@ UNDEFINED
An undefined token-type.
Definition: token.H:78
@ COMPOUND
Compound type such as List<label> etc.
Definition: token.H:92
@ FLOAT_SCALAR
Definition: token.H:104
@ FLOAT
float (single-precision) type
Definition: token.H:86
@ VERBATIM
Definition: token.H:100
@ DOUBLE_SCALAR
Definition: token.H:105
@ VERBATIMSTRING
Definition: token.H:106
@ DIRECTIVE
Definition: token.H:94
@ BOOL
boolean type
Definition: token.H:84
@ STRING
Foam::string (usually double-quoted)
Definition: token.H:91
@ PUNCTUATION
single character punctuation
Definition: token.H:83
label lineNumber() const noexcept
The line number for the token.
Definition: tokenI.H:391
bool isBool() const noexcept
Token is BOOL.
Definition: tokenI.H:423
bool isSeparator() const noexcept
Token is PUNCTUATION and isseparator.
Definition: tokenI.H:475
bool isPunctuation() const noexcept
Token is PUNCTUATION.
Definition: tokenI.H:459
friend ostream & operator<<(ostream &os, const punctuationToken &pt)
bool isExpression() const noexcept
Token is EXPRESSION (string variant)
Definition: tokenI.H:665
word name() const
Return the name of the token type.
Definition: tokenIO.C:134
punctuationToken
Standard punctuation tokens (a character)
Definition: token.H:121
@ LBRACE
Left brace [isseparator].
Definition: token.H:147
@ BEGIN_STRING
Begin string with double quote.
Definition: token.H:162
@ DIVIDE
Divide [isseparator].
Definition: token.H:141
@ BEGIN_BLOCK
Begin block [isseparator].
Definition: token.H:159
@ BEGIN_SQR
Begin dimensions [isseparator].
Definition: token.H:157
@ COLON
Colon [isseparator].
Definition: token.H:127
@ RPAREN
Right parenthesis [isseparator].
Definition: token.H:144
@ END_BLOCK
End block [isseparator].
Definition: token.H:160
@ HASH
Hash - directive or start verbatim string.
Definition: token.H:130
@ LPAREN
Left parenthesis [isseparator].
Definition: token.H:143
@ RSQUARE
Right square bracket [isseparator].
Definition: token.H:146
@ END_STRING
End string with double quote.
Definition: token.H:163
@ LSQUARE
Left square bracket [isseparator].
Definition: token.H:145
@ ASSIGN
Assignment/equals [isseparator].
Definition: token.H:137
@ SEMICOLON
Semicolon [isseparator].
Definition: token.H:128
@ END_STATEMENT
End entry [isseparator].
Definition: token.H:154
@ SQUOTE
Single quote.
Definition: token.H:134
@ NULL_TOKEN
Nul character.
Definition: token.H:122
@ BEGIN_LIST
Begin list [isseparator].
Definition: token.H:155
@ PLUS
Addition [isseparator].
Definition: token.H:138
@ DOLLAR
Dollar - start variable or expression.
Definition: token.H:131
@ DQUOTE
Double quote.
Definition: token.H:135
@ RBRACE
Right brace [isseparator].
Definition: token.H:148
@ SUBTRACT
Subtract or start of negative number.
Definition: token.H:153
@ END_LIST
End list [isseparator].
Definition: token.H:156
@ SPACE
Space [isspace].
Definition: token.H:125
@ ADD
Addition [isseparator].
Definition: token.H:152
@ QUESTION
Question mark (eg, ternary)
Definition: token.H:132
@ END_SQR
End dimensions [isseparator].
Definition: token.H:158
@ ATSYM
The 'at' symbol.
Definition: token.H:133
@ MULTIPLY
Multiply [isseparator].
Definition: token.H:140
@ NL
Newline [isspace].
Definition: token.H:124
@ MINUS
Subtract or start of negative number.
Definition: token.H:139
@ COMMA
Comma [isseparator].
Definition: token.H:129
bool isLabel() const noexcept
Token is LABEL.
Definition: tokenI.H:497
const string & stringToken() const
Return const reference to the string contents.
Definition: tokenI.H:689
bool operator!=(const token &tok) const
Definition: tokenI.H:978
punctuationToken pToken() const
Return punctuation character.
Definition: tokenI.H:485
bool operator==(const token &tok) const
Definition: tokenI.H:884
bool good() const noexcept
True if token is not UNDEFINED or ERROR.
Definition: tokenI.H:405
void setBad()
Clear token and set to be ERROR.
Definition: tokenI.H:734
label labelToken() const
Return label value.
Definition: tokenI.H:513
bool isDouble() const noexcept
Token is DOUBLE.
Definition: tokenI.H:543
static bool isseparator(int c) noexcept
True if the character is a punctuation separator (eg, in ISstream).
Definition: tokenI.H:53
bool isString() const noexcept
Token is string-variant (STRING, EXPRESSION, VARIABLE, VERBATIM)
Definition: tokenI.H:653
flagType
Stream or output control flags (1-byte width)
Definition: token.H:112
@ NO_FLAG
No flags.
Definition: token.H:113
@ BINARY
BINARY-mode stream.
Definition: token.H:115
@ ASCII
ASCII-mode stream.
Definition: token.H:114
InfoProxy< token > info() const
Return info proxy for printing token information to a stream.
Definition: token.H:586
void swap(token &tok)
Swap token contents: type, data, line-number.
Definition: tokenI.H:298
bool boolToken() const
Return boolean token value.
Definition: tokenI.H:429
bool isScalar() const noexcept
Token is FLOAT or DOUBLE.
Definition: tokenI.H:561
const compound & compoundToken() const
Read access for compound token.
Definition: tokenI.H:722
bool isDirective() const noexcept
Token is DIRECTIVE (word variant)
Definition: tokenI.H:625
bool isFloatScalar() const
Token is FLOAT.
Definition: token.H:671
static constexpr const char *const typeName
The type name is "token".
Definition: token.H:346
floatScalar floatScalarToken() const
Return float value.
Definition: token.H:679
bool isFlag() const noexcept
Token is FLAG.
Definition: tokenI.H:441
bool setType(const tokenType tokType) noexcept
Change the token type, for similar types.
Definition: tokenI.H:317
int flagToken() const
Return flag bitmask value.
Definition: tokenI.H:447
doubleScalar doubleToken() const
Return double value.
Definition: tokenI.H:549
friend Ostream & operator<<(Ostream &os, const token &tok)
bool undefined() const noexcept
Token is UNDEFINED.
Definition: tokenI.H:411
tokenType type() const noexcept
Return the token type.
Definition: tokenI.H:311
bool isQuotedString() const noexcept
Token is (quoted) STRING (string variant)
Definition: tokenI.H:647
bool isCompound() const noexcept
Token is COMPOUND.
Definition: tokenI.H:716
bool isFloat() const noexcept
Token is FLOAT.
Definition: tokenI.H:525
bool isStringType() const noexcept
Definition: tokenI.H:683
bool isVariable() const noexcept
Token is VARIABLE (string variant)
Definition: tokenI.H:671
void reset()
Reset token to UNDEFINED and clear any allocated storage.
Definition: tokenI.H:257
static const token undefinedToken
An undefined token.
Definition: token.H:294
const word & wordToken() const
Return const reference to the word contents.
Definition: tokenI.H:631
bool isWord() const noexcept
Token is word-variant (WORD, DIRECTIVE)
Definition: tokenI.H:609
scalar scalarToken() const
Return float or double value.
Definition: tokenI.H:571
bool isVerbatim() const noexcept
Token is VERBATIM string (string variant)
Definition: tokenI.H:677
static token flag(int bitmask) noexcept
Create a token with stream flags, no sanity check.
Definition: tokenI.H:43
void operator=(const token &tok)
Copy assign.
Definition: tokenI.H:743
scalar number() const
Return label, float or double value.
Definition: tokenI.H:593
A class for handling words, derived from Foam::string.
Definition: word.H:68
volScalarField & p
const volScalarField & T
OBJstream os(runTime.globalPath()/outputName)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Namespace for OpenFOAM.
double doubleScalar
A typedef for double.
Definition: scalarFwd.H:48
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Istream & operator>>(Istream &, directionInfo &)
float floatScalar
A typedef for float.
Definition: scalarFwd.H:45
const direction noexcept
Definition: Scalar.H:223
runTime write()
Macros to ease declaration of run-time selection tables.
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes)
volScalarField & b
Definition: createFields.H:27
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73