tokenI.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-2019 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 \*---------------------------------------------------------------------------*/
28 
29 #include <algorithm>
30 
31 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
32 
34 {
35  token tok;
36  tok.type_ = tokenType::BOOL;
37  tok.data_.labelVal = on;
38 
39  return tok;
40 }
41 
42 
43 inline Foam::token Foam::token::flag(int bitmask)
44 {
45  token tok;
46  tok.type_ = tokenType::FLAG;
47  tok.data_.flagVal = bitmask;
48 
49  return tok;
50 }
51 
52 
53 inline bool Foam::token::isseparator(int c)
54 {
55  switch (c)
56  {
58  case token::BEGIN_LIST :
59  case token::END_LIST :
60  case token::BEGIN_SQR :
61  case token::END_SQR :
62  case token::BEGIN_BLOCK :
63  case token::END_BLOCK :
64  case token::COLON :
65  case token::COMMA :
66  case token::ASSIGN :
67  case token::ADD :
68  // Excluded token::SUBTRACT since it could start a number
69  case token::MULTIPLY :
70  case token::DIVIDE :
71  {
72  return true;
73  }
74 
75  default:
76  break;
77  }
78 
79  return false;
80 }
81 
82 
83 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
84 
85 inline void Foam::token::setUndefined()
86 {
87  type_ = tokenType::UNDEFINED;
88  data_.int64Val = 0; // bit-wise zero for union content
89  // leave lineNumber untouched - may still be needed
90 }
91 
92 
93 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
94 
95 inline constexpr Foam::token::token() noexcept
96 :
97  data_(), // bit-wise zero for union content
98  type_(tokenType::UNDEFINED),
99  lineNumber_(0)
100 {}
101 
102 
103 inline Foam::token::token(const token& tok)
104 :
105  data_(tok.data_), // bit-wise copy of union content
106  type_(tok.type_),
107  lineNumber_(tok.lineNumber_)
108 {
109  // Fundamental: values already handled by bit-wise copy
110  // Pointer: duplicate content or increase refCount
111 
112  switch (type_)
113  {
114  case tokenType::WORD:
115  {
116  data_.wordPtr = new word(*tok.data_.wordPtr);
117  break;
118  }
119 
120  case tokenType::STRING:
121  case tokenType::VARIABLE:
122  case tokenType::VERBATIMSTRING:
123  {
124  data_.stringPtr = new string(*tok.data_.stringPtr);
125  break;
126  }
127 
128  case tokenType::COMPOUND:
129  {
130  // Identical pointers, but increase the refCount
131  data_.compoundPtr = tok.data_.compoundPtr;
132  data_.compoundPtr->refCount::operator++();
133  break;
134  }
135 
136  default:
137  break;
138  }
139 }
140 
141 
143 :
144  data_(tok.data_), // bit-wise copy of union content
145  type_(tok.type_),
146  lineNumber_(tok.lineNumber_)
147 {
148  tok.setUndefined(); // zero the union content without any checking
149  tok.lineNumber_ = 0;
150 }
151 
152 
154 :
155  data_(),
156  type_(tokenType::PUNCTUATION),
157  lineNumber_(lineNumber)
158 {
159  data_.punctuationVal = p;
160 }
161 
162 
163 inline Foam::token::token(const label val, label lineNumber)
164 :
165  data_(),
166  type_(tokenType::LABEL),
167  lineNumber_(lineNumber)
168 {
169  data_.labelVal = val;
170 }
171 
172 
173 inline Foam::token::token(const floatScalar val, label lineNumber)
174 :
175  data_(),
176  type_(tokenType::FLOAT_SCALAR),
177  lineNumber_(lineNumber)
178 {
179  data_.floatVal = val;
180 }
181 
182 
183 inline Foam::token::token(const doubleScalar val, label lineNumber)
184 :
185  data_(),
186  type_(tokenType::DOUBLE_SCALAR),
187  lineNumber_(lineNumber)
188 {
189  data_.doubleVal = val;
190 }
191 
192 
193 inline Foam::token::token(const word& w, label lineNumber)
194 :
195  data_(),
196  type_(tokenType::WORD),
197  lineNumber_(lineNumber)
198 {
199  data_.wordPtr = new word(w);
200 }
201 
202 
203 inline Foam::token::token(const string& str, label lineNumber)
204 :
205  data_(),
206  type_(tokenType::STRING),
207  lineNumber_(lineNumber)
208 {
209  data_.stringPtr = new string(str);
210 }
211 
212 
213 inline Foam::token::token(word&& w, label lineNumber)
214 :
215  data_(),
216  type_(tokenType::WORD),
217  lineNumber_(lineNumber)
218 {
219  data_.wordPtr = new word(std::move(w));
220 }
221 
222 
223 inline Foam::token::token(string&& str, label lineNumber)
224 :
225  data_(),
226  type_(tokenType::STRING),
227  lineNumber_(lineNumber)
228 {
229  data_.stringPtr = new string(std::move(str));
230 }
231 
232 
233 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
234 
236 {
237  reset();
238 }
239 
240 
241 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
242 
243 inline void Foam::token::reset()
244 {
245  switch (type_)
246  {
247  case tokenType::WORD:
248  {
249  delete data_.wordPtr;
250  break;
251  }
252 
253  case tokenType::STRING:
254  case tokenType::VARIABLE:
255  case tokenType::VERBATIMSTRING:
256  {
257  delete data_.stringPtr;
258  break;
259  }
260 
261  case tokenType::COMPOUND:
262  {
263  if (data_.compoundPtr->unique())
264  {
265  delete data_.compoundPtr;
266  }
267  else
268  {
269  data_.compoundPtr->refCount::operator--();
270  }
271  break;
272  }
273 
274  default:
275  break;
276  }
277 
278  setUndefined();
279 }
280 
281 
282 inline void Foam::token::swap(token& tok)
283 {
284  if (this == &tok)
285  {
286  return; // Self-swap is a no-op
287  }
288 
289  std::swap(data_, tok.data_);
290  std::swap(type_, tok.type_);
291  std::swap(lineNumber_, tok.lineNumber_);
292 }
293 
294 
296 {
297  return type_;
298 }
299 
300 
302 {
303  if (type_ == variant)
304  {
305  // No change required
306  return true;
307  }
308 
309  switch (variant)
310  {
311  case tokenType::BOOL:
312  case tokenType::LABEL:
313  {
314  switch (type_)
315  {
316  case tokenType::BOOL:
317  case tokenType::LABEL:
318  type_ = variant;
319  return true;
320  break;
321 
322  default:
323  break;
324  }
325  }
326  break;
327 
328  case tokenType::STRING:
329  case tokenType::VARIABLE:
330  case tokenType::VERBATIMSTRING:
331  {
332  switch (type_)
333  {
334  // could also go from WORD to STRING etc - to be decided
335  case tokenType::STRING:
336  case tokenType::VARIABLE:
337  case tokenType::VERBATIMSTRING:
338  type_ = variant;
339  return true;
340  break;
341 
342  default:
343  break;
344  }
345  }
346  break;
347 
348  default:
349  break;
350  }
351 
352  return false;
353 }
354 
355 
357 {
358  return lineNumber_;
359 }
360 
361 
363 {
364  return lineNumber_;
365 }
366 
367 
368 inline bool Foam::token::good() const
369 {
370  return (type_ != tokenType::UNDEFINED && type_ != tokenType::ERROR);
371 }
372 
373 
374 inline bool Foam::token::undefined() const
375 {
376  return (type_ == tokenType::UNDEFINED);
377 }
378 
379 
380 inline bool Foam::token::error() const
381 {
382  return (type_ == tokenType::ERROR);
383 }
384 
385 
386 inline bool Foam::token::isBool() const
387 {
388  return (type_ == tokenType::BOOL);
389 }
390 
391 
392 inline bool Foam::token::boolToken() const
393 {
394  if (type_ == tokenType::BOOL || type_ == tokenType::LABEL)
395  {
396  return data_.labelVal;
397  }
398 
399  parseError("bool");
400  return false;
401 }
402 
403 
404 inline bool Foam::token::isFlag() const
405 {
406  return (type_ == tokenType::FLAG);
407 }
408 
409 
410 inline int Foam::token::flagToken() const
411 {
412  if (type_ == tokenType::FLAG)
413  {
414  return data_.flagVal;
415  }
416 
417  parseError("flag bitmask");
418  return NO_FLAG;
419 }
420 
421 
422 inline bool Foam::token::isPunctuation() const
423 {
424  return (type_ == tokenType::PUNCTUATION);
425 }
426 
427 
429 {
430  if (type_ == tokenType::PUNCTUATION)
431  {
432  return data_.punctuationVal;
433  }
434 
435  parseError("punctuation character");
436  return punctuationToken::NULL_TOKEN;
437 }
438 
439 
440 inline bool Foam::token::isSeparator() const
441 {
442  return
443  (
444  type_ == tokenType::PUNCTUATION
445  && isseparator(data_.punctuationVal)
446  );
447 }
448 
449 
450 inline bool Foam::token::isLabel() const
451 {
452  return (type_ == tokenType::LABEL);
453 }
454 
455 
457 {
458  if (type_ == tokenType::LABEL)
459  {
460  return data_.labelVal;
461  }
462 
463  parseError("label");
464  return 0;
465 }
466 
467 
468 inline bool Foam::token::isFloatScalar() const
469 {
470  return (type_ == tokenType::FLOAT_SCALAR);
471 }
472 
473 
475 {
476  if (type_ == tokenType::FLOAT_SCALAR)
477  {
478  return data_.floatVal;
479  }
480 
481  parseError("float");
482  return 0;
483 }
484 
485 
486 inline bool Foam::token::isDoubleScalar() const
487 {
488  return (type_ == tokenType::DOUBLE_SCALAR);
489 }
490 
491 
493 {
494  if (type_ == tokenType::DOUBLE_SCALAR)
495  {
496  return data_.doubleVal;
497  }
498 
499  parseError("double");
500  return 0;
501 }
502 
503 
504 inline bool Foam::token::isScalar() const
505 {
506  return
507  (
508  type_ == tokenType::FLOAT_SCALAR
509  || type_ == tokenType::DOUBLE_SCALAR
510  );
511 }
512 
513 
514 inline Foam::scalar Foam::token::scalarToken() const
515 {
516  if (type_ == tokenType::FLOAT_SCALAR)
517  {
518  return data_.floatVal;
519  }
520  else if (type_ == tokenType::DOUBLE_SCALAR)
521  {
522  return data_.doubleVal;
523  }
524 
525  parseError("scalar");
526  return 0;
527 }
528 
529 
530 inline bool Foam::token::isNumber() const
531 {
532  return (type_ == tokenType::LABEL || isScalar());
533 }
534 
535 
536 inline Foam::scalar Foam::token::number() const
537 {
538  if (isLabel())
539  {
540  return labelToken();
541  }
542  if (isScalar())
543  {
544  return scalarToken();
545  }
546 
547  parseError("number (label or scalar)");
548  return 0;
549 }
550 
551 
552 inline bool Foam::token::isWord() const
553 {
554  return (type_ == tokenType::WORD);
555 }
556 
557 
558 inline const Foam::word& Foam::token::wordToken() const
559 {
560  if (type_ == tokenType::WORD)
561  {
562  return *data_.wordPtr;
563  }
564 
565  parseError("word");
566  return word::null;
567 }
568 
569 
570 inline bool Foam::token::isString() const
571 {
572  return
573  (
574  type_ == tokenType::STRING
575  || type_ == tokenType::VARIABLE
576  || type_ == tokenType::VERBATIMSTRING
577  );
578 }
579 
580 
581 inline bool Foam::token::isVariable() const
582 {
583  return (type_ == tokenType::VARIABLE);
584 }
585 
586 
587 inline bool Foam::token::isVerbatim() const
588 {
589  return (type_ == tokenType::VERBATIMSTRING);
590 }
591 
592 
593 inline bool Foam::token::isStringType() const
594 {
595  return (isWord() || isString());
596 }
597 
598 
600 {
601  if
602  (
603  type_ == tokenType::STRING
604  || type_ == tokenType::VARIABLE
605  || type_ == tokenType::VERBATIMSTRING
606  )
607  {
608  return *data_.stringPtr;
609  }
610  else if (type_ == tokenType::WORD)
611  {
612  // Upcast to string
613  return static_cast<const string&>(*data_.wordPtr);
614  }
615 
616  parseError("string");
617  return string::null;
618 }
619 
620 
621 inline bool Foam::token::isCompound() const
622 {
623  return (type_ == tokenType::COMPOUND);
624 }
625 
626 
628 {
629  if (type_ == tokenType::COMPOUND)
630  {
631  return *data_.compoundPtr;
632  }
633 
634  parseError("compound");
635  return *data_.compoundPtr; // This is questionable.
636 }
637 
638 
639 inline void Foam::token::setBad()
640 {
641  reset();
642  type_ = tokenType::ERROR;
643 }
644 
645 
646 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
647 
648 inline void Foam::token::operator=(const token& tok)
649 {
650  if (this == &tok)
651  {
652  return; // Self-assignment is a no-op
653  }
654 
655  reset();
656 
657  type_ = tok.type_;
658  data_ = tok.data_; // bit-wise copy of union content
659  lineNumber_ = tok.lineNumber_;
660 
661  // Fundamental: values already handled by bit-wise copy
662  // Pointer: duplicate content or increase refCount
663 
664  switch (type_)
665  {
666  case tokenType::WORD:
667  {
668  data_.wordPtr = new word(*tok.data_.wordPtr);
669  }
670  break;
671 
672  case tokenType::STRING:
673  case tokenType::VARIABLE:
674  case tokenType::VERBATIMSTRING:
675  {
676  data_.stringPtr = new string(*tok.data_.stringPtr);
677  }
678  break;
679 
680  case tokenType::COMPOUND:
681  {
682  // Identical pointers, but increase the refCount
683  data_.compoundPtr = tok.data_.compoundPtr;
684  data_.compoundPtr->refCount::operator++();
685  }
686  break;
687 
688  default:
689  break;
690  }
691 }
692 
693 
694 inline void Foam::token::operator=(token&& tok)
695 {
696  if (this == &tok)
697  {
698  return; // Self-assignment is a no-op
699  }
700 
701  reset();
702  lineNumber_ = 0;
703  swap(tok);
704 }
705 
706 
708 {
709  reset();
710  type_ = tokenType::PUNCTUATION;
711  data_.punctuationVal = p;
712 }
713 
714 
715 inline void Foam::token::operator=(const label val)
716 {
717  reset();
718  type_ = tokenType::LABEL;
719  data_.labelVal = val;
720 }
721 
722 
724 {
725  reset();
726  type_ = tokenType::FLOAT_SCALAR;
727  data_.floatVal = val;
728 }
729 
730 
732 {
733  reset();
734  type_ = tokenType::DOUBLE_SCALAR;
735  data_.doubleVal = val;
736 }
737 
738 
739 inline void Foam::token::operator=(const word& w)
740 {
741  reset();
742  type_ = tokenType::WORD;
743  data_.wordPtr = new word(w);
744 }
745 
746 
747 inline void Foam::token::operator=(const string& str)
748 {
749  reset();
750  type_ = tokenType::STRING;
751  data_.stringPtr = new string(str);
752 }
753 
754 
755 inline void Foam::token::operator=(word&& w)
756 {
757  reset();
758  type_ = tokenType::WORD;
759  data_.wordPtr = new word(std::move(w));
760 }
761 
762 
763 inline void Foam::token::operator=(string&& s)
764 {
765  reset();
766  type_ = tokenType::STRING;
767  data_.stringPtr = new string(std::move(s));
768 }
769 
770 
772 {
773  reset();
774  type_ = tokenType::COMPOUND;
775  data_.compoundPtr = compoundPtr;
776 }
777 
778 
779 inline bool Foam::token::operator==(const token& tok) const
780 {
781  if (type_ != tok.type_)
782  {
783  return false;
784  }
785 
786  switch (type_)
787  {
788  case tokenType::UNDEFINED:
789  return true;
790 
791  case tokenType::BOOL:
792  return data_.labelVal == tok.data_.labelVal;
793 
794  case tokenType::FLAG:
795  return data_.flagVal == tok.data_.flagVal;
796 
797  case tokenType::PUNCTUATION:
798  return data_.punctuationVal == tok.data_.punctuationVal;
799 
800  case tokenType::LABEL:
801  return data_.labelVal == tok.data_.labelVal;
802 
803  case tokenType::FLOAT_SCALAR:
804  return equal(data_.floatVal, tok.data_.floatVal);
805 
806  case tokenType::DOUBLE_SCALAR:
807  return equal(data_.doubleVal, tok.data_.doubleVal);
808 
809  case tokenType::WORD:
810  return *data_.wordPtr == *tok.data_.wordPtr;
811 
812  case tokenType::STRING:
813  case tokenType::VARIABLE:
814  case tokenType::VERBATIMSTRING:
815  return *data_.stringPtr == *tok.data_.stringPtr;
816 
817  case tokenType::COMPOUND:
818  return data_.compoundPtr == tok.data_.compoundPtr;
819 
820  case tokenType::ERROR:
821  return true;
822  }
823 
824  return false;
825 }
826 
827 
829 {
830  return (type_ == tokenType::PUNCTUATION && data_.punctuationVal == p);
831 }
832 
833 
834 inline bool Foam::token::operator==(const std::string& s) const
835 {
836  return
837  (
838  type_ == tokenType::WORD
839  ? s == *data_.wordPtr
840  : isString() && s == *data_.stringPtr
841  );
842 }
843 
844 
845 inline bool Foam::token::operator==(const label val) const
846 {
847  return
848  (
849  type_ == tokenType::LABEL
850  && data_.labelVal == val
851  );
852 }
853 
854 
855 inline bool Foam::token::operator==(const floatScalar val) const
856 {
857  return
858  (
859  type_ == tokenType::FLOAT_SCALAR
860  && equal(data_.floatVal, val)
861  );
862 }
863 
864 
865 inline bool Foam::token::operator==(const doubleScalar val) const
866 {
867  return
868  (
869  type_ == tokenType::DOUBLE_SCALAR
870  && equal(data_.doubleVal, val)
871  );
872 }
873 
874 
875 inline bool Foam::token::operator!=(const token& tok) const
876 {
877  return !operator==(tok);
878 }
879 
880 
882 {
883  return !operator==(p);
884 }
885 
886 
887 inline bool Foam::token::operator!=(const label val) const
888 {
889  return !operator==(val);
890 }
891 
892 
893 inline bool Foam::token::operator!=(const floatScalar val) const
894 {
895  return !operator==(val);
896 }
897 
898 
899 inline bool Foam::token::operator!=(const doubleScalar val) const
900 {
901  return !operator==(val);
902 }
903 
904 
905 inline bool Foam::token::operator!=(const std::string& s) const
906 {
907  return !operator==(s);
908 }
909 
910 
911 // ************************************************************************* //
Foam::token::isDoubleScalar
bool isDoubleScalar() const
Token is DOUBLE_SCALAR.
Definition: tokenI.H:486
Foam::token::flag
static token flag(int bitmask)
Create a token with stream flags, no sanity check.
Definition: tokenI.H:43
Foam::token::ASSIGN
Assignment/equals [isseparator].
Definition: token.H:131
Foam::token::isFlag
bool isFlag() const
Token is FLAG.
Definition: tokenI.H:404
Foam::token::labelToken
label labelToken() const
Return label value.
Definition: tokenI.H:456
Foam::val
label ListType::const_reference val
Definition: ListOps.H:407
Foam::doubleScalar
double doubleScalar
Floating-point double precision scalar type.
Definition: doubleScalar.H:52
Foam::token::COMMA
Comma [isseparator].
Definition: token.H:124
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::token::isScalar
bool isScalar() const
Token is FLOAT_SCALAR or DOUBLE_SCALAR.
Definition: tokenI.H:504
Foam::token::compound
Abstract base class for complex tokens.
Definition: token.H:143
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
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::isNumber
bool isNumber() const
Token is LABEL, FLOAT_SCALAR or DOUBLE_SCALAR.
Definition: tokenI.H:530
Foam::token::stringToken
const string & stringToken() const
Return const reference to the string contents.
Definition: tokenI.H:599
Foam::token::isFloatScalar
bool isFloatScalar() const
Token is FLOAT_SCALAR.
Definition: tokenI.H:468
Foam::floatScalar
float floatScalar
Floating-point single precision scalar type.
Definition: floatScalar.H:52
Foam::token::isString
bool isString() const
Token is STRING, VARIABLE or VERBATIM string.
Definition: tokenI.H:570
Foam::token::boolToken
bool boolToken() const
Return boolean token value.
Definition: tokenI.H:392
Foam::token
A token holds an item read from Istream.
Definition: token.H:69
Foam::token::compoundToken
const compound & compoundToken() const
Read access for compound token.
Definition: tokenI.H:627
Foam::string
A class for handling character strings derived from std::string.
Definition: string.H:73
Foam::token::isSeparator
bool isSeparator() const
Token is PUNCTUATION and isseparator.
Definition: tokenI.H:440
Foam::token::good
bool good() const
True if token is not UNDEFINED or ERROR.
Definition: tokenI.H:368
Foam::token::isCompound
bool isCompound() const
Token is COMPOUND.
Definition: tokenI.H:621
Foam::token::pToken
punctuationToken pToken() const
Return punctuation character.
Definition: tokenI.H:428
Foam::token::isseparator
static bool isseparator(int c)
True if the character is a punctuation separator (eg, in ISstream).
Definition: tokenI.H:53
Foam::token::isLabel
bool isLabel() const
Token is LABEL.
Definition: tokenI.H:450
Foam::token::floatScalarToken
floatScalar floatScalarToken() const
Return float value.
Definition: tokenI.H:474
Foam::token::DIVIDE
Divide [isseparator].
Definition: token.H:135
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
Foam::token::number
scalar number() const
Return label, float or double value.
Definition: tokenI.H:536
Foam::operator==
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
Foam::token::BEGIN_SQR
Begin dimensions [isseparator].
Definition: token.H:119
Foam::token::~token
~token()
Destructor.
Definition: tokenI.H:235
Foam::token::operator!=
bool operator!=(const token &tok) const
Definition: tokenI.H:875
Foam::token::reset
void reset()
Reset token to UNDEFINED and clear any allocated storage.
Definition: tokenI.H:243
Foam::token::isVariable
bool isVariable() const
Token is VARIABLE.
Definition: tokenI.H:581
Foam::token::END_STATEMENT
End entry [isseparator].
Definition: token.H:116
Foam::token::END_BLOCK
End block [isseparator].
Definition: token.H:122
Foam::token::tokenType
tokenType
Enumeration defining the types of token.
Definition: token.H:76
Foam::token::isWord
bool isWord() const
Token is WORD.
Definition: tokenI.H:552
Foam::string::null
static const string null
An empty string.
Definition: string.H:147
Foam::token::END_SQR
End dimensions [isseparator].
Definition: token.H:120
Foam::token::setType
bool setType(const tokenType variant)
Change the token type, for similar types.
Definition: tokenI.H:301
Foam::token::MULTIPLY
Multiply [isseparator].
Definition: token.H:134
Foam::token::operator==
bool operator==(const token &tok) const
Definition: tokenI.H:779
Foam::token::boolean
static token boolean(bool on)
Create a bool token.
Definition: tokenI.H:33
Foam::token::BEGIN_BLOCK
Begin block [isseparator].
Definition: token.H:121
Foam::token::wordToken
const word & wordToken() const
Return const reference to the word contents.
Definition: tokenI.H:558
Foam::token::swap
void swap(token &tok)
Swap token contents: type, data, line-number.
Definition: tokenI.H:282
Foam::token::type
tokenType type() const
Return the token type.
Definition: tokenI.H:295
Foam::token::isBool
bool isBool() const
Token is BOOL.
Definition: tokenI.H:386
Foam::token::COLON
Colon [isseparator].
Definition: token.H:123
Foam::token::scalarToken
scalar scalarToken() const
Return float or double value.
Definition: tokenI.H:514
Foam::token::isVerbatim
bool isVerbatim() const
Token is VERBATIM string.
Definition: tokenI.H:587
Foam::word::null
static const word null
An empty word.
Definition: word.H:77
Foam::token::doubleScalarToken
doubleScalar doubleScalarToken() const
Return double value.
Definition: tokenI.H:492
Foam::token::END_LIST
End list [isseparator].
Definition: token.H:118
Foam::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.
Foam::token::token
constexpr token() noexcept
Construct null, initialized to an UNDEFINED token.
Definition: tokenI.H:95
Foam::token::undefined
bool undefined() const
Token is UNDEFINED.
Definition: tokenI.H:374
Foam::token::flagToken
int flagToken() const
Return flag bitmask value.
Definition: tokenI.H:410
Foam::token::lineNumber
label lineNumber() const
The line number for the token.
Definition: tokenI.H:356
Foam::token::isPunctuation
bool isPunctuation() const
Token is PUNCTUATION.
Definition: tokenI.H:422
Foam::token::BEGIN_LIST
Begin list [isseparator].
Definition: token.H:117
Foam::equal
bool equal(const T &s1, const T &s2)
Compare two values for equality.
Definition: doubleFloat.H:46
Foam::token::isStringType
bool isStringType() const
Token is WORD, STRING, VARIABLE or VERBATIM.
Definition: tokenI.H:593
Foam::token::error
bool error() const
Token is ERROR.
Definition: tokenI.H:380
Foam::token::punctuationToken
punctuationToken
Standard punctuation tokens (a character)
Definition: token.H:109
Foam::token::operator=
void operator=(const token &tok)
Copy assign.
Definition: tokenI.H:648
Foam::token::ADD
Addition [isseparator].
Definition: token.H:132
Foam::token::setBad
void setBad()
Clear token and set to be ERROR.
Definition: tokenI.H:639