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 -------------------------------------------------------------------------------
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  Class token Declaration
67 \*---------------------------------------------------------------------------*/
68 
69 class token
70 {
71 public:
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
83  FLAG,
85  BOOL,
88  DOUBLE,
89 
90  // Pointer types
91  WORD,
93  COMPOUND,
94 
95  DIRECTIVE,
102 
104  // Aliases
108  };
109 
110 
111  //- Stream or output control flags (1-byte width)
112  enum flagType
113  {
114  NO_FLAG = 0,
115  ASCII = 1,
116  BINARY = 2
117  };
118 
119 
120  //- Standard punctuation tokens (a character)
121  enum punctuationToken : char
122  {
123  NULL_TOKEN = '\0',
124  TAB = '\t',
125  NL = '\n',
126  SPACE = ' ',
127 
128  COLON = ':',
129  SEMICOLON = ';',
130  COMMA = ',',
131  HASH = '#',
132  DOLLAR = '$',
133  QUESTION = '?',
134  ATSYM = '@',
135  SQUOTE = '\'',
136  DQUOTE = '"',
137 
138  ASSIGN = '=',
139  PLUS = '+',
140  MINUS = '-',
141  MULTIPLY = '*',
142  DIVIDE = '/',
143 
144  LPAREN = '(',
145  RPAREN = ')',
146  LSQUARE = '[',
147  RSQUARE = ']',
148  LBRACE = '{',
149  RBRACE = '}',
150 
151  // With semantically meaning
152 
153  ADD = PLUS,
161  END_BLOCK = RBRACE,
162 
164  END_STRING = DQUOTE
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 
298 private:
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 
342 public:
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
655 
656  friend Ostream& operator<<(Ostream& os, const token& tok);
657 
658  friend Ostream& operator<<(Ostream& os, const punctuationToken& pt);
659  friend ostream& operator<<(ostream& os, const punctuationToken& pt);
660 
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 
699 Istream& operator>>(Istream& is, token& tok);
700 Ostream& operator<<(Ostream& os, const token::punctuationToken& pt);
701 ostream& operator<<(ostream& os, const token::punctuationToken& pt);
702 Ostream& operator<<(Ostream& os, const token::compound& ct);
703 
704 ostream& operator<<(ostream& os, const InfoProxy<token>& ip);
705 
706 template<>
707 Ostream& operator<<(Ostream& os, const InfoProxy<token>& ip);
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 // ************************************************************************* //
Foam::token::SUBTRACT
Subtract or start of negative number.
Definition: token.H:153
Foam::token::RSQUARE
Right square bracket [isseparator].
Definition: token.H:146
Foam::token::isDoubleScalar
bool isDoubleScalar() const
Token is DOUBLE.
Definition: token.H:675
Foam::token::ASSIGN
Assignment/equals [isseparator].
Definition: token.H:137
Foam::token::Compound::Compound
Compound(Istream &is)
Read construct from Istream.
Definition: token.H:271
Foam::token::flagType
flagType
Stream or output control flags (1-byte width)
Definition: token.H:111
Foam::token::labelToken
label labelToken() const
Return label value.
Definition: tokenI.H:513
Foam::doubleScalar
double doubleScalar
A typedef for double.
Definition: scalarFwd.H:48
Foam::token::COMMA
Comma [isseparator].
Definition: token.H:129
Foam::token::LBRACE
Left brace [isseparator].
Definition: token.H:147
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::token::DOUBLE
double (double-precision) type
Definition: token.H:87
Foam::token::isLabel
bool isLabel() const noexcept
Token is LABEL.
Definition: tokenI.H:497
Foam::token::compound
Abstract base class for complex tokens.
Definition: token.H:168
Foam::token::COMPOUND
Compound type such as List<label> etc.
Definition: token.H:92
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::token::Compound
A templated class for holding compound tokens.
Definition: token.H:246
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::isBool
bool isBool() const noexcept
Token is BOOL.
Definition: tokenI.H:423
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
Foam::token::isDouble
bool isDouble() const noexcept
Token is DOUBLE.
Definition: tokenI.H:543
typeInfo.H
Foam::refCount
Reference counter for various OpenFOAM components.
Definition: refCount.H:50
Foam::token::lineNumber
label lineNumber() const noexcept
The line number for the token.
Definition: tokenI.H:391
Foam::token::LABEL
label (integer) type
Definition: token.H:85
Foam::token::RPAREN
Right parenthesis [isseparator].
Definition: token.H:144
Foam::token::Compound::write
virtual void write(Ostream &os) const
Redirect write to underlying content.
Definition: token.H:286
Foam::token::SEMICOLON
Semicolon [isseparator].
Definition: token.H:128
Foam::token::stringToken
const string & stringToken() const
Return const reference to the string contents.
Definition: tokenI.H:689
InfoProxy.H
Foam::token::DOUBLE_SCALAR
Definition: token.H:105
Foam::token::compound::~compound
virtual ~compound() noexcept=default
Destructor.
Foam::token::isFloatScalar
bool isFloatScalar() const
Token is FLOAT.
Definition: token.H:671
Foam::token::PLUS
Addition [isseparator].
Definition: token.H:138
Foam::floatScalar
float floatScalar
A typedef for float.
Definition: scalarFwd.H:45
Foam::token::isStringType
bool isStringType() const noexcept
Definition: tokenI.H:683
Foam::token::FLOAT_SCALAR
Definition: token.H:104
Foam::token::isExpression
bool isExpression() const noexcept
Token is EXPRESSION (string variant)
Definition: tokenI.H:665
Foam::token::END_STRING
End string with double quote.
Definition: token.H:163
Foam::token::boolToken
bool boolToken() const
Return boolean token value.
Definition: tokenI.H:429
Foam::token::isseparator
static bool isseparator(int c) noexcept
True if the character is a punctuation separator (eg, in ISstream).
Definition: tokenI.H:53
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:230
Foam::token
A token holds an item read from Istream.
Definition: token.H:68
Foam::token::compound::write
virtual void write(Ostream &os) const =0
Redirect write to underlying content.
Foam::token::isFloat
bool isFloat() const noexcept
Token is FLOAT.
Definition: tokenI.H:525
Foam::token::isQuotedString
bool isQuotedString() const noexcept
Token is (quoted) STRING (string variant)
Definition: tokenI.H:647
Foam::token::compoundToken
const compound & compoundToken() const
Read access for compound token.
Definition: tokenI.H:722
Foam::token::compound::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, compound, Istream,(Istream &is),(is))
Declare run-time constructor selection table.
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:485
Foam::token::isVariable
bool isVariable() const noexcept
Token is VARIABLE (string variant)
Definition: tokenI.H:671
Foam::token::isWord
bool isWord() const noexcept
Token is word-variant (WORD, DIRECTIVE)
Definition: tokenI.H:609
Foam::token::STRING
Foam::string (usually double-quoted)
Definition: token.H:91
Foam::token::DIRECTIVE
Definition: token.H:94
Foam::token::DIVIDE
Divide [isseparator].
Definition: token.H:141
Foam::token::isNumber
bool isNumber() const noexcept
Token is LABEL, FLOAT or DOUBLE.
Definition: tokenI.H:587
Foam::token::MINUS
Subtract or start of negative number.
Definition: token.H:139
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::token::EXPRESSION
Definition: token.H:96
Foam::token::ERROR
Token error encountered.
Definition: token.H:79
Foam::token::DQUOTE
Double quote.
Definition: token.H:135
Foam::token::number
scalar number() const
Return label, float or double value.
Definition: tokenI.H:593
Foam::token::RBRACE
Right brace [isseparator].
Definition: token.H:148
Foam::token::BINARY
BINARY-mode stream.
Definition: token.H:115
Foam::constant::physicoChemical::b
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
Foam::token::info
InfoProxy< token > info() const
Return info proxy for printing token information to a stream.
Definition: token.H:586
Foam::token::PUNCTUATION
single character punctuation
Definition: token.H:83
Foam::token::BEGIN_SQR
Begin dimensions [isseparator].
Definition: token.H:157
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
The 'at' symbol.
Definition: token.H:133
Foam::token::NO_FLAG
No flags.
Definition: token.H:113
Foam::token::operator!=
bool operator!=(const token &tok) const
Definition: tokenI.H:978
Foam::token::ASCII
ASCII-mode stream.
Definition: token.H:114
Foam::token::Compound::size
virtual label size() const
The size of the underlying content.
Definition: token.H:280
Foam::token::reset
void reset()
Reset token to UNDEFINED and clear any allocated storage.
Definition: tokenI.H:257
Foam::token::Compound::Compound
Compound(T &&val)
Move construct.
Definition: token.H:265
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:58
tokenI.H
Foam::token::floatScalarToken
floatScalar floatScalarToken() const
Return float value.
Definition: token.H:679
Foam::token::isPunctuation
bool isPunctuation() const noexcept
Token is PUNCTUATION.
Definition: tokenI.H:459
Foam::token::isFlag
bool isFlag() const noexcept
Token is FLAG.
Definition: tokenI.H:441
Foam::token::operator<<
friend Ostream & operator<<(Ostream &os, const token &tok)
Foam::token::END_STATEMENT
End entry [isseparator].
Definition: token.H:154
Foam::token::compound::moved
bool moved() const noexcept
Get compound transferred status.
Definition: token.H:219
Foam::token::compound::isCompound
static bool isCompound(const word &name)
Test if name is a known (registered) compound type.
Definition: token.C:80
Istream.H
Foam::token::NULL_TOKEN
Nul character.
Definition: token.H:122
Foam::token::isSeparator
bool isSeparator() const noexcept
Token is PUNCTUATION and isseparator.
Definition: tokenI.H:475
Foam::token::END_BLOCK
End block [isseparator].
Definition: token.H:160
Foam::token::undefinedToken
static const token undefinedToken
An undefined token.
Definition: token.H:294
Foam::token::DOLLAR
Dollar - start variable or expression.
Definition: token.H:131
Foam::token::NL
Newline [isspace].
Definition: token.H:124
Foam::token::WORD
Foam::word.
Definition: token.H:90
scalar.H
Foam::token::END_SQR
End dimensions [isseparator].
Definition: token.H:158
os
OBJstream os(runTime.globalPath()/outputName)
Foam::token::HASH
Hash - directive or start verbatim string.
Definition: token.H:130
Foam::token::MULTIPLY
Multiply [isseparator].
Definition: token.H:140
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::token::QUESTION
Question mark (eg, ternary)
Definition: token.H:132
Foam::token::isScalar
bool isScalar() const noexcept
Token is FLOAT or DOUBLE.
Definition: tokenI.H:561
Foam::token::operator==
bool operator==(const token &tok) const
Definition: tokenI.H:884
Foam::token::floatToken
floatScalar floatToken() const
Return float value.
Definition: tokenI.H:531
Foam::token::transferCompoundToken
compound & transferCompoundToken()
Return reference to compound and mark internally as released.
Definition: token.C:90
Foam::token::BEGIN_BLOCK
Begin block [isseparator].
Definition: token.H:159
Foam::token::doubleToken
doubleScalar doubleToken() const
Return double value.
Definition: tokenI.H:549
Foam::token::wordToken
const word & wordToken() const
Return const reference to the word contents.
Definition: tokenI.H:631
Foam::token::isDirective
bool isDirective() const noexcept
Token is DIRECTIVE (word variant)
Definition: tokenI.H:625
Foam::token::compound::size
virtual label size() const =0
The size of the underlying content.
Foam::token::typeName
static constexpr const char *const typeName
The type name is "token".
Definition: token.H:346
Foam::token::VARIABLE
Definition: token.H:98
Foam::token::compound::operator<<
friend Ostream & operator<<(Ostream &os, const compound &ct)
Output operator.
Foam::token::LPAREN
Left parenthesis [isseparator].
Definition: token.H:143
Foam::token::good
bool good() const noexcept
True if token is not UNDEFINED or ERROR.
Definition: tokenI.H:405
Foam::token::UNDEFINED
An undefined token-type.
Definition: token.H:78
Foam::token::swap
void swap(token &tok)
Swap token contents: type, data, line-number.
Definition: tokenI.H:298
Foam::token::isVerbatim
bool isVerbatim() const noexcept
Token is VERBATIM string (string variant)
Definition: tokenI.H:677
Foam::token::type
tokenType type() const noexcept
Return the token type.
Definition: tokenI.H:311
Foam::token::Compound::TypeName
TypeName("Compound<T>")
Declare type-name, virtual type (with debug switch)
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::token::Compound::Compound
Compound(const T &val)
Copy construct.
Definition: token.H:259
Foam::token::COLON
Colon [isseparator].
Definition: token.H:127
Foam::token::LSQUARE
Left square bracket [isseparator].
Definition: token.H:145
Foam::token::scalarToken
scalar scalarToken() const
Return float or double value.
Definition: tokenI.H:571
Foam::token::name
word name() const
Return the name of the token type.
Definition: tokenIO.C:134
runTimeSelectionTables.H
Macros to ease declaration of run-time selection tables.
Foam::token::flag
static token flag(int bitmask) noexcept
Create a token with stream flags, no sanity check.
Definition: tokenI.H:43
Foam::token::undefined
bool undefined() const noexcept
Token is UNDEFINED.
Definition: tokenI.H:411
Foam::token::compound::compound
constexpr compound() noexcept
Default construct.
Definition: token.H:200
label.H
Foam::token::tokenType
tokenType
Enumeration defining the types of token.
Definition: token.H:76
Foam::token::BOOL
boolean type
Definition: token.H:84
Foam::token::SPACE
Space [isspace].
Definition: token.H:125
Foam::token::FLAG
stream flag (1-byte bitmask)
Definition: token.H:82
Foam::token::isString
bool isString() const noexcept
Token is string-variant (STRING, EXPRESSION, VARIABLE, VERBATIM)
Definition: tokenI.H:653
Foam::token::VERBATIMSTRING
Definition: token.H:106
Foam::token::doubleScalarToken
doubleScalar doubleScalarToken() const
Return double value.
Definition: token.H:683
Foam::token::isCompound
bool isCompound() const noexcept
Token is COMPOUND.
Definition: tokenI.H:716
Foam::token::FLOAT
float (single-precision) type
Definition: token.H:86
Foam::token::END_LIST
End list [isseparator].
Definition: token.H:156
Foam::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.
Foam::token::flagToken
int flagToken() const
Return flag bitmask value.
Definition: tokenI.H:447
Foam::token::compound::New
static autoPtr< compound > New(const word &type, Istream &is)
Construct compound from Istream.
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
uLabel.H
Foam::TAB
The TAB Method for Numerical Calculation of Spray Droplet Breakup.
Definition: TAB.H:66
Foam::token::BEGIN_LIST
Begin list [isseparator].
Definition: token.H:155
refCount.H
Foam::token::VERBATIM
Definition: token.H:100
Foam::token::setType
bool setType(const tokenType tokType) noexcept
Change the token type, for similar types.
Definition: tokenI.H:317
Foam::error
Class to handle errors and exceptions in a simple, consistent stream-based manner.
Definition: error.H:73
Foam::token::BEGIN_STRING
Begin string with double quote.
Definition: token.H:162
Foam::token::punctuationToken
punctuationToken
Standard punctuation tokens (a character)
Definition: token.H:120
Foam::token::compound::moved
void moved(bool b) noexcept
Set compound transferred status.
Definition: token.H:225
Foam::token::operator=
void operator=(const token &tok)
Copy assign.
Definition: tokenI.H:743
Foam::token::ADD
Addition [isseparator].
Definition: token.H:152
Foam::token::setBad
void setBad()
Clear token and set to be ERROR.
Definition: tokenI.H:734