tokenTupleN.C
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) 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 "tokenTupleN.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
31 :
32  tokens_(),
33  offsets_()
34 {}
35 
36 
38 :
39  tokens_(4),
40  offsets_(2)
41 {
42  is >> *this;
43 }
44 
45 
46 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
47 
49 {}
50 
51 
52 // * * * * * * * * * * * * * * IOStream Operators * * * * * * * * * * * * * //
53 
55 {
56  is.readBegin("StringTupleN");
57 
58  label level = 0;
59 
60  while (is.good())
61  {
62  if (level == 0)
63  {
64  ttn.offsets_.append(ttn.tokens_.size());
65  }
66 
67  const token t(is);
68 
69  if (t == token::BEGIN_LIST)
70  {
71  level ++;
72  }
73 
74  if (t == token::END_LIST)
75  {
76  if (level != 0)
77  {
78  level --;
79  }
80  else
81  {
82  is.putBack(t);
83  is.readEnd("StringTupleN");
84  break;
85  }
86  }
87 
88  ttn.tokens_.append(t);
89  }
90 
91  // Check state of Istream
92  is.check("operator>>(Istream& is, tokenTupleN&)");
93 
94  return is;
95 }
96 
97 
98 // ************************************************************************* //
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
Definition: DynamicListI.H:296
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:92
bool good() const
Return true if next operation might succeed.
Definition: IOstream.H:333
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
Istream & readEnd(const char *funcName)
Definition: Istream.C:103
Istream & readBegin(const char *funcName)
Definition: Istream.C:86
void putBack(const token &)
Put back token.
Definition: Istream.C:30
Reads a n-component tuple, storing the result as a list of tokens, using bracket counting to disambig...
Definition: tokenTupleN.H:75
tokenTupleN()
Default construct.
Definition: tokenTupleN.C:30
~tokenTupleN()
Destructor.
Definition: tokenTupleN.C:48
A token holds items read from Istream.
Definition: token.H:73
@ BEGIN_LIST
Definition: token.H:109
@ END_LIST
Definition: token.H:110
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
Istream & operator>>(Istream &, pistonPointEdgeData &)