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-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::token
29 
30 Description
31  A token holds an item read from Istream.
32 
33 SourceFiles
34  tokenI.H
35  token.C
36  tokenIO.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef token_H
41 #define 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"
50 
51 #define NoHashTableC
52 #include "runTimeSelectionTables.H"
53 
54 #include <iostream>
55 
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 
58 namespace Foam
59 {
60 
61 // Forward Declarations
62 class token;
63 Ostream& operator<<(Ostream& os, const token& tok);
64 
65 
66 /*---------------------------------------------------------------------------*\
67  Class token Declaration
68 \*---------------------------------------------------------------------------*/
69 
70 class token
71 {
72 public:
73 
74  //- Enumeration defining the types of token.
75  // Since these values are also used to tag content in Pstream,
76  // the maximum number of types is limited to 30.
77  enum tokenType
78  {
79  UNDEFINED = 0,
80 
81  // Fundamental types
82  FLAG,
84  BOOL,
87  DOUBLE,
88 
89  // Pointer types
90  WORD,
95  COMPOUND,
96 
97  ERROR,
98 
99  // Aliases
103  };
104 
105 
106  //- Stream or output control flags (1-byte width)
107  enum flagType
108  {
109  NO_FLAG = 0,
110  ASCII = 1,
111  BINARY = 2
112  };
113 
114 
115  //- Standard punctuation tokens (a character)
116  enum punctuationToken : char
117  {
118  NULL_TOKEN = '\0',
119  SPACE = ' ',
120  TAB = '\t',
121  NL = '\n',
122 
124  BEGIN_LIST = '(',
125  END_LIST = ')',
126  BEGIN_SQR = '[',
127  END_SQR = ']',
128  BEGIN_BLOCK = '{',
129  END_BLOCK = '}',
130  COLON = ':',
131  COMMA = ',',
132  HASH = '#',
133  DOLLAR = '$',
134  ATSYM = '@',
135  SQUOTE = '\'',
136  DQUOTE = '"',
137 
138  ASSIGN = '=',
139  ADD = '+',
140  SUBTRACT = '-',
141  MULTIPLY = '*',
142  DIVIDE = '/',
143 
145  END_STRING = DQUOTE
146  };
147 
148 
149  //- Abstract base class for complex tokens
150  class compound
151  :
152  public refCount
153  {
154  bool empty_;
155 
156  //- No copy construct
157  compound(const compound&) = delete;
158 
159  //- No copy assignment
160  compound& operator=(const compound&) = delete;
161 
162  public:
163 
164  //- Declare type-name, virtual type (with debug switch)
165  TypeName("compound");
166 
167  //- Declare run-time constructor selection table
169  (
170  autoPtr,
171  compound,
172  Istream,
173  (Istream& is),
174  (is)
175  );
176 
177 
178  // Constructors
179 
180  //- Default construct
181  compound()
182  :
183  empty_(false)
184  {}
185 
186 
187  // Selectors
188 
189  //- Select null constructed
190  static autoPtr<compound> New(const word& type, Istream& is);
191 
192  //- Return true if name is a known (registered) compound type
193  static bool isCompound(const word& name);
194 
195 
196  //- Destructor
197  virtual ~compound() = default;
198 
199 
200  // Member Functions
201 
202  bool empty() const
203  {
204  return empty_;
205  }
206 
207  bool& empty()
208  {
209  return empty_;
210  }
211 
212  virtual label size() const = 0;
213 
214  virtual void write(Ostream& os) const = 0;
215 
216 
217  // Operators
218 
219  //- Output operator
220  friend Ostream& operator<<(Ostream& os, const compound& ct);
221  };
222 
223 
224  //- A templated class for holding compound tokens
225  template<class T>
226  class Compound
227  :
228  public token::compound,
229  public T
230  {
231  public:
232 
233  //- Declare type-name, virtual type (with debug switch)
234  TypeName("Compound<T>");
235 
236  Compound(Istream& is)
237  :
238  T(is)
239  {}
240 
241  label size() const
242  {
243  return T::size();
244  }
245 
246  void write(Ostream& os) const
247  {
248  operator<<(os, static_cast<const T&>(*this));
249  }
250  };
251 
252 
253  //- An undefined token
254  static const token undefinedToken;
255 
256 
257 private:
258 
259  //- A %union of token types
260  union content
261  {
262  // Fundamental values. Largest first for any {} initialization.
263  int64_t int64Val;
264  int32_t int32Val;
265 
266  int flagVal; // bitmask - stored as int, not enum
267  punctuationToken punctuationVal;
268  label labelVal;
269  floatScalar floatVal;
270  doubleScalar doubleVal;
271 
272  // Pointers
273  word* wordPtr;
274  string* stringPtr;
275  mutable compound* compoundPtr;
276  };
277 
278 
279  // Private Data
280 
281  //- The data content (as a union).
282  // For memory alignment this should appear as the first member.
283  content data_;
284 
285  //- The token type
286  tokenType type_;
287 
288  //- Line number in the file the token was read from
289  label lineNumber_;
290 
291 
292  // Private Member Functions
293 
294  //- Set as UNDEFINED and zero the union content without any checking
295  inline void setUndefined();
296 
297  // Parse error, expected 'expected', found ...
298  void parseError(const char* expected) const;
299 
300 
301 public:
302 
303  // Static Data Members
304 
305  //- The type name is "token"
306  static constexpr const char* const typeName = "token";
307 
308 
309  // Constructors
310 
311  //- Default construct, initialized to an UNDEFINED token.
312  inline constexpr token() noexcept;
313 
314  //- Copy construct
315  inline token(const token& t);
316 
317  //- Move construct. The original token is left as UNDEFINED.
318  inline token(token&& t);
319 
320  //- Construct punctuation character token
321  inline explicit token(punctuationToken p, label lineNumber=0);
322 
323  //- Construct label token
324  inline explicit token(const label val, label lineNumber=0);
325 
326  //- Construct float token
327  inline explicit token(const floatScalar val, label lineNumber=0);
328 
329  //- Construct double token
330  inline explicit token(const doubleScalar val, label lineNumber=0);
331 
332  //- Copy construct word token
333  inline explicit token(const word& w, label lineNumber=0);
334 
335  //- Copy construct string token
336  inline explicit token(const string& str, label lineNumber=0);
337 
338  //- Move construct word token
339  inline explicit token(word&& w, label lineNumber=0);
340 
341  //- Move construct string token
342  inline explicit token(string&& str, label lineNumber=0);
343 
344  //- Construct from Istream
345  explicit token(Istream& is);
346 
347 
348  //- Destructor
349  inline ~token();
350 
351 
352  // Static Functions
353 
354  //- Create a bool token.
355  inline static token boolean(bool on);
356 
357  //- Create a token with stream flags, no sanity check
358  //
359  // \param bitmask the flags to set
360  inline static token flag(int bitmask);
361 
362  //- True if the character is a punctuation separator (eg, in ISstream).
363  // Since it could also start a number, SUBTRACT is not included as
364  // a separator.
365  //
366  // \param c the character to test, passed as int for consistency with
367  // isdigit, isspace etc.
368  inline static bool isseparator(int c);
369 
370 
371  // Member Functions
372 
373  // Status
374 
375  //- Return the name of the token type
376  word name() const;
377 
378  //- Return the token type
379  inline tokenType type() const;
380 
381  //- Change the token type, for similar types.
382  // This can be used to change between string-like variants
383  // (eg, STRING, VARIABLE, etc)
384  // To change types entirely (eg, STRING to DOUBLE),
385  // use the corresponding assignment operator.
386  //
387  // \return true if the change was successful or no change was required
388  inline bool setType(const tokenType tokType);
389 
390  //- The line number for the token
391  inline label lineNumber() const;
392 
393  //- The line number for the token
394  inline label& lineNumber();
395 
396  //- True if token is not UNDEFINED or ERROR
397  inline bool good() const;
398 
399  //- Token is UNDEFINED
400  inline bool undefined() const;
401 
402  //- Token is ERROR
403  inline bool error() const;
404 
405  //- Token is BOOL
406  inline bool isBool() const;
407 
408  //- Token is FLAG
409  inline bool isFlag() const;
410 
411  //- Token is PUNCTUATION
412  inline bool isPunctuation() const;
413 
414  //- Token is PUNCTUATION and isseparator
415  inline bool isSeparator() const;
416 
417  //- Token is LABEL
418  inline bool isLabel() const;
419 
420  //- Token is FLOAT
421  inline bool isFloat() const;
422 
423  //- Token is DOUBLE
424  inline bool isDouble() const;
425 
426  //- Token is FLOAT or DOUBLE
427  inline bool isScalar() const;
428 
429  //- Token is LABEL, FLOAT or DOUBLE
430  inline bool isNumber() const;
431 
432  //- Token is WORD or DIRECTIVE word
433  inline bool isWord() const;
434 
435  //- Token is DIRECTIVE (word variant)
436  inline bool isDirective() const;
437 
438  //- Token is STRING, VARIABLE or VERBATIM string
439  inline bool isString() const;
440 
441  //- Token is VARIABLE (string variant)
442  inline bool isVariable() const;
443 
444  //- Token is VERBATIM string (string variant)
445  inline bool isVerbatim() const;
446 
447  //- Token is WORD, DIRECTIVE, STRING, VARIABLE or VERBATIM
448  inline bool isStringType() const;
449 
450  //- Token is COMPOUND
451  inline bool isCompound() const;
452 
453 
454  // Access
455 
456  //- Return boolean token value.
457  // Report FatalIOError and return false if token is not BOOL or LABEL
458  inline bool boolToken() const;
459 
460  //- Return flag bitmask value.
461  // Report FatalIOError and return NO_FLAG if token is not FLAG
462  inline int flagToken() const;
463 
464  //- Return punctuation character.
465  // Report FatalIOError and return \b \\0 if token is not PUNCTUATION
466  inline punctuationToken pToken() const;
467 
468  //- Return label value.
469  // Report FatalIOError and return \b 0 if token is not LABEL
470  inline label labelToken() const;
471 
472  //- Return float value.
473  // Report FatalIOError and return \b 0 if token is not FLOAT
474  inline floatScalar floatToken() const;
475 
476  //- Return double value.
477  // Report FatalIOError and return \b 0 if token is not DOUBLE
478  inline doubleScalar doubleToken() const;
479 
480  //- Return float or double value.
481  // Report FatalIOError and return \b 0 if token is not a
482  // FLOAT or DOUBLE
483  inline scalar scalarToken() const;
484 
485  //- Return label, float or double value.
486  // Report FatalIOError and return \b 0 if token is not a
487  // LABEL, FLOAT or DOUBLE
488  inline scalar number() const;
489 
490  //- Return const reference to the word contents.
491  // Report FatalIOError and return \b "" if token is not a
492  // WORD or DIRECTIVE
493  inline const word& wordToken() const;
494 
495  //- Return const reference to the string contents.
496  // Report FatalIOError and return \b "" if token is not a
497  // STRING, VARIABLE, VERBATIM or an upcast WORD or DIRECTIVE
498  inline const string& stringToken() const;
499 
500  //- Read access for compound token
501  inline const compound& compoundToken() const;
502 
503  //- Return reference to compound token and decrease its internal
504  //- refCount accordingly.
505  // The Istream is used for reference error messages only.
507 
508 
509  // Edit
510 
511  //- Reset token to UNDEFINED and clear any allocated storage
512  inline void reset();
513 
514  //- Clear token and set to be ERROR.
515  inline void setBad();
516 
517  //- Swap token contents: type, data, line-number
518  inline void swap(token& tok);
519 
520 
521  // Info
522 
523  //- Return info proxy for printing token information to a stream
524  InfoProxy<token> info() const
525  {
526  return *this;
527  }
528 
529 
530  // Member Operators
531 
532  // Assignment
533 
534  //- Copy assign
535  inline void operator=(const token& tok);
536 
537  //- Move assign
538  inline void operator=(token&& tok);
539 
540  //- Copy assign from punctuation
541  inline void operator=(const punctuationToken p);
542 
543  //- Copy assign from label
544  inline void operator=(const label val);
545 
546  //- Copy assign from float
547  inline void operator=(const floatScalar val);
548 
549  //- Copy assign from double
550  inline void operator=(const doubleScalar val);
551 
552  //- Copy assign from word
553  inline void operator=(const word& w);
554 
555  //- Copy assign from string
556  inline void operator=(const string& str);
557 
558  //- Move assign from word
559  inline void operator=(word&& w);
560 
561  //- Move assign from string
562  inline void operator=(string&& str);
563 
564  //- Assign compound with reference counting to token
565  inline void operator=(compound* compoundPtr);
566 
567 
568  // Equality
569 
570  inline bool operator==(const token& tok) const;
571  inline bool operator==(const punctuationToken p) const;
572  inline bool operator==(const label val) const;
573  inline bool operator==(const floatScalar val) const;
574  inline bool operator==(const doubleScalar val) const;
575  inline bool operator==(const std::string& s) const;
576 
577 
578  // Inequality
579 
580  inline bool operator!=(const token& tok) const;
581  inline bool operator!=(const punctuationToken p) const;
582  inline bool operator!=(const label val) const;
583  inline bool operator!=(const floatScalar val) const;
584  inline bool operator!=(const doubleScalar val) const;
585  inline bool operator!=(const std::string& s) const;
586 
587 
588  // IOstream Operators
589 
590  friend Ostream& operator<<(Ostream& os, const token& tok);
591 
592  friend Ostream& operator<<(Ostream& os, const punctuationToken& pt);
593  friend ostream& operator<<(ostream& os, const punctuationToken& pt);
594 
595  friend ostream& operator<<(ostream& os, const InfoProxy<token>& ct);
596 
597 
598  // Housekeeping
599 
600  //- Token is FLOAT
601  // \deprecated(2020-01) - isFloat()
602  bool isFloatScalar() const { return isFloat(); };
603 
604  //- Token is DOUBLE
605  // \deprecated(2020-01) - isDouble()
606  bool isDoubleScalar() const { return isDouble(); }
607 
608  //- Return float value.
609  // \deprecated(2020-01) - floatToken()
610  floatScalar floatScalarToken() const { return floatToken(); }
611 
612  //- Return double value.
613  // \deprecated(2020-01) - doubleToken()
614  doubleScalar doubleScalarToken() const { return doubleToken(); }
615 
616  //- Deprecated(2017-11) transfer word pointer to the token
617  // \deprecated(2017-11) - use move assign from word
618  void operator=(word*) = delete;
619 
620  //- Deprecated(2017-11) transfer string pointer to the token
621  // \deprecated(2017-11) - use move assign from string
622  void operator=(string*) = delete;
623 };
624 
625 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
626 
627 // IOstream Operators
628 
629 Istream& operator>>(Istream& is, token& tok);
630 Ostream& operator<<(Ostream& os, const token::punctuationToken& pt);
631 ostream& operator<<(ostream& os, const token::punctuationToken& pt);
632 Ostream& operator<<(Ostream& os, const token::compound& ct);
633 
634 ostream& operator<<(ostream& os, const InfoProxy<token>& ip);
635 
636 template<>
637 Ostream& operator<<(Ostream& os, const InfoProxy<token>& ip);
638 
639 
640 // Handling of compound types
641 
642 #define defineCompoundTypeName(Type, Name) \
643  defineTemplateTypeNameAndDebugWithName(token::Compound<Type>, #Type, 0);
644 
645 #define addCompoundToRunTimeSelectionTable(Type, Name) \
646  token::compound::addIstreamConstructorToTable<token::Compound<Type>> \
647  add##Name##IstreamConstructorToTable_;
648 
649 
650 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
651 
652 } // End namespace Foam
653 
654 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
655 
656 #include "tokenI.H"
657 #include "Istream.H"
658 
659 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
660 
661 #endif
662 
663 // ************************************************************************* //
Foam::token::SUBTRACT
Subtract or start of negative number.
Definition: token.H:139
Foam::token::isDoubleScalar
bool isDoubleScalar() const
Token is DOUBLE.
Definition: token.H:605
Foam::token::flag
static token flag(int bitmask)
Create a token with stream flags, no sanity check.
Definition: tokenI.H:43
Foam::token::ASSIGN
Assignment/equals [isseparator].
Definition: token.H:137
Foam::token::isFlag
bool isFlag() const
Token is FLAG.
Definition: tokenI.H:425
Foam::token::Compound::Compound
Compound(Istream &is)
Definition: token.H:235
Foam::token::flagType
flagType
Stream or output control flags (1-byte width)
Definition: token.H:106
Foam::token::labelToken
label labelToken() const
Return label value.
Definition: tokenI.H:477
Foam::doubleScalar
double doubleScalar
A typedef for double.
Definition: scalarFwd.H:48
Foam::token::COMMA
Comma [isseparator].
Definition: token.H:130
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::token::isScalar
bool isScalar() const
Token is FLOAT or DOUBLE.
Definition: tokenI.H:525
Foam::token::compound
Abstract base class for complex tokens.
Definition: token.H:149
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::token::Compound
A templated class for holding compound tokens.
Definition: token.H:225
Foam::InfoProxy
A helper class for outputting values to Ostream.
Definition: InfoProxy.H:47
Foam::token::SQUOTE
Single quote.
Definition: token.H:134
Foam::token::Compound::size
label size() const
Definition: token.H:240
s
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))
Definition: gmvOutputSpray.H:25
typeInfo.H
Foam::token::isNumber
bool isNumber() const
Token is LABEL, FLOAT or DOUBLE.
Definition: tokenI.H:551
Foam::refCount
Reference counter for various OpenFOAM components.
Definition: refCount.H:50
Foam::token::stringToken
const string & stringToken() const
Return const reference to the string contents.
Definition: tokenI.H:634
Foam::token::LABEL
label (integer) type
Definition: token.H:84
InfoProxy.H
Foam::token::isFloatScalar
bool isFloatScalar() const
Token is FLOAT.
Definition: token.H:601
Foam::floatScalar
float floatScalar
A typedef for float.
Definition: scalarFwd.H:45
Foam::token::isString
bool isString() const
Token is STRING, VARIABLE or VERBATIM string.
Definition: tokenI.H:605
Foam::token::END_STRING
End string with double quote.
Definition: token.H:144
Foam::token::boolToken
bool boolToken() const
Return boolean token value.
Definition: tokenI.H:413
Foam::token::isDirective
bool isDirective() const
Token is DIRECTIVE (word variant)
Definition: tokenI.H:583
Foam::token::DIRECTIVE
A dictionary #directive (word variant)
Definition: token.H:91
Foam::token::PUNCTUATION
single character punctuation
Definition: token.H:82
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:230
Foam::token
A token holds an item read from Istream.
Definition: token.H:69
Foam::token::compound::write
virtual void write(Ostream &os) const =0
Foam::token::compoundToken
const compound & compoundToken() const
Read access for compound token.
Definition: tokenI.H:666
Foam::token::isSeparator
bool isSeparator() const
Token is PUNCTUATION and isseparator.
Definition: tokenI.H:461
Foam::token::ERROR
A token error encountered.
Definition: token.H:96
Foam::token::good
bool good() const
True if token is not UNDEFINED or ERROR.
Definition: tokenI.H:389
Foam::token::compound::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, compound, Istream,(Istream &is),(is))
Declare run-time constructor selection table.
Foam::token::isCompound
bool isCompound() const
Token is COMPOUND.
Definition: tokenI.H:660
Foam::token::VERBATIM
Verbatim string content.
Definition: token.H:93
Foam::token::compound::TypeName
TypeName("compound")
Declare type-name, virtual type (with debug switch)
Foam::token::pToken
punctuationToken pToken() const
Return punctuation character.
Definition: tokenI.H:449
Foam::token::compound::empty
bool empty() const
Definition: token.H:201
Foam::token::isseparator
static bool isseparator(int c)
True if the character is a punctuation separator (eg, in ISstream).
Definition: tokenI.H:53
Foam::token::isLabel
bool isLabel() const
Token is LABEL.
Definition: tokenI.H:471
Foam::token::DIVIDE
Divide [isseparator].
Definition: token.H:141
Foam::token::FLOAT_SCALAR
Definition: token.H:99
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::token::DQUOTE
Double quote.
Definition: token.H:135
Foam::token::number
scalar number() const
Return label, float or double value.
Definition: tokenI.H:557
Foam::token::BINARY
BINARY-mode stream.
Definition: token.H:110
Foam::token::info
InfoProxy< token > info() const
Return info proxy for printing token information to a stream.
Definition: token.H:523
Foam::token::BEGIN_SQR
Begin dimensions [isseparator].
Definition: token.H:125
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::token::ATSYM
At.
Definition: token.H:133
Foam::token::NO_FLAG
No flags.
Definition: token.H:108
Foam::token::VARIABLE
A dictionary $variable (string variant)
Definition: token.H:92
Foam::token::operator!=
bool operator!=(const token &tok) const
Definition: tokenI.H:916
Foam::token::ASCII
ASCII-mode stream.
Definition: token.H:109
Foam::token::compound::empty
bool & empty()
Definition: token.H:206
Foam::token::reset
void reset()
Reset token to UNDEFINED and clear any allocated storage.
Definition: tokenI.H:246
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:58
Foam::token::isVariable
bool isVariable() const
Token is VARIABLE (string variant)
Definition: tokenI.H:616
tokenI.H
Foam::token::floatScalarToken
floatScalar floatScalarToken() const
Return float value.
Definition: token.H:609
Foam::token::BOOL
boolean type
Definition: token.H:83
Foam::token::compound::~compound
virtual ~compound()=default
Destructor.
Foam::token::operator<<
friend Ostream & operator<<(Ostream &os, const token &tok)
Foam::token::transferCompoundToken
compound & transferCompoundToken(const Istream &is)
Definition: token.C:90
Foam::token::END_STATEMENT
End entry [isseparator].
Definition: token.H:122
Foam::token::compound::isCompound
static bool isCompound(const word &name)
Return true if name is a known (registered) compound type.
Definition: token.C:80
Istream.H
Foam::token::Compound::write
void write(Ostream &os) const
Definition: token.H:245
Foam::token::NULL_TOKEN
Nul character.
Definition: token.H:117
Foam::token::END_BLOCK
End block [isseparator].
Definition: token.H:128
Foam::token::undefinedToken
static const token undefinedToken
An undefined token.
Definition: token.H:253
Foam::token::tokenType
tokenType
Enumeration defining the types of token.
Definition: token.H:76
Foam::token::DOLLAR
Dollar - start variable.
Definition: token.H:132
Foam::token::COMPOUND
Compound type such as List<label> etc.
Definition: token.H:94
Foam::token::NL
Newline [isspace].
Definition: token.H:120
Foam::token::isWord
bool isWord() const
Token is WORD or DIRECTIVE word.
Definition: tokenI.H:573
scalar.H
Foam::token::END_SQR
End dimensions [isseparator].
Definition: token.H:126
Foam::token::STRING
A string.
Definition: token.H:90
Foam::token::isDouble
bool isDouble() const
Token is DOUBLE.
Definition: tokenI.H:507
Foam::token::HASH
Hash - directive or verbatim string.
Definition: token.H:131
Foam::token::MULTIPLY
Multiply [isseparator].
Definition: token.H:140
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::token::operator==
bool operator==(const token &tok) const
Definition: tokenI.H:819
Foam::token::floatToken
floatScalar floatToken() const
Return float value.
Definition: tokenI.H:495
Foam::token::BEGIN_BLOCK
Begin block [isseparator].
Definition: token.H:127
Foam::token::doubleToken
doubleScalar doubleToken() const
Return double value.
Definition: tokenI.H:513
Foam::token::wordToken
const word & wordToken() const
Return const reference to the word contents.
Definition: tokenI.H:589
Foam::token::compound::size
virtual label size() const =0
Foam::token::typeName
static constexpr const char *const typeName
The type name is "token".
Definition: token.H:305
Foam::token::compound::operator<<
friend Ostream & operator<<(Ostream &os, const compound &ct)
Output operator.
Foam::token::swap
void swap(token &tok)
Swap token contents: type, data, line-number.
Definition: tokenI.H:286
Foam::token::Compound::TypeName
TypeName("Compound<T>")
Declare type-name, virtual type (with debug switch)
Foam::token::FLAG
stream flag (1-byte bitmask)
Definition: token.H:81
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::token::FLOAT
float (single-precision) type
Definition: token.H:85
Foam::token::type
tokenType type() const
Return the token type.
Definition: tokenI.H:299
Foam::token::isBool
bool isBool() const
Token is BOOL.
Definition: tokenI.H:407
Foam::token::COLON
Colon [isseparator].
Definition: token.H:129
Foam::token::scalarToken
scalar scalarToken() const
Return float or double value.
Definition: tokenI.H:535
Foam::token::setType
bool setType(const tokenType tokType)
Change the token type, for similar types.
Definition: tokenI.H:305
Foam::token::name
word name() const
Return the name of the token type.
Definition: tokenIO.C:130
runTimeSelectionTables.H
Macros to ease declaration of run-time selection tables.
label.H
Foam::token::isVerbatim
bool isVerbatim() const
Token is VERBATIM string (string variant)
Definition: tokenI.H:622
Foam::token::SPACE
Space [isspace].
Definition: token.H:118
Foam::token::WORD
A Foam::word.
Definition: token.H:89
Foam::token::doubleScalarToken
doubleScalar doubleScalarToken() const
Return double value.
Definition: token.H:613
Foam::token::isFloat
bool isFloat() const
Token is FLOAT.
Definition: tokenI.H:489
Foam::token::DOUBLE_SCALAR
Definition: token.H:100
Foam::token::compound::compound
compound()
Default construct.
Definition: token.H:180
Foam::token::END_LIST
End list [isseparator].
Definition: token.H:124
Foam::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.
Foam::token::token
constexpr token() noexcept
Default construct, initialized to an UNDEFINED token.
Definition: tokenI.H:97
Foam::token::undefined
bool undefined() const
Token is UNDEFINED.
Definition: tokenI.H:395
Foam::token::flagToken
int flagToken() const
Return flag bitmask value.
Definition: tokenI.H:431
Foam::token::compound::New
static autoPtr< compound > New(const word &type, Istream &is)
Select null constructed.
Definition: token.C:56
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
word.H
Foam::token::lineNumber
label lineNumber() const
The line number for the token.
Definition: tokenI.H:377
uLabel.H
Foam::TAB
The TAB Method for Numerical Calculation of Spray Droplet Breakup.
Definition: TAB.H:66
Foam::token::isPunctuation
bool isPunctuation() const
Token is PUNCTUATION.
Definition: tokenI.H:443
Foam::token::UNDEFINED
An undefined token-type.
Definition: token.H:78
Foam::token::BEGIN_LIST
Begin list [isseparator].
Definition: token.H:123
refCount.H
Foam::error
Class to handle errors and exceptions in a simple, consistent stream-based manner.
Definition: error.H:64
Foam::token::DOUBLE
double (double-precision) type
Definition: token.H:86
Foam::token::VERBATIMSTRING
Definition: token.H:101
Foam::token::isStringType
bool isStringType() const
Token is WORD, DIRECTIVE, STRING, VARIABLE or VERBATIM.
Definition: tokenI.H:628
Foam::token::BEGIN_STRING
Begin string with double quote.
Definition: token.H:143
Foam::token::punctuationToken
punctuationToken
Standard punctuation tokens (a character)
Definition: token.H:115
Foam::token::operator=
void operator=(const token &tok)
Copy assign.
Definition: tokenI.H:687
Foam::token::ADD
Addition [isseparator].
Definition: token.H:138
Foam::token::setBad
void setBad()
Clear token and set to be ERROR.
Definition: tokenI.H:678