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-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
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::PLUS :
70  // Excluded token::MINUS 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::EXPRESSION:
125  case tokenType::VARIABLE:
126  case tokenType::VERBATIM:
127  {
128  data_.stringPtr = new string(*tok.data_.stringPtr);
129  break;
130  }
131 
132  case tokenType::COMPOUND:
133  {
134  // Identical pointers, but increase the refCount
135  data_.compoundPtr = tok.data_.compoundPtr;
136  data_.compoundPtr->refCount::operator++();
137  break;
138  }
139 
140  default:
141  break;
142  }
143 }
144 
145 
146 inline Foam::token::token(token&& tok) noexcept
147 :
148  data_(tok.data_), // bit-wise copy of union content
149  type_(tok.type_),
150  line_(tok.line_)
151 {
152  tok.setUndefined(); // zero the union content without any checking
153  tok.line_ = 0;
154 }
155 
156 
157 inline Foam::token::token(punctuationToken p, label lineNum) noexcept
158 :
159  data_(),
160  type_(tokenType::PUNCTUATION),
161  line_(lineNum)
162 {
163  data_.punctuationVal = p;
164 }
165 
166 
167 inline Foam::token::token(const label val, label lineNum) noexcept
168 :
169  data_(),
170  type_(tokenType::LABEL),
171  line_(lineNum)
172 {
173  data_.labelVal = val;
174 }
175 
176 
177 inline Foam::token::token(const floatScalar val, label lineNum) noexcept
178 :
179  data_(),
180  type_(tokenType::FLOAT),
181  line_(lineNum)
182 {
183  data_.floatVal = val;
184 }
185 
186 
187 inline Foam::token::token(const doubleScalar val, label lineNum) noexcept
188 :
189  data_(),
190  type_(tokenType::DOUBLE),
191  line_(lineNum)
192 {
193  data_.doubleVal = val;
194 }
195 
196 
197 inline Foam::token::token(const word& w, label lineNum)
198 :
199  data_(),
200  type_(tokenType::WORD),
201  line_(lineNum)
202 {
203  data_.wordPtr = new word(w);
204 }
205 
206 
207 inline Foam::token::token(const string& str, label lineNum)
208 :
209  data_(),
210  type_(tokenType::STRING),
211  line_(lineNum)
212 {
213  data_.stringPtr = new string(str);
214 }
215 
216 
217 inline Foam::token::token(word&& w, label lineNum)
218 :
219  data_(),
220  type_(tokenType::WORD),
221  line_(lineNum)
222 {
223  data_.wordPtr = new word(std::move(w));
224 }
225 
226 
227 inline Foam::token::token(string&& str, label lineNum)
228 :
229  data_(),
230  type_(tokenType::STRING),
231  line_(lineNum)
232 {
233  data_.stringPtr = new string(std::move(str));
234 }
235 
236 
237 inline Foam::token::token(token::compound* ptr, label lineNum)
238 :
239  data_(),
240  type_(tokenType::COMPOUND),
241  line_(lineNum)
242 {
243  data_.compoundPtr = ptr;
244 }
245 
246 
247 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
248 
250 {
251  reset();
252 }
253 
254 
255 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
256 
257 inline void Foam::token::reset()
258 {
259  switch (type_)
260  {
261  case tokenType::WORD:
262  case tokenType::DIRECTIVE:
263  {
264  delete data_.wordPtr;
265  break;
266  }
267 
268  case tokenType::STRING:
269  case tokenType::EXPRESSION:
270  case tokenType::VARIABLE:
271  case tokenType::VERBATIM:
272  {
273  delete data_.stringPtr;
274  break;
275  }
276 
277  case tokenType::COMPOUND:
278  {
279  if (data_.compoundPtr->unique())
280  {
281  delete data_.compoundPtr;
282  }
283  else
284  {
285  data_.compoundPtr->refCount::operator--();
286  }
287  break;
288  }
289 
290  default:
291  break;
292  }
293 
294  setUndefined();
295 }
296 
297 
298 inline void Foam::token::swap(token& tok)
299 {
300  if (this == &tok)
301  {
302  return; // Self-swap is a no-op
303  }
304 
305  std::swap(data_, tok.data_);
306  std::swap(type_, tok.type_);
307  std::swap(line_, tok.line_);
308 }
309 
310 
312 {
313  return type_;
314 }
315 
316 
317 inline bool Foam::token::setType(token::tokenType tokType) noexcept
318 {
319  if (type_ == tokType)
320  {
321  // No change required
322  return true;
323  }
324 
325  switch (tokType)
326  {
327  case tokenType::BOOL:
328  case tokenType::LABEL:
329  {
330  switch (type_)
331  {
332  case tokenType::BOOL:
333  case tokenType::LABEL:
334  type_ = tokType;
335  return true;
336  break;
337 
338  default:
339  break;
340  }
341  }
342  break;
343 
344  case tokenType::WORD:
345  case tokenType::DIRECTIVE:
346  {
347  switch (type_)
348  {
349  case tokenType::WORD:
350  case tokenType::DIRECTIVE:
351  type_ = tokType;
352  return true;
353  break;
354 
355  default:
356  break;
357  }
358  }
359  break;
360 
361  case tokenType::STRING:
362  case tokenType::EXPRESSION:
363  case tokenType::VARIABLE:
364  case tokenType::VERBATIM:
365  {
366  switch (type_)
367  {
368  // could also go from WORD to STRING etc - to be decided
369  case tokenType::STRING:
370  case tokenType::EXPRESSION:
371  case tokenType::VARIABLE:
372  case tokenType::VERBATIM:
373  type_ = tokType;
374  return true;
375  break;
376 
377  default:
378  break;
379  }
380  }
381  break;
382 
383  default:
384  break;
385  }
386 
387  return false;
388 }
389 
390 
391 inline Foam::label Foam::token::lineNumber() const noexcept
392 {
393  return line_;
394 }
395 
396 
397 inline Foam::label Foam::token::lineNumber(const label lineNum) noexcept
398 {
399  label old(line_);
400  line_ = lineNum;
401  return old;
402 }
403 
404 
405 inline bool Foam::token::good() const noexcept
406 {
407  return (type_ != tokenType::UNDEFINED && type_ != tokenType::ERROR);
408 }
409 
410 
411 inline bool Foam::token::undefined() const noexcept
412 {
413  return (type_ == tokenType::UNDEFINED);
414 }
415 
416 
417 inline bool Foam::token::error() const noexcept
418 {
419  return (type_ == tokenType::ERROR);
420 }
421 
422 
423 inline bool Foam::token::isBool() const noexcept
424 {
425  return (type_ == tokenType::BOOL);
426 }
427 
428 
429 inline bool Foam::token::boolToken() const
430 {
431  if (type_ == tokenType::BOOL || type_ == tokenType::LABEL)
432  {
433  return data_.labelVal;
434  }
435 
436  parseError("bool");
437  return false;
438 }
439 
440 
441 inline bool Foam::token::isFlag() const noexcept
442 {
443  return (type_ == tokenType::FLAG);
444 }
445 
446 
447 inline int Foam::token::flagToken() const
448 {
449  if (type_ == tokenType::FLAG)
450  {
451  return data_.flagVal;
452  }
453 
454  parseError("flag bitmask");
455  return NO_FLAG;
456 }
457 
458 
459 inline bool Foam::token::isPunctuation() const noexcept
460 {
461  return (type_ == tokenType::PUNCTUATION);
462 }
463 
464 
465 inline bool Foam::token::isPunctuation(const punctuationToken p) const noexcept
466 {
467  return
468  (
469  type_ == tokenType::PUNCTUATION
470  && data_.punctuationVal == p
471  );
472 }
473 
474 
475 inline bool Foam::token::isSeparator() const noexcept
476 {
477  return
478  (
479  type_ == tokenType::PUNCTUATION
480  && isseparator(data_.punctuationVal)
481  );
482 }
483 
484 
486 {
487  if (type_ == tokenType::PUNCTUATION)
488  {
489  return data_.punctuationVal;
490  }
491 
492  parseError("punctuation character");
493  return punctuationToken::NULL_TOKEN;
494 }
495 
496 
497 inline bool Foam::token::isLabel() const noexcept
498 {
499  return (type_ == tokenType::LABEL);
500 }
501 
502 
503 inline bool Foam::token::isLabel(const label val) const noexcept
504 {
505  return
506  (
507  type_ == tokenType::LABEL
508  && data_.labelVal == val
509  );
510 }
511 
512 
513 inline Foam::label Foam::token::labelToken() const
514 {
515  if (type_ == tokenType::LABEL)
516  {
517  return data_.labelVal;
518  }
519 
520  parseError("label");
521  return 0;
522 }
523 
524 
525 inline bool Foam::token::isFloat() const noexcept
526 {
527  return (type_ == tokenType::FLOAT);
528 }
529 
530 
532 {
533  if (type_ == tokenType::FLOAT)
534  {
535  return data_.floatVal;
536  }
537 
538  parseError("float");
539  return 0;
540 }
541 
542 
543 inline bool Foam::token::isDouble() const noexcept
544 {
545  return (type_ == tokenType::DOUBLE);
546 }
547 
548 
550 {
551  if (type_ == tokenType::DOUBLE)
552  {
553  return data_.doubleVal;
554  }
555 
556  parseError("double");
557  return 0;
558 }
559 
560 
561 inline bool Foam::token::isScalar() const noexcept
562 {
563  return
564  (
565  type_ == tokenType::FLOAT
566  || type_ == tokenType::DOUBLE
567  );
568 }
569 
570 
571 inline Foam::scalar Foam::token::scalarToken() const
572 {
573  if (type_ == tokenType::FLOAT)
574  {
575  return data_.floatVal;
576  }
577  else if (type_ == tokenType::DOUBLE)
578  {
579  return data_.doubleVal;
580  }
581 
582  parseError("scalar");
583  return 0;
584 }
585 
586 
587 inline bool Foam::token::isNumber() const noexcept
588 {
589  return (type_ == tokenType::LABEL || isScalar());
590 }
591 
592 
593 inline Foam::scalar Foam::token::number() const
594 {
595  if (isLabel())
596  {
597  return labelToken();
598  }
599  if (isScalar())
600  {
601  return scalarToken();
602  }
603 
604  parseError("number (label or scalar)");
605  return 0;
606 }
607 
608 
609 inline bool Foam::token::isWord() const noexcept
610 {
611  return
612  (
613  type_ == tokenType::WORD
614  || type_ == tokenType::DIRECTIVE
615  );
616 }
617 
618 
619 inline bool Foam::token::isWord(const std::string& s) const
620 {
621  return (isWord() && s == *data_.wordPtr);
622 }
623 
624 
625 inline bool Foam::token::isDirective() const noexcept
626 {
627  return (type_ == tokenType::DIRECTIVE);
628 }
629 
630 
631 inline const Foam::word& Foam::token::wordToken() const
632 {
633  if
634  (
635  type_ == tokenType::WORD
636  || type_ == tokenType::DIRECTIVE
637  )
638  {
639  return *data_.wordPtr;
640  }
641 
642  parseError("word");
643  return word::null;
644 }
645 
646 
647 inline bool Foam::token::isQuotedString() const noexcept
648 {
649  return (type_ == tokenType::STRING);
650 }
651 
652 
653 inline bool Foam::token::isString() const noexcept
654 {
655  return
656  (
657  type_ == tokenType::STRING
658  || type_ == tokenType::EXPRESSION
659  || type_ == tokenType::VARIABLE
660  || type_ == tokenType::VERBATIM
661  );
662 }
663 
664 
665 inline bool Foam::token::isExpression() const noexcept
666 {
667  return (type_ == tokenType::EXPRESSION);
668 }
669 
670 
671 inline bool Foam::token::isVariable() const noexcept
672 {
673  return (type_ == tokenType::VARIABLE);
674 }
675 
676 
677 inline bool Foam::token::isVerbatim() const noexcept
678 {
679  return (type_ == tokenType::VERBATIM);
680 }
681 
682 
683 inline bool Foam::token::isStringType() const noexcept
684 {
685  return (isWord() || isString());
686 }
687 
688 
690 {
691  if
692  (
693  type_ == tokenType::STRING
694  || type_ == tokenType::EXPRESSION
695  || type_ == tokenType::VARIABLE
696  || type_ == tokenType::VERBATIM
697  )
698  {
699  return *data_.stringPtr;
700  }
701  else if
702  (
703  type_ == tokenType::WORD
704  || type_ == tokenType::DIRECTIVE
705  )
706  {
707  // Foam::word derives from Foam::string, no need to cast.
708  return *data_.wordPtr;
709  }
710 
711  parseError("string");
712  return string::null;
713 }
714 
715 
716 inline bool Foam::token::isCompound() const noexcept
717 {
718  return (type_ == tokenType::COMPOUND);
719 }
720 
721 
723 {
724  if (type_ == tokenType::COMPOUND)
725  {
726  return *data_.compoundPtr;
727  }
728 
729  parseError("compound");
730  return *data_.compoundPtr; // This is questionable.
731 }
732 
733 
734 inline void Foam::token::setBad()
735 {
736  reset();
737  type_ = tokenType::ERROR;
738 }
739 
740 
741 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
742 
743 inline void Foam::token::operator=(const token& tok)
744 {
745  if (this == &tok)
746  {
747  return; // Self-assignment is a no-op
748  }
749 
750  reset();
751 
752  type_ = tok.type_;
753  data_ = tok.data_; // bit-wise copy of union content
754  line_ = tok.line_;
755 
756  // Fundamental: values already handled by bit-wise copy
757  // Pointer: duplicate content or increase refCount
758 
759  switch (type_)
760  {
761  case tokenType::WORD:
762  case tokenType::DIRECTIVE:
763  {
764  data_.wordPtr = new word(*tok.data_.wordPtr);
765  }
766  break;
767 
768  case tokenType::STRING:
769  case tokenType::EXPRESSION:
770  case tokenType::VARIABLE:
771  case tokenType::VERBATIM:
772  {
773  data_.stringPtr = new string(*tok.data_.stringPtr);
774  }
775  break;
776 
777  case tokenType::COMPOUND:
778  {
779  // Identical pointers, but increase the refCount
780  data_.compoundPtr = tok.data_.compoundPtr;
781  data_.compoundPtr->refCount::operator++();
782  }
783  break;
784 
785  default:
786  break;
787  }
788 }
789 
790 
791 inline void Foam::token::operator=(token&& tok)
792 {
793  if (this == &tok)
794  {
795  return; // Self-assignment is a no-op
796  }
797 
798  reset();
799  line_ = 0;
800  swap(tok);
801 }
802 
803 
805 {
806  reset();
807  type_ = tokenType::PUNCTUATION;
808  data_.punctuationVal = p;
809 }
810 
811 
812 inline void Foam::token::operator=(const label val)
813 {
814  reset();
815  type_ = tokenType::LABEL;
816  data_.labelVal = val;
817 }
818 
819 
820 inline void Foam::token::operator=(const floatScalar val)
821 {
822  reset();
823  type_ = tokenType::FLOAT;
824  data_.floatVal = val;
825 }
826 
827 
828 inline void Foam::token::operator=(const doubleScalar val)
829 {
830  reset();
831  type_ = tokenType::DOUBLE;
832  data_.doubleVal = val;
833 }
834 
835 
836 inline void Foam::token::operator=(const word& w)
837 {
838  reset();
839  type_ = tokenType::WORD;
840  data_.wordPtr = new word(w);
841 }
842 
843 
844 inline void Foam::token::operator=(const string& str)
845 {
846  reset();
847  type_ = tokenType::STRING;
848  data_.stringPtr = new string(str);
849 }
850 
851 
852 inline void Foam::token::operator=(word&& w)
853 {
854  reset();
855  type_ = tokenType::WORD;
856  data_.wordPtr = new word(std::move(w));
857 }
858 
859 
860 inline void Foam::token::operator=(string&& s)
861 {
862  reset();
863  type_ = tokenType::STRING;
864  data_.stringPtr = new string(std::move(s));
865 }
866 
867 
869 {
870  reset();
871  type_ = tokenType::COMPOUND;
872  data_.compoundPtr = ptr;
873 }
874 
875 
877 {
878  reset();
879  type_ = tokenType::COMPOUND;
880  data_.compoundPtr = ptr.release();
881 }
882 
883 
884 inline bool Foam::token::operator==(const token& tok) const
885 {
886  if (type_ != tok.type_)
887  {
888  return false;
889  }
890 
891  switch (type_)
892  {
893  case tokenType::UNDEFINED:
894  return true;
895 
896  case tokenType::BOOL:
897  return data_.labelVal == tok.data_.labelVal;
898 
899  case tokenType::FLAG:
900  return data_.flagVal == tok.data_.flagVal;
901 
902  case tokenType::PUNCTUATION:
903  return data_.punctuationVal == tok.data_.punctuationVal;
904 
905  case tokenType::LABEL:
906  return data_.labelVal == tok.data_.labelVal;
907 
908  case tokenType::FLOAT:
909  return equal(data_.floatVal, tok.data_.floatVal);
910 
911  case tokenType::DOUBLE:
912  return equal(data_.doubleVal, tok.data_.doubleVal);
913 
914  case tokenType::WORD:
915  case tokenType::DIRECTIVE:
916  return *data_.wordPtr == *tok.data_.wordPtr;
917 
918  case tokenType::STRING:
919  case tokenType::EXPRESSION:
920  case tokenType::VARIABLE:
921  case tokenType::VERBATIM:
922  return *data_.stringPtr == *tok.data_.stringPtr;
923 
924  case tokenType::COMPOUND:
925  return data_.compoundPtr == tok.data_.compoundPtr;
926 
927  case tokenType::ERROR:
928  return true;
929  }
930 
931  return false;
932 }
933 
934 
935 inline bool Foam::token::operator==(const punctuationToken p) const noexcept
936 {
937  return isPunctuation(p);
938 }
939 
940 
941 inline bool Foam::token::operator==(const std::string& s) const
942 {
943  return
944  (
945  isWord()
946  ? s == *data_.wordPtr
947  : isString() && s == *data_.stringPtr
948  );
949 }
950 
951 
952 inline bool Foam::token::operator==(const label val) const noexcept
953 {
954  return isLabel(val);
955 }
956 
957 
958 inline bool Foam::token::operator==(const floatScalar val) const noexcept
959 {
960  return
961  (
962  type_ == tokenType::FLOAT
963  && equal(data_.floatVal, val)
964  );
965 }
966 
967 
968 inline bool Foam::token::operator==(const doubleScalar val) const noexcept
969 {
970  return
971  (
972  type_ == tokenType::DOUBLE
973  && equal(data_.doubleVal, val)
974  );
975 }
976 
977 
978 inline bool Foam::token::operator!=(const token& tok) const
979 {
980  return !operator==(tok);
981 }
982 
983 
984 inline bool Foam::token::operator!=(const punctuationToken p) const noexcept
985 {
986  return !isPunctuation(p);
987 }
988 
989 
990 inline bool Foam::token::operator!=(const label val) const noexcept
991 {
992  return !operator==(val);
993 }
994 
995 
996 inline bool Foam::token::operator!=(const floatScalar val) const noexcept
997 {
998  return !operator==(val);
999 }
1000 
1001 
1002 inline bool Foam::token::operator!=(const doubleScalar val) const noexcept
1003 {
1004  return !operator==(val);
1005 }
1006 
1007 
1008 inline bool Foam::token::operator!=(const std::string& s) const
1009 {
1010  return !operator==(s);
1011 }
1012 
1013 
1014 // ************************************************************************* //
Foam::token::labelToken
label labelToken() const
Return label value.
Definition: tokenI.H:513
Foam::doubleScalar
double doubleScalar
A typedef for double.
Definition: scalarFwd.H:48
Foam::token::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:497
Foam::token::compound
Abstract base class for complex tokens.
Definition: token.H:168
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::token::isBool
bool isBool() const noexcept
Token is BOOL.
Definition: tokenI.H:423
s
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Definition: gmvOutputSpray.H:25
Foam::token::isDouble
bool isDouble() const noexcept
Token is DOUBLE.
Definition: tokenI.H:543
Foam::token::lineNumber
label lineNumber() const noexcept
The line number for the token.
Definition: tokenI.H:391
Foam::token::stringToken
const string & stringToken() const
Return const reference to the string contents.
Definition: tokenI.H:689
Foam::floatScalar
float floatScalar
A typedef for float.
Definition: scalarFwd.H:45
Foam::token::isStringType
bool isStringType() const noexcept
Definition: tokenI.H:683
Foam::token::isExpression
bool isExpression() const noexcept
Token is EXPRESSION (string variant)
Definition: tokenI.H:665
Foam::token::boolToken
bool boolToken() const
Return boolean token value.
Definition: tokenI.H:429
Foam::token::isseparator
static bool isseparator(int c) noexcept
True if the character is a punctuation separator (eg, in ISstream).
Definition: tokenI.H:53
Foam::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:525
Foam::token::isQuotedString
bool isQuotedString() const noexcept
Token is (quoted) STRING (string variant)
Definition: tokenI.H:647
Foam::token::compoundToken
const compound & compoundToken() const
Read access for compound token.
Definition: tokenI.H:722
Foam::string
A class for handling character strings derived from std::string.
Definition: string.H:76
Foam::token::pToken
punctuationToken pToken() const
Return punctuation character.
Definition: tokenI.H:485
Foam::token::isVariable
bool isVariable() const noexcept
Token is VARIABLE (string variant)
Definition: tokenI.H:671
Foam::token::isWord
bool isWord() const noexcept
Token is word-variant (WORD, DIRECTIVE)
Definition: tokenI.H:609
Foam::token::isNumber
bool isNumber() const noexcept
Token is LABEL, FLOAT or DOUBLE.
Definition: tokenI.H:587
Foam::token::number
scalar number() const
Return label, float or double value.
Definition: tokenI.H:593
Foam::operator==
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
Foam::token::~token
~token()
Destructor.
Definition: tokenI.H:249
Foam::token::operator!=
bool operator!=(const token &tok) const
Definition: tokenI.H:978
Foam::token::reset
void reset()
Reset token to UNDEFINED and clear any allocated storage.
Definition: tokenI.H:257
Foam::token::isPunctuation
bool isPunctuation() const noexcept
Token is PUNCTUATION.
Definition: tokenI.H:459
Foam::token::isFlag
bool isFlag() const noexcept
Token is FLAG.
Definition: tokenI.H:441
Foam::token::isSeparator
bool isSeparator() const noexcept
Token is PUNCTUATION and isseparator.
Definition: tokenI.H:475
Foam::string::null
static const string null
An empty string.
Definition: string.H:169
Foam::token::error
bool error() const noexcept
Token is ERROR.
Definition: tokenI.H:417
Foam::token::isScalar
bool isScalar() const noexcept
Token is FLOAT or DOUBLE.
Definition: tokenI.H:561
Foam::token::operator==
bool operator==(const token &tok) const
Definition: tokenI.H:884
Foam::token::floatToken
floatScalar floatToken() const
Return float value.
Definition: tokenI.H:531
Foam::token::doubleToken
doubleScalar doubleToken() const
Return double value.
Definition: tokenI.H:549
Foam::token::wordToken
const word & wordToken() const
Return const reference to the word contents.
Definition: tokenI.H:631
Foam::token::isDirective
bool isDirective() const noexcept
Token is DIRECTIVE (word variant)
Definition: tokenI.H:625
reset
meshPtr reset(new Foam::fvMesh(Foam::IOobject(regionName, runTime.timeName(), runTime, Foam::IOobject::MUST_READ), false))
Foam::token::good
bool good() const noexcept
True if token is not UNDEFINED or ERROR.
Definition: tokenI.H:405
Foam::token::swap
void swap(token &tok)
Swap token contents: type, data, line-number.
Definition: tokenI.H:298
Foam::token::isVerbatim
bool isVerbatim() const noexcept
Token is VERBATIM string (string variant)
Definition: tokenI.H:677
Foam::token::type
tokenType type() const noexcept
Return the token type.
Definition: tokenI.H:311
Foam::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:571
Foam::token::flag
static token flag(int bitmask) noexcept
Create a token with stream flags, no sanity check.
Definition: tokenI.H:43
Foam::token::undefined
bool undefined() const noexcept
Token is UNDEFINED.
Definition: tokenI.H:411
Foam::token::tokenType
tokenType
Enumeration defining the types of token.
Definition: token.H:76
Foam::token::isString
bool isString() const noexcept
Token is string-variant (STRING, EXPRESSION, VARIABLE, VERBATIM)
Definition: tokenI.H:653
Foam::word::null
static const word null
An empty word.
Definition: word.H:80
Foam::token::isCompound
bool isCompound() const noexcept
Token is COMPOUND.
Definition: tokenI.H:716
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:447
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:317
Foam::token::punctuationToken
punctuationToken
Standard punctuation tokens (a character)
Definition: token.H:120
Foam::token::operator=
void operator=(const token &tok)
Copy assign.
Definition: tokenI.H:743
Foam::token::setBad
void setBad()
Clear token and set to be ERROR.
Definition: tokenI.H:734