tokenI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include <iostream>
27 #include "token.H"
28 
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 
31 inline void Foam::token::clear()
32 {
33  if (type_ == WORD)
34  {
35  delete wordTokenPtr_;
36  }
37  else if (type_ == FUNCTIONNAME)
38  {
39  delete functionNameTokenPtr_;
40  }
41  else if (type_ == VARIABLE)
42  {
43  delete variableTokenPtr_;
44  }
45  else if (type_ == STRING)
46  {
47  delete stringTokenPtr_;
48  }
49  else if (type_ == VERBATIMSTRING)
50  {
52  }
53  else if (type_ == LONG_DOUBLE_SCALAR)
54  {
56  }
57  else if (type_ == COMPOUND)
58  {
60  {
61  delete compoundTokenPtr_;
62  }
63  else
64  {
65  compoundTokenPtr_->refCount::operator--();
66  }
67  }
68 
69  type_ = UNDEFINED;
70 }
71 
72 
73 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
74 
76 :
77  type_(UNDEFINED),
78  lineNumber_(0)
79 {}
80 
81 
82 inline Foam::token::token(const token& t)
83 :
84  type_(t.type_),
85  lineNumber_(t.lineNumber_)
86 {
87  switch (type_)
88  {
89  case token::UNDEFINED:
90  break;
91 
92  case PUNCTUATION:
94  break;
95 
96  case WORD:
98  break;
99 
100  case FUNCTIONNAME:
102  break;
103 
104  case VARIABLE:
106  break;
107 
108  case STRING:
110  break;
111 
112  case VERBATIMSTRING:
115  break;
116 
117  case INTEGER_32:
119  break;
120 
121  case INTEGER_64:
123  break;
124 
125  case UNSIGNED_INTEGER_32:
127  break;
128 
129  case UNSIGNED_INTEGER_64:
131  break;
132 
133  case FLOAT_SCALAR:
135  break;
136 
137  case DOUBLE_SCALAR:
139  break;
140 
141  case LONG_DOUBLE_SCALAR:
144  break;
145 
146  case COMPOUND:
148  compoundTokenPtr_->refCount::operator++();
149  break;
150 
151  case token::ERROR:
152  break;
153  }
154 }
155 
156 
158 :
159  type_(PUNCTUATION),
160  punctuationToken_(p),
161  lineNumber_(lineNumber)
162 {}
163 
164 
165 inline Foam::token::token(const word& w, label lineNumber)
166 :
167  type_(WORD),
168  wordTokenPtr_(new word(w)),
169  lineNumber_(lineNumber)
170 {}
171 
172 
173 inline Foam::token::token(const string& s, label lineNumber)
174 :
175  type_(STRING),
176  stringTokenPtr_(new string(s)),
177  lineNumber_(lineNumber)
178 {}
179 
180 
181 inline Foam::token::token(const verbatimString& vs, label lineNumber)
182 :
183  type_(VERBATIMSTRING),
184  verbatimStringTokenPtr_(new verbatimString(vs)),
185  lineNumber_(lineNumber)
186 {}
187 
188 
189 inline Foam::token::token(const int32_t l, label lineNumber)
190 :
191  type_(INTEGER_32),
192  integer32Token_(l),
193  lineNumber_(lineNumber)
194 {}
195 
196 
197 inline Foam::token::token(const int64_t l, label lineNumber)
198 :
199  type_(INTEGER_64),
200  integer64Token_(l),
201  lineNumber_(lineNumber)
202 {}
203 
204 
205 inline Foam::token::token(const uint32_t l, label lineNumber)
206 :
207  type_(UNSIGNED_INTEGER_32),
208  unsignedInteger32Token_(l),
209  lineNumber_(lineNumber)
210 {}
211 
212 
213 inline Foam::token::token(const uint64_t l, label lineNumber)
214 :
215  type_(UNSIGNED_INTEGER_64),
216  unsignedInteger64Token_(l),
217  lineNumber_(lineNumber)
218 {}
219 
220 
221 inline Foam::token::token(const floatScalar s, label lineNumber)
222 :
223  type_(FLOAT_SCALAR),
224  floatScalarToken_(s),
225  lineNumber_(lineNumber)
226 {}
227 
228 
229 inline Foam::token::token(const doubleScalar s, label lineNumber)
230 :
231  type_(DOUBLE_SCALAR),
232  doubleScalarToken_(s),
233  lineNumber_(lineNumber)
234 {}
235 
236 
237 inline Foam::token::token(const longDoubleScalar s, label lineNumber)
238 :
239  type_(LONG_DOUBLE_SCALAR),
240  longDoubleScalarTokenPtr_(new longDoubleScalar(s)),
241  lineNumber_(lineNumber)
242 {}
243 
244 
245 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
246 
248 {
249  clear();
250 }
251 
252 
253 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
254 
256 {
257  return type_;
258 }
259 
261 {
262  return type_;
263 }
264 
265 inline bool Foam::token::good() const
266 {
267  return (type_ != ERROR && type_ != UNDEFINED);
268 }
269 
270 inline bool Foam::token::undefined() const
271 {
272  return (type_ == UNDEFINED);
273 }
274 
275 inline bool Foam::token::error() const
276 {
277  return (type_ == ERROR);
278 }
279 
280 inline bool Foam::token::isPunctuation() const
281 {
282  return (type_ == PUNCTUATION);
283 }
284 
286 {
287  if (type_ == PUNCTUATION)
288  {
289  return punctuationToken_;
290  }
291  else
292  {
293  parseError("punctuation character");
294  return NULL_TOKEN;
295  }
296 }
297 
298 inline bool Foam::token::isWord() const
299 {
300  return (type_ == WORD);
301 }
302 
303 inline const Foam::word& Foam::token::wordToken() const
304 {
305  if (type_ == WORD)
306  {
307  return *wordTokenPtr_;
308  }
309  else
310  {
311  parseError(word::typeName);
312  return word::null;
313  }
314 }
315 
316 inline bool Foam::token::isFunctionName() const
317 {
318  return (type_ == FUNCTIONNAME);
319 }
320 
322 {
323  if (type_ == FUNCTIONNAME)
324  {
325  return *functionNameTokenPtr_;
326  }
327  else
328  {
329  parseError(functionName::typeName);
330  return functionName::null;
331  }
332 }
333 
334 inline bool Foam::token::isVariable() const
335 {
336  return (type_ == VARIABLE);
337 }
338 
340 {
341  if (type_ == VARIABLE)
342  {
343  return *variableTokenPtr_;
344  }
345  else
346  {
347  parseError(variable::typeName);
348  return variable::null;
349  }
350 }
351 
352 inline bool Foam::token::isString() const
353 {
354  return (type_ == STRING);
355 }
356 
358 {
359  if (type_ == STRING)
360  {
361  return *stringTokenPtr_;
362  }
363  else
364  {
365  parseError(string::typeName);
366  return string::null;
367  }
368 }
369 
370 inline bool Foam::token::isVerbatimString() const
371 {
372  return (type_ == VERBATIMSTRING);
373 }
374 
376 {
377  if (type_ == VERBATIMSTRING)
378  {
379  return *verbatimStringTokenPtr_;
380  }
381  else
382  {
383  parseError(verbatimString::typeName);
384  return verbatimString::null;
385  }
386 }
387 
388 inline bool Foam::token::isAnyString() const
389 {
390  return
391  (
392  type_ == WORD
393  || type_ == FUNCTIONNAME
394  || type_ == VARIABLE
395  || type_ == STRING
396  || type_ == VERBATIMSTRING
397  );
398 }
399 
401 {
402  if (type_ == WORD)
403  {
404  return *wordTokenPtr_;
405  }
406  else if (type_ == FUNCTIONNAME)
407  {
408  return *functionNameTokenPtr_;
409  }
410  else if (type_ == VARIABLE)
411  {
412  return *variableTokenPtr_;
413  }
414  else if (type_ == STRING)
415  {
416  return *stringTokenPtr_;
417  }
418  else if (type_ == VERBATIMSTRING)
419  {
420  return *verbatimStringTokenPtr_;
421  }
422  else
423  {
424  parseError(string::typeName);
425  return string::null;
426  }
427 }
428 
429 inline bool Foam::token::isInteger32() const
430 {
431  return
432  type_ == INTEGER_32
433  || (
434  type_ == INTEGER_64
435  && (integer64Token_ >= INT32_MIN) && (integer64Token_ <= INT32_MAX)
436  )
437  || (type_ == UNSIGNED_INTEGER_32 && unsignedInteger32Token_ <= INT32_MAX)
438  || (type_ == UNSIGNED_INTEGER_64 && unsignedInteger64Token_ <= INT32_MAX);
439 }
440 
441 inline int32_t Foam::token::integer32Token() const
442 {
443  if (type_ == INTEGER_32)
444  {
445  return integer32Token_;
446  }
447  else if (type_ == INTEGER_64)
448  {
449  return integer64Token_;
450  }
451  if (type_ == UNSIGNED_INTEGER_32)
452  {
453  return unsignedInteger32Token_;
454  }
455  else if (type_ == UNSIGNED_INTEGER_64)
456  {
457  return unsignedInteger64Token_;
458  }
459  else
460  {
461  parseError(pTraits<int32_t>::typeName);
462  return 0;
463  }
464 }
465 
466 inline bool Foam::token::isInteger64() const
467 {
468  return
469  type_ == INTEGER_32
470  || type_ == INTEGER_64
471  || type_ == UNSIGNED_INTEGER_32
472  || (type_ == UNSIGNED_INTEGER_64 && unsignedInteger64Token_ <= INT64_MAX);
473 }
474 
475 inline int64_t Foam::token::integer64Token() const
476 {
477  if (type_ == INTEGER_32)
478  {
479  return integer32Token_;
480  }
481  else if (type_ == INTEGER_64)
482  {
483  return integer64Token_;
484  }
485  if (type_ == UNSIGNED_INTEGER_32)
486  {
487  return unsignedInteger32Token_;
488  }
489  else if (type_ == UNSIGNED_INTEGER_64)
490  {
491  return unsignedInteger64Token_;
492  }
493  else
494  {
495  parseError(pTraits<int64_t>::typeName);
496  return 0;
497  }
498 }
499 
501 {
502  return
503  (type_ == INTEGER_32 && integer32Token_ >= 0)
504  || (
505  type_ == INTEGER_64
506  && (integer64Token_ >= 0) && (integer64Token_ <= UINT32_MAX)
507  )
508  || type_ == UNSIGNED_INTEGER_32
509  || (type_ == UNSIGNED_INTEGER_64 && unsignedInteger64Token_ <= UINT32_MAX);
510 }
511 
512 inline uint32_t Foam::token::unsignedInteger32Token() const
513 {
514  if (type_ == INTEGER_32)
515  {
516  return integer32Token_;
517  }
518  else if (type_ == INTEGER_64)
519  {
520  return integer64Token_;
521  }
522  if (type_ == UNSIGNED_INTEGER_32)
523  {
524  return unsignedInteger32Token_;
525  }
526  else if (type_ == UNSIGNED_INTEGER_64)
527  {
528  return unsignedInteger64Token_;
529  }
530  else
531  {
532  parseError(pTraits<uint32_t>::typeName);
533  return 0;
534  }
535 }
536 
538 {
539  return
540  (type_ == INTEGER_32 && integer32Token_ >= 0)
541  || (type_ == INTEGER_64 && integer64Token_ >= 0)
542  || type_ == UNSIGNED_INTEGER_32
543  || type_ == UNSIGNED_INTEGER_64;
544 }
545 
546 inline uint64_t Foam::token::unsignedInteger64Token() const
547 {
548  if (type_ == INTEGER_32)
549  {
550  return integer32Token_;
551  }
552  else if (type_ == INTEGER_64)
553  {
554  return integer64Token_;
555  }
556  if (type_ == UNSIGNED_INTEGER_32)
557  {
558  return unsignedInteger32Token_;
559  }
560  else if (type_ == UNSIGNED_INTEGER_64)
561  {
562  return unsignedInteger64Token_;
563  }
564  else
565  {
566  parseError(pTraits<uint64_t>::typeName);
567  return 0;
568  }
569 }
570 
571 inline bool Foam::token::isLabel() const
572 {
573  return
574  type_ == INTEGER_32
575  || (
576  type_ == INTEGER_64
577  && integer64Token_ >= int64_t(labelMin)
578  && integer64Token_ <= int64_t(labelMax)
579  )
580  || (
581  type_ == UNSIGNED_INTEGER_32
582  && uint64_t(unsignedInteger32Token_) <= uint64_t(labelMax)
583  )
584  || (
585  type_ == UNSIGNED_INTEGER_64
586  && unsignedInteger64Token_ <= uint64_t(labelMax)
587  );
588 }
589 
591 {
592  if (type_ == INTEGER_32)
593  {
594  return integer32Token_;
595  }
596  else if (type_ == INTEGER_64)
597  {
598  return integer64Token_;
599  }
600  if (type_ == UNSIGNED_INTEGER_32)
601  {
602  return unsignedInteger32Token_;
603  }
604  else if (type_ == UNSIGNED_INTEGER_64)
605  {
606  return unsignedInteger64Token_;
607  }
608  else
609  {
610  parseError(pTraits<label>::typeName);
611  return 0;
612  }
613 }
614 
615 inline bool Foam::token::isULabel() const
616 {
617  return
618  (
619  type_ == INTEGER_32
620  && integer32Token_ >= 0
621  )
622  || (
623  type_ == INTEGER_64
624  && integer64Token_ >= 0
625  && uint64_t(integer64Token_) <= uint64_t(uLabelMax)
626  )
627  || type_ == UNSIGNED_INTEGER_32
628  || (
629  type_ == UNSIGNED_INTEGER_64
630  && unsignedInteger64Token_ <= uint64_t(uLabelMax)
631  );
632 }
633 
635 {
636  if (type_ == INTEGER_32)
637  {
638  return integer32Token_;
639  }
640  else if (type_ == INTEGER_64)
641  {
642  return integer64Token_;
643  }
644  if (type_ == UNSIGNED_INTEGER_32)
645  {
646  return unsignedInteger32Token_;
647  }
648  else if (type_ == UNSIGNED_INTEGER_64)
649  {
650  return unsignedInteger64Token_;
651  }
652  else
653  {
654  parseError(pTraits<uLabel>::typeName);
655  return 0;
656  }
657 }
658 
659 inline bool Foam::token::isFloatScalar() const
660 {
661  return (type_ == FLOAT_SCALAR);
662 }
663 
665 {
666  if (type_ == FLOAT_SCALAR)
667  {
668  return floatScalarToken_;
669  }
670  else
671  {
672  parseError("floatScalar");
673  return 0.0;
674  }
675 }
676 
677 
678 inline bool Foam::token::isDoubleScalar() const
679 {
680  return (type_ == DOUBLE_SCALAR);
681 }
682 
684 {
685  if (type_ == DOUBLE_SCALAR)
686  {
687  return doubleScalarToken_;
688  }
689  else
690  {
691  parseError("doubleScalar");
692  return 0.0;
693  }
694 }
695 
696 
698 {
699  return (type_ == LONG_DOUBLE_SCALAR);
700 }
701 
703 {
704  if (type_ == LONG_DOUBLE_SCALAR)
705  {
706  return *longDoubleScalarTokenPtr_;
707  }
708  else
709  {
710  parseError("longDoubleScalar");
711  return 0.0;
712  }
713 }
714 
715 
716 inline bool Foam::token::isScalar() const
717 {
718  return
719  type_ == FLOAT_SCALAR
720  || type_ == DOUBLE_SCALAR
721  || type_ == LONG_DOUBLE_SCALAR;
722 }
723 
724 inline Foam::scalar Foam::token::scalarToken() const
725 {
726  if (type_ == FLOAT_SCALAR)
727  {
728  return floatScalarToken_;
729  }
730  else if (type_ == DOUBLE_SCALAR)
731  {
732  return doubleScalarToken_;
733  }
734  else if (type_ == LONG_DOUBLE_SCALAR)
735  {
736  return *longDoubleScalarTokenPtr_;
737  }
738  else
739  {
740  parseError(pTraits<scalar>::typeName);
741  return 0.0;
742  }
743 }
744 
745 inline bool Foam::token::isNumber() const
746 {
747  return
748  type_ == INTEGER_32
749  || type_ == INTEGER_64
750  || type_ == UNSIGNED_INTEGER_32
751  || type_ == UNSIGNED_INTEGER_64
752  || isScalar();
753 }
754 
755 inline Foam::scalar Foam::token::number() const
756 {
757  if (type_ == INTEGER_32)
758  {
759  return integer32Token_;
760  }
761  else if (type_ == INTEGER_64)
762  {
763  return integer64Token_;
764  }
765  if (type_ == UNSIGNED_INTEGER_32)
766  {
767  return unsignedInteger32Token_;
768  }
769  else if (type_ == UNSIGNED_INTEGER_64)
770  {
771  return unsignedInteger64Token_;
772  }
773  else if (isScalar())
774  {
775  return scalarToken();
776  }
777  else
778  {
779  parseError("number (label or scalar)");
780  return 0.0;
781  }
782 }
783 
784 inline bool Foam::token::isCompound() const
785 {
786  return (type_ == COMPOUND);
787 }
788 
790 {
791  if (type_ == COMPOUND)
792  {
793  return *compoundTokenPtr_;
794  }
795  else
796  {
797  parseError("compound");
798  return *compoundTokenPtr_;
799  }
800 }
801 
802 
804 {
805  return lineNumber_;
806 }
807 
809 {
810  return lineNumber_;
811 }
812 
813 
814 inline void Foam::token::setBad()
815 {
816  clear();
817  type_ = ERROR;
818 }
819 
820 
821 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
822 
823 inline void Foam::token::operator=(const token& t)
824 {
825  clear();
826  type_ = t.type_;
827 
828  switch (type_)
829  {
830  case token::UNDEFINED:
831  break;
832 
833  case PUNCTUATION:
834  punctuationToken_ = t.punctuationToken_;
835  break;
836 
837  case WORD:
838  wordTokenPtr_ = new word(*t.wordTokenPtr_);
839  break;
840 
841  case FUNCTIONNAME:
842  functionNameTokenPtr_ = new functionName(*t.functionNameTokenPtr_);
843  break;
844 
845  case VARIABLE:
846  variableTokenPtr_ = new variable(*t.variableTokenPtr_);
847  break;
848 
849  case STRING:
850  stringTokenPtr_ = new string(*t.stringTokenPtr_);
851  break;
852 
853  case VERBATIMSTRING:
854  verbatimStringTokenPtr_ =
856  break;
857 
858  case INTEGER_32:
859  integer32Token_ = t.integer32Token_;
860  break;
861 
862  case INTEGER_64:
863  integer64Token_ = t.integer64Token_;
864  break;
865 
866  case UNSIGNED_INTEGER_32:
867  unsignedInteger32Token_ = t.unsignedInteger32Token_;
868  break;
869 
870  case UNSIGNED_INTEGER_64:
871  unsignedInteger64Token_ = t.unsignedInteger64Token_;
872  break;
873 
874  case FLOAT_SCALAR:
875  floatScalarToken_ = t.floatScalarToken_;
876  break;
877 
878  case DOUBLE_SCALAR:
879  doubleScalarToken_ = t.doubleScalarToken_;
880  break;
881 
882  case LONG_DOUBLE_SCALAR:
883  longDoubleScalarTokenPtr_ =
885  break;
886 
887  case COMPOUND:
888  compoundTokenPtr_ = t.compoundTokenPtr_;
889  compoundTokenPtr_->refCount::operator++();
890  break;
891 
892  case token::ERROR:
893  break;
894  }
895 
896  lineNumber_ = t.lineNumber_;
897 }
898 
900 {
901  clear();
902  type_ = PUNCTUATION;
903  punctuationToken_ = p;
904 }
905 
906 inline void Foam::token::operator=(word* wPtr)
907 {
908  clear();
909  type_ = WORD;
910  wordTokenPtr_ = wPtr;
911 }
912 
913 inline void Foam::token::operator=(const word& w)
914 {
915  operator=(new word(w));
916 }
917 
919 {
920  clear();
921  type_ = FUNCTIONNAME;
922  functionNameTokenPtr_ = fnPtr;
923 }
924 
925 inline void Foam::token::operator=(const functionName& fn)
926 {
927  operator=(new functionName(fn));
928 }
929 
931 {
932  clear();
933  type_ = VARIABLE;
934  variableTokenPtr_ = vPtr;
935 }
936 
937 inline void Foam::token::operator=(const variable& v)
938 {
939  operator=(new variable(v));
940 }
941 
942 inline void Foam::token::operator=(string* sPtr)
943 {
944  clear();
945  type_ = STRING;
946  stringTokenPtr_ = sPtr;
947 }
948 
949 inline void Foam::token::operator=(const string& s)
950 {
951  operator=(new string(s));
952 }
953 
955 {
956  clear();
957  type_ = VERBATIMSTRING;
958  verbatimStringTokenPtr_ = vsPtr;
959 }
960 
962 {
963  operator=(new verbatimString(vs));
964 }
965 
966 inline void Foam::token::operator=(const int32_t l)
967 {
968  clear();
969  type_ = INTEGER_32;
970  integer32Token_ = l;
971 }
972 
973 inline void Foam::token::operator=(const int64_t l)
974 {
975  clear();
976  type_ = INTEGER_64;
977  integer64Token_ = l;
978 }
979 
980 inline void Foam::token::operator=(const uint32_t l)
981 {
982  clear();
983  type_ = UNSIGNED_INTEGER_32;
984  unsignedInteger32Token_ = l;
985 }
986 
987 inline void Foam::token::operator=(const uint64_t l)
988 {
989  clear();
990  type_ = UNSIGNED_INTEGER_64;
991  unsignedInteger64Token_ = l;
992 }
993 
995 {
996  clear();
997  type_ = FLOAT_SCALAR;
998  floatScalarToken_ = s;
999 }
1000 
1002 {
1003  clear();
1004  type_ = DOUBLE_SCALAR;
1005  doubleScalarToken_ = s;
1006 }
1007 
1009 {
1010  clear();
1011  type_ = LONG_DOUBLE_SCALAR;
1012  longDoubleScalarTokenPtr_ = new longDoubleScalar(s);
1013 }
1014 
1016 {
1017  clear();
1018  type_ = COMPOUND;
1019  compoundTokenPtr_ = cPtr;
1020 }
1021 
1022 
1023 inline bool Foam::token::operator==(const token& t) const
1024 {
1025  if (type_ != t.type_)
1026  {
1027  return false;
1028  }
1029 
1030  switch (type_)
1031  {
1032  case token::UNDEFINED:
1033  return true;
1034 
1035  case PUNCTUATION:
1036  return punctuationToken_ == t.punctuationToken_;
1037 
1038  case WORD:
1039  return *wordTokenPtr_ == *t.wordTokenPtr_;
1040 
1041  case FUNCTIONNAME:
1042  return *functionNameTokenPtr_ == *t.functionNameTokenPtr_;
1043 
1044  case VARIABLE:
1045  return *variableTokenPtr_ == *t.variableTokenPtr_;
1046 
1047  case STRING:
1048  return *stringTokenPtr_ == *t.stringTokenPtr_;
1049 
1050  case VERBATIMSTRING:
1051  return *verbatimStringTokenPtr_ == *t.verbatimStringTokenPtr_;
1052 
1053  case INTEGER_32:
1054  return integer32Token_ == t.integer32Token_;
1055 
1056  case INTEGER_64:
1057  return integer64Token_ == t.integer64Token_;
1058 
1059  case UNSIGNED_INTEGER_32:
1060  return unsignedInteger32Token_ == t.unsignedInteger32Token_;
1061 
1062  case UNSIGNED_INTEGER_64:
1063  return unsignedInteger64Token_ == t.unsignedInteger64Token_;
1064 
1065  case FLOAT_SCALAR:
1066  return equal(floatScalarToken_, t.floatScalarToken_);
1067 
1068  case DOUBLE_SCALAR:
1069  return equal(doubleScalarToken_, t.doubleScalarToken_);
1070 
1071  case LONG_DOUBLE_SCALAR:
1072  return equal
1073  (
1074  *longDoubleScalarTokenPtr_,
1076  );
1077 
1078  case COMPOUND:
1079  return compoundTokenPtr_ == t.compoundTokenPtr_;
1080 
1081  case token::ERROR:
1082  return true;
1083  }
1084 
1085  return false;
1086 }
1087 
1089 {
1090  return (type_ == PUNCTUATION && punctuationToken_ == p);
1091 }
1092 
1093 inline bool Foam::token::operator==(const word& w) const
1094 {
1095  return (type_ == WORD && wordToken() == w);
1096 }
1097 
1098 inline bool Foam::token::operator==(const functionName& fn) const
1099 {
1100  return (type_ == FUNCTIONNAME && functionNameToken() == fn);
1101 }
1102 
1103 inline bool Foam::token::operator==(const variable& v) const
1104 {
1105  return (type_ == VARIABLE && variableToken() == v);
1106 }
1107 
1108 inline bool Foam::token::operator==(const string& s) const
1109 {
1110  return (type_ == STRING && stringToken() == s);
1111 }
1112 
1113 inline bool Foam::token::operator==(const verbatimString& vs) const
1114 {
1115  return (type_ == VERBATIMSTRING && verbatimStringToken() == vs);
1116 }
1117 
1118 inline bool Foam::token::operator==(const int32_t l) const
1119 {
1120  return (type_ == INTEGER_32 && integer32Token_ == l);
1121 }
1122 
1123 inline bool Foam::token::operator==(const int64_t l) const
1124 {
1125  return (type_ == INTEGER_64 && integer64Token_ == l);
1126 }
1127 
1128 inline bool Foam::token::operator==(const uint32_t l) const
1129 {
1130  return (type_ == UNSIGNED_INTEGER_32 && unsignedInteger32Token_ == l);
1131 }
1132 
1133 inline bool Foam::token::operator==(const uint64_t l) const
1134 {
1135  return (type_ == UNSIGNED_INTEGER_64 && unsignedInteger64Token_ == l);
1136 }
1137 
1138 inline bool Foam::token::operator==(const floatScalar s) const
1139 {
1140  return (type_ == FLOAT_SCALAR && equal(floatScalarToken_, s));
1141 }
1142 
1143 inline bool Foam::token::operator==(const doubleScalar s) const
1144 {
1145  return (type_ == DOUBLE_SCALAR && equal(doubleScalarToken_, s));
1146 }
1147 
1149 {
1150  return
1151  (
1152  type_ == LONG_DOUBLE_SCALAR && equal(*longDoubleScalarTokenPtr_, s)
1153  );
1154 }
1155 
1156 inline bool Foam::token::operator!=(const token& t) const
1157 {
1158  return !operator==(t);
1159 }
1160 
1162 {
1163  return !operator==(p);
1164 }
1165 
1166 inline bool Foam::token::operator!=(const word& w) const
1167 {
1168  return !operator==(w);
1169 }
1170 
1171 inline bool Foam::token::operator!=(const functionName& fn) const
1172 {
1173  return !operator==(fn);
1174 }
1175 
1176 inline bool Foam::token::operator!=(const variable& v) const
1177 {
1178  return !operator==(v);
1179 }
1180 
1181 inline bool Foam::token::operator!=(const string& s) const
1182 {
1183  return !operator==(s);
1184 }
1185 
1186 inline bool Foam::token::operator!=(const verbatimString& vs) const
1187 {
1188  return !operator==(vs);
1189 }
1190 
1191 inline bool Foam::token::operator!=(const int32_t l) const
1192 {
1193  return !operator==(l);
1194 }
1195 
1196 inline bool Foam::token::operator!=(const int64_t l) const
1197 {
1198  return !operator==(l);
1199 }
1200 
1201 inline bool Foam::token::operator!=(const uint32_t l) const
1202 {
1203  return !operator==(l);
1204 }
1205 
1206 inline bool Foam::token::operator!=(const uint64_t l) const
1207 {
1208  return !operator==(l);
1209 }
1210 
1211 inline bool Foam::token::operator!=(const floatScalar s) const
1212 {
1213  return !operator==(s);
1214 }
1215 
1216 inline bool Foam::token::operator!=(const doubleScalar s) const
1217 {
1218  return !operator==(s);
1219 }
1220 
1222 {
1223  return !operator==(s);
1224 }
1225 
1226 
1227 // ************************************************************************* //
A functionName is a word starting with '#'.
Definition: functionName.H:60
static const functionName null
An empty functionName.
Definition: functionName.H:70
static const char *const typeName
Definition: functionName.H:66
Traits class for primitives.
Definition: pTraits.H:53
bool unique() const
Return true if the reference count is zero.
Definition: refCount.H:81
A class for handling character strings derived from std::string.
Definition: string.H:79
static const string null
An empty string.
Definition: string.H:88
static const char *const typeName
Definition: string.H:84
Abstract base class for complex tokens.
Definition: token.H:133
A token holds items read from Istream.
Definition: token.H:73
bool isLabel() const
Definition: tokenI.H:571
longDoubleScalar longDoubleScalarToken() const
Definition: tokenI.H:702
const variable & variableToken() const
Definition: tokenI.H:339
bool isUnsignedInteger32() const
Definition: tokenI.H:500
bool isNumber() const
Definition: tokenI.H:745
bool isPunctuation() const
Definition: tokenI.H:280
punctuationToken punctuationToken_
Definition: token.H:256
bool isDoubleScalar() const
Definition: tokenI.H:678
tokenType
Enumeration defining the types of token.
Definition: token.H:79
@ ERROR
Definition: token.H:97
@ VARIABLE
Definition: token.H:85
@ WORD
Definition: token.H:83
@ UNSIGNED_INTEGER_32
Definition: token.H:90
@ UNDEFINED
Definition: token.H:80
@ COMPOUND
Definition: token.H:95
@ FLOAT_SCALAR
Definition: token.H:92
@ INTEGER_64
Definition: token.H:89
@ DOUBLE_SCALAR
Definition: token.H:93
@ LONG_DOUBLE_SCALAR
Definition: token.H:94
@ VERBATIMSTRING
Definition: token.H:87
@ FUNCTIONNAME
Definition: token.H:84
@ UNSIGNED_INTEGER_64
Definition: token.H:91
@ INTEGER_32
Definition: token.H:88
@ STRING
Definition: token.H:86
@ PUNCTUATION
Definition: token.H:82
bool isLongDoubleScalar() const
Definition: tokenI.H:697
verbatimString * verbatimStringTokenPtr_
Definition: token.H:261
int32_t integer32Token() const
Definition: tokenI.H:441
compound * compoundTokenPtr_
Definition: token.H:269
bool isVerbatimString() const
Definition: tokenI.H:370
functionName * functionNameTokenPtr_
Definition: token.H:258
floatScalar floatScalarToken_
Definition: token.H:266
const functionName & functionNameToken() const
Definition: tokenI.H:321
variable * variableTokenPtr_
Definition: token.H:259
floatScalar floatScalarToken() const
Definition: tokenI.H:664
punctuationToken
Standard punctuation tokens.
Definition: token.H:102
bool isULabel() const
Definition: tokenI.H:615
const string & stringToken() const
Definition: tokenI.H:357
bool isAnyString() const
Definition: tokenI.H:388
punctuationToken pToken() const
Definition: tokenI.H:285
void setBad()
Set bad.
Definition: tokenI.H:814
bool isUnsignedInteger64() const
Definition: tokenI.H:537
label labelToken() const
Definition: tokenI.H:590
uint32_t unsignedInteger32Token() const
Definition: tokenI.H:512
bool isVariable() const
Definition: tokenI.H:334
bool isInteger64() const
Definition: tokenI.H:466
void operator=(const token &)
Definition: tokenI.H:823
int64_t integer64Token() const
Definition: tokenI.H:475
string * stringTokenPtr_
Definition: token.H:260
bool isScalar() const
Definition: tokenI.H:716
tokenType type() const
Definition: tokenI.H:255
const string & anyStringToken() const
Definition: tokenI.H:400
bool isFunctionName() const
Definition: tokenI.H:316
bool isInteger32() const
Definition: tokenI.H:429
int64_t integer64Token_
Definition: token.H:263
bool isCompound() const
Definition: tokenI.H:784
bool error() const
Definition: tokenI.H:275
int32_t integer32Token_
Definition: token.H:262
const compound & compoundToken() const
Definition: tokenI.H:789
bool isFloatScalar() const
Definition: tokenI.H:659
bool undefined() const
Definition: tokenI.H:270
uLabel uLabelToken() const
Definition: tokenI.H:634
bool operator!=(const token &) const
Definition: tokenI.H:1156
uint64_t unsignedInteger64Token() const
Definition: tokenI.H:546
doubleScalar doubleScalarToken() const
Definition: tokenI.H:683
bool isString() const
Definition: tokenI.H:352
bool good() const
Definition: tokenI.H:265
doubleScalar doubleScalarToken_
Definition: token.H:267
bool isWord() const
Definition: tokenI.H:298
word * wordTokenPtr_
Definition: token.H:257
token()
Construct null.
Definition: tokenI.H:75
const word & wordToken() const
Definition: tokenI.H:303
scalar scalarToken() const
Definition: tokenI.H:724
const verbatimString & verbatimStringToken() const
Definition: tokenI.H:375
~token()
Destructor.
Definition: tokenI.H:247
uint32_t unsignedInteger32Token_
Definition: token.H:264
bool operator==(const token &) const
Definition: tokenI.H:1023
uint64_t unsignedInteger64Token_
Definition: token.H:265
label lineNumber() const
Definition: tokenI.H:803
scalar number() const
Definition: tokenI.H:755
longDoubleScalar * longDoubleScalarTokenPtr_
Definition: token.H:268
A variable is a word with support for additional characters, in particular '$' and '/'.
Definition: variable.H:61
static const variable null
An empty variable.
Definition: variable.H:76
static const char *const typeName
Definition: variable.H:72
A class for handling verbatimStrings, derived from string.
static const verbatimString null
An empty verbatimString.
static const char *const typeName
A class for handling words, derived from string.
Definition: word.H:62
static const word null
An empty word.
Definition: word.H:77
static const char *const typeName
Definition: word.H:73
static bool isScalar[maxNames]
Definition: globalFoam.H:27
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
tUEqn clear()
bool equal(const T &s1, const T &s2)
Definition: doubleFloat.H:62
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:59
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
double doubleScalar
Double precision floating point scalar type.
Definition: doubleScalar.H:52
static const uLabel uLabelMax
Definition: uLabel.H:61
float floatScalar
Float precision floating point scalar type.
Definition: floatScalar.H:52
uintWM_LABEL_SIZE_t uLabel
A uLabel is an uint32_t or uint64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: uLabel.H:59
static const label labelMax
Definition: label.H:62
long double longDoubleScalar
Lang double precision floating point scalar type.
static const label labelMin
Definition: label.H:61
volScalarField & p