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