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-2022 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 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"
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,
87  FLOAT,
88  DOUBLE,
89 
90  // Pointer types
91  WORD,
92  STRING,
94 
96  EXPRESSION,
98  VARIABLE,
100  VERBATIM,
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 = ' ',
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 = '}',
151  // With semantically meaning
152 
153  ADD = PLUS,
154  SUBTRACT = MINUS,
164  END_STRING = DQUOTE
165  };
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 
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;
307  int flagVal; // bitmask - stored as int, not enum
308  punctuationToken punctuationVal;
309  label labelVal;
310  float floatVal;
311  double 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_;
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:
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 float val, label lineNum=0) noexcept;
369 
370  //- Construct double token
371  inline explicit token(const double 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 float floatToken() const;
535 
536  //- Return double value.
537  // Report FatalIOError and return \b 0 if token is not DOUBLE
538  inline double 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 float val);
611 
612  //- Copy assign from double
613  inline void operator=(const double 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 float val) const noexcept;
640  inline bool operator==(const double 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 float val) const noexcept;
650  inline bool operator!=(const double 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  float floatScalarToken() const { return floatToken(); }
681 
682  //- Return double value.
683  // \deprecated(2020-01) - doubleToken()
684  double 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 // ************************************************************************* //
Subtract or start of negative number.
Definition: token.H:142
Begin block [isseparator].
Definition: token.H:162
static const token undefinedToken
An undefined token.
Definition: token.H:343
bool good() const noexcept
True if token is not UNDEFINED or ERROR.
Definition: tokenI.H:398
double doubleScalarToken() const
Return double value.
Definition: token.H:924
Compound(const T &val)
Copy construct.
Definition: token.H:298
bool isPunctuation() const noexcept
Token is PUNCTUATION.
Definition: tokenI.H:452
bool operator!=(const token &tok) const
Definition: tokenI.H:971
bool isDouble() const noexcept
Token is DOUBLE.
Definition: tokenI.H:536
boolean type
Definition: token.H:83
Left parenthesis [isseparator].
Definition: token.H:146
bool isWord() const noexcept
Token is word-variant (WORD, DIRECTIVE)
Definition: tokenI.H:602
BINARY-mode stream.
Definition: token.H:116
punctuationToken pToken() const
Return punctuation character.
Definition: tokenI.H:478
constexpr token() noexcept
Default construct, initialized to an UNDEFINED token.
Definition: tokenI.H:90
compound & transferCompoundToken()
Return reference to compound and mark internally as released.
Definition: token.C:86
single character punctuation
Definition: token.H:82
No flags.
Definition: token.H:114
Reference counter for various OpenFOAM components.
Definition: refCount.H:44
stream flag (1-byte bitmask)
Definition: token.H:81
Double quote.
Definition: token.H:138
bool isCompound() const noexcept
Token is COMPOUND.
Definition: tokenI.H:709
scalar number() const
Return label, float or double value.
Definition: tokenI.H:586
InfoProxy< token > info() const
Return info proxy for printing token information to a stream.
Definition: token.H:788
Begin dimensions [isseparator].
Definition: token.H:160
const word & wordToken() const
Return const reference to the word contents.
Definition: tokenI.H:624
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
declareRunTimeSelectionTable(autoPtr, compound, Istream,(Istream &is),(is))
Declare run-time constructor selection table.
A token holds an item read from Istream.
Definition: token.H:64
tokenType
Enumeration defining the types of token.
Definition: token.H:75
Newline [isspace].
Definition: token.H:127
bool moved() const noexcept
Get compound transferred status.
Definition: token.H:244
tokenType type() const noexcept
Return the token type.
Definition: tokenI.H:304
bool isFlag() const noexcept
Token is FLAG.
Definition: tokenI.H:434
Begin string with double quote.
Definition: token.H:165
void swap(token &tok)
Swap token contents: type, data, line-number.
Definition: tokenI.H:291
friend Ostream & operator<<(Ostream &os, const token &tok)
TypeName("compound")
Declare type-name, virtual type (with debug switch)
Begin list [isseparator].
Definition: token.H:158
Subtract or start of negative number.
Definition: token.H:156
Addition [isseparator].
Definition: token.H:155
Assignment/equals [isseparator].
Definition: token.H:140
float floatToken() const
Return float value.
Definition: tokenI.H:524
bool isExpression() const noexcept
Token is EXPRESSION (string variant)
Definition: tokenI.H:658
bool isSeparator() const noexcept
Token is PUNCTUATION and isseparator.
Definition: tokenI.H:468
virtual ~compound() noexcept=default
Destructor.
End entry [isseparator].
Definition: token.H:157
bool undefined() const noexcept
Token is UNDEFINED.
Definition: tokenI.H:404
scalar scalarToken() const
Return float or double value.
Definition: tokenI.H:564
bool boolToken() const
Return boolean token value.
Definition: tokenI.H:422
Dollar - start variable or expression.
Definition: token.H:134
word name() const
Return the name of the token type.
Definition: tokenIO.C:127
Foam::word.
Definition: token.H:89
static constexpr const char *const typeName
The type name is "token".
Definition: token.H:408
End dimensions [isseparator].
Definition: token.H:161
bool isScalar() const noexcept
Token is FLOAT or DOUBLE.
Definition: tokenI.H:554
bool isString() const noexcept
Token is string-variant (STRING, EXPRESSION, VARIABLE, VERBATIM)
Definition: tokenI.H:646
int flagToken() const
Return flag bitmask value.
Definition: tokenI.H:440
Class to handle errors and exceptions in a simple, consistent stream-based manner.
Definition: error.H:69
Right square bracket [isseparator].
Definition: token.H:149
Abstract base class for complex tokens.
Definition: token.H:173
A templated class for holding compound tokens.
Definition: token.H:281
label (integer) type
Definition: token.H:84
Addition [isseparator].
Definition: token.H:141
Right parenthesis [isseparator].
Definition: token.H:147
Comma [isseparator].
Definition: token.H:132
Compound type such as List<label> etc.
Definition: token.H:91
label lineNumber() const noexcept
The line number for the token.
Definition: tokenI.H:384
double doubleToken() const
Return double value.
Definition: tokenI.H:542
Left square bracket [isseparator].
Definition: token.H:148
Single quote.
Definition: token.H:137
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
bool isStringType() const noexcept
Token is word-variant or string-variant (WORD, DIRECTIVE, STRING, EXPRESSION, VARIABLE, VERBATIM)
Definition: tokenI.H:676
A class for handling words, derived from Foam::string.
Definition: word.H:63
static bool isseparator(int c) noexcept
True if the character is a punctuation separator (eg, in ISstream).
Definition: tokenI.H:46
Istream & operator>>(Istream &, directionInfo &)
End string with double quote.
Definition: token.H:166
flagType
Stream or output control flags (1-byte width)
Definition: token.H:112
Space [isspace].
Definition: token.H:128
void setBad()
Clear token and set to be ERROR.
Definition: tokenI.H:727
punctuationToken
Standard punctuation tokens (a character)
Definition: token.H:123
const compound & compoundToken() const
Read access for compound token.
Definition: tokenI.H:715
End list [isseparator].
Definition: token.H:159
static autoPtr< compound > New(const word &type, Istream &is)
Construct compound from Istream.
Definition: token.C:52
float (single-precision) type
Definition: token.H:85
float floatScalarToken() const
Return float value.
Definition: token.H:917
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:55
const direction noexcept
Definition: Scalar.H:258
Divide [isseparator].
Definition: token.H:144
bool isBool() const noexcept
Token is BOOL.
Definition: tokenI.H:416
constexpr compound() noexcept
Default construct.
Definition: token.H:217
static bool isCompound(const word &name)
Test if name is a known (registered) compound type.
Definition: token.C:76
Token error encountered.
Definition: token.H:78
bool setType(const tokenType tokType) noexcept
Change the token type, for similar types.
Definition: tokenI.H:310
The TAB Method for Numerical Calculation of Spray Droplet Breakup.
Definition: TAB.H:60
OBJstream os(runTime.globalPath()/outputName)
bool isFloatScalar() const
Token is FLOAT.
Definition: token.H:903
bool isDoubleScalar() const
Token is DOUBLE.
Definition: token.H:910
const string & stringToken() const
Return const reference to the string contents.
Definition: tokenI.H:682
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Left brace [isseparator].
Definition: token.H:150
static token flag(int bitmask) noexcept
Create a token with stream flags, no sanity check.
Definition: tokenI.H:36
bool operator==(const token &tok) const
Definition: tokenI.H:877
Foam::string (usually double-quoted)
Definition: token.H:90
void operator=(const token &tok)
Copy assign.
Definition: tokenI.H:736
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:76
bool isFloat() const noexcept
Token is FLOAT.
Definition: tokenI.H:518
void reset()
Reset token to UNDEFINED and clear any allocated storage.
Definition: tokenI.H:250
virtual label size() const =0
The size of the underlying content.
A helper class for outputting values to Ostream.
Definition: ensightCells.H:43
ASCII-mode stream.
Definition: token.H:115
const dimensionedScalar c
Speed of light in a vacuum.
label labelToken() const
Return label value.
Definition: tokenI.H:506
Semicolon [isseparator].
Definition: token.H:131
double (double-precision) type
Definition: token.H:86
Right brace [isseparator].
Definition: token.H:151
bool isLabel() const noexcept
Token is LABEL.
Definition: tokenI.H:490
The &#39;at&#39; symbol.
Definition: token.H:136
virtual void write(Ostream &os) const
Redirect write to underlying content.
Definition: token.H:333
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Macros to ease declaration of run-time selection tables.
Question mark (eg, ternary)
Definition: token.H:135
volScalarField & p
bool isVariable() const noexcept
Token is VARIABLE (string variant)
Definition: tokenI.H:664
bool isDirective() const noexcept
Token is DIRECTIVE (word variant)
Definition: tokenI.H:618
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))
End block [isseparator].
Definition: token.H:163
Nul character.
Definition: token.H:125
bool isNumber() const noexcept
Token is LABEL, FLOAT or DOUBLE.
Definition: tokenI.H:580
An undefined token-type.
Definition: token.H:77
virtual void write(Ostream &os) const =0
Redirect write to underlying content.
friend Ostream & operator<<(Ostream &os, const compound &ct)
Output operator.
bool isVerbatim() const noexcept
Token is VERBATIM string (string variant)
Definition: tokenI.H:670
Multiply [isseparator].
Definition: token.H:143
Namespace for OpenFOAM.
Hash - directive or start verbatim string.
Definition: token.H:133
virtual label size() const
The size of the underlying content.
Definition: token.H:325
bool isQuotedString() const noexcept
Token is (quoted) STRING (string variant)
Definition: tokenI.H:640
TypeName("Compound<T>")
Declare type-name, virtual type (with debug switch)
Colon [isseparator].
Definition: token.H:130