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