tokenTupleN.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) 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 Class
25  Foam::tokenTupleN
26 
27 Description
28  Reads a n-component tuple, storing the result as a list of tokens, using
29  bracket counting to disambiguate types. This allows foam-format tables of
30  mixed types to be read and columns extracted, provided that the complex
31  types are bounded by parentheses. For example, the following table, with
32  scalar, vector, scalar, and symmTensor columns could be read as a list of
33  tokenTupleN-s:
34 
35  \verbatim
36  (
37  (0 (1 2 3) 4 (5 6 7 8 9 10))
38  (1 (2 3 4) 5 (6 7 8 9 10 11))
39  (2 (3 4 5) 6 (7 8 9 10 11 12))
40  )
41  \endverbatim
42 
43  Once constructed, this type then provides type-based access to the
44  components of the tuple so that they can be extracted into a different
45  structure.
46 
47 SourceFiles
48  tokenTupleN.C
49 
50 \*---------------------------------------------------------------------------*/
51 
52 #ifndef tokenTupleN_H
53 #define tokenTupleN_H
54 
55 #include "DynamicList.H"
56 
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 
59 namespace Foam
60 {
61 
62 // Forward declaration of classes
63 class Istream;
64 class Ostream;
65 
66 // Forward declaration of friend functions and operators
67 class tokenTupleN;
68 Istream& operator>>(Istream&, tokenTupleN&);
69 
70 
71 /*---------------------------------------------------------------------------*\
72  Class tokenTupleN Declaration
73 \*---------------------------------------------------------------------------*/
74 
75 class tokenTupleN
76 {
77  // Private Data
78 
79  //- Tokens
80  DynamicList<token> tokens_;
81 
82  //- Indices of the tokens that start the different pieces of data, plus
83  // an index at the end for convenience
84  DynamicList<label> offsets_;
85 
86 
87 public:
88 
89  // Constructors
90 
91  //- Default construct
92  tokenTupleN();
93 
94  //- Construct from stream
95  tokenTupleN(Istream& is);
96 
97 
98  //- Destructor
99  ~tokenTupleN();
100 
101 
102  // Member Functions
103 
104  //- Get the number of elements in the tuple
105  inline label size() const;
106 
107  //- Get a type at a given position in the tuple. Stream used for error
108  // reporting only.
109  template<class Type>
110  inline Type get(const IOstream& s, const label i);
111 
112 
113  // IOstream Operators
114 
115  //- Read from stream
117 };
118 
119 
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121 
122 } // End namespace Foam
123 
124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
125 
126 #include "tokenTupleNI.H"
127 
128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 
130 #endif
131 
132 // ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:78
An IOstream is an abstract base class for all input/output systems; be they streams,...
Definition: IOstream.H:72
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
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
label size() const
Get the number of elements in the tuple.
Definition: tokenTupleNI.H:32
friend Istream & operator>>(Istream &, tokenTupleN &)
Read from stream.
~tokenTupleN()
Destructor.
Definition: tokenTupleN.C:48
Type get(const IOstream &s, const label i)
Get a type at a given position in the tuple. Stream used for error.
Definition: tokenTupleNI.H:39
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), lagrangian::cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Namespace for OpenFOAM.
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 &)