csvTableReader.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 | Copyright (C) 2011-2015 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::csvTableReader
26 
27 Description
28  Reads an interpolation table from a file - CSV-format
29 
30 SourceFiles
31  tableReader.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef csvTableReader_H
36 #define csvTableReader_H
37 
38 #include "tableReader.H"
39 #include "labelList.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 /*---------------------------------------------------------------------------*\
47  Class csvTableReader Declaration
48 \*---------------------------------------------------------------------------*/
49 
50 template<class Type>
51 class csvTableReader
52 :
53  public tableReader<Type>
54 {
55  // Private data
56 
57  //- Does the file have a header line?
58  const bool headerLine_;
59 
60  //- Column of the time
61  const label timeColumn_;
62 
63  //- Labels of the components
64  const labelList componentColumns_;
65 
66  //- Read the next value from the splitted string
67  Type readValue(const List<string>&);
68 
69  //- Separator character
70  const char separator_;
71 
72 
73 public:
74 
75  //- Runtime type information
76  TypeName("csv");
77 
78 
79  // Constructors
80 
81  //- Construct from dictionary
83 
84  //- Construct and return a copy
85  virtual autoPtr<tableReader<Type> > clone() const
86  {
88  (
90  (
91  *this
92  )
93  );
94  }
95 
96 
97  //- Destructor
98  virtual ~csvTableReader();
99 
100 
101  // Member Functions
102 
103  //- Read the table
104  virtual void operator()(const fileName&, List<Tuple2<scalar, Type> >&);
105 
106  //- Read 2D table
107  virtual void operator()
108  (
109  const fileName&,
111  );
112 
113  //- Write the remaining parameters
114  virtual void write(Ostream& os) const;
115 };
116 
117 
118 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
119 
120 } // End namespace Foam
121 
122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
123 
124 #ifdef NoRepository
125 # include "csvTableReader.C"
126 #endif
127 
128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 
130 #endif
131 
132 // ************************************************************************* //
A 2-tuple for storing two objects of different types.
Definition: Tuple2.H:47
virtual ~csvTableReader()
Destructor.
virtual void operator()(const fileName &, List< Tuple2< scalar, Type > > &)
Read the table.
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
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Namespace for OpenFOAM.
dictionary dict
Reads an interpolation table from a file - CSV-format.
Base class to read table data for the interpolationTable.
Definition: tableReader.H:57
csvTableReader(const dictionary &dict)
Construct from dictionary.
A class for handling file names.
Definition: fileName.H:69
virtual void write(Ostream &os) const
Write the remaining parameters.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
TypeName("csv")
Runtime type information.
virtual autoPtr< tableReader< Type > > clone() const
Construct and return a copy.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117