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