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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::csvTableReader
28 
29 Description
30  Reads an interpolation table from a file - CSV-format
31 
32 SourceFiles
33  tableReader.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef csvTableReader_H
38 #define csvTableReader_H
39 
40 #include "tableReader.H"
41 #include "labelList.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class csvTableReader Declaration
50 \*---------------------------------------------------------------------------*/
51 
52 template<class Type>
53 class csvTableReader
54 :
55  public tableReader<Type>
56 {
57  // Private data
58 
59  //- Does the file have a header line?
60  const bool headerLine_;
61 
62  //- Column of the time
63  const label timeColumn_;
64 
65  //- Labels of the components
66  const labelList componentColumns_;
67 
68  //- Read the next value from the splitted string
69  Type readValue(const List<string>&);
70 
71  //- Separator character
72  const char separator_;
73 
74 
75 public:
76 
77  //- Runtime type information
78  TypeName("csv");
79 
80 
81  // Constructors
82 
83  //- Construct from dictionary
85 
86  //- Construct and return a copy
87  virtual autoPtr<tableReader<Type>> clone() const
88  {
90  (
92  (
93  *this
94  )
95  );
96  }
97 
98 
99  //- Destructor
100  virtual ~csvTableReader();
101 
102 
103  // Member Functions
104 
105  //- Read the table
106  virtual void operator()(const fileName&, List<Tuple2<scalar, Type>>&);
107 
108  //- Read 2D table
109  virtual void operator()
110  (
111  const fileName&,
113  );
114 
115  //- Write the remaining parameters
116  virtual void write(Ostream& os) const;
117 };
118 
119 
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121 
122 } // End namespace Foam
123 
124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
125 
126 #ifdef NoRepository
127  #include "csvTableReader.C"
128 #endif
129 
130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
131 
132 #endif
133 
134 // ************************************************************************* //
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::tableReader
Base class to read table data for the interpolationTable.
Definition: tableReader.H:59
Foam::csvTableReader::csvTableReader
csvTableReader(const dictionary &dict)
Construct from dictionary.
Definition: csvTableReader.C:35
Foam::csvTableReader::write
virtual void write(Ostream &os) const
Write the remaining parameters.
Definition: csvTableReader.C:174
Foam::label
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:62
labelList.H
Foam::csvTableReader::~csvTableReader
virtual ~csvTableReader()
Destructor.
Definition: csvTableReader.C:56
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::csvTableReader
Reads an interpolation table from a file - CSV-format.
Definition: csvTableReader.H:52
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::csvTableReader::clone
virtual autoPtr< tableReader< Type > > clone() const
Construct and return a copy.
Definition: csvTableReader.H:86
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::csvTableReader::TypeName
TypeName("csv")
Runtime type information.
Foam::List< label >
Foam::csvTableReader::operator()
virtual void operator()(const fileName &, List< Tuple2< scalar, Type >> &)
Read the table.
Definition: csvTableReader.C:105
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::Tuple2
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition: Tuple2.H:57
csvTableReader.C
tableReader.H