40 std::initializer_list<std::pair<const char*,int>> compat,
49 ITstream& is =
dict.lookupCompat(
name, compat);
50 is.format(IOstreamOption::ASCII);
54 if (cols.size() != pTraits<Type>::nComponents)
57 <<
name <<
" with " << cols
58 <<
" does not have the expected length "
59 << pTraits<Type>::nComponents <<
nl
60 <<
exit(FatalIOError);
70Type Foam::csvTableReader<Type>::readValue
72 const UList<string>& strings
77 if constexpr (std::is_integral_v<Type>)
84 for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; ++cmpt)
87 readScalar(strings[componentColumns_[cmpt]]);
101 headerLine_(
dict.get<bool>(
"hasHeaderLine")),
102 refColumn_(
dict.getCompat<label>(
"refColumn", {{
"timeColumn", 1912}})),
105 getComponentColumns(
"componentColumns", {{
"valueColumns", 1912}},
dict)
107 separator_(
dict.getOrDefault<
string>(
"separator",
",")[0])
123 const label maxEntry =
124 max(refColumn_, componentColumns_[
findMax(componentColumns_)]);
136 DynamicList<Tuple2<scalar, Type>> values;
137 DynamicList<string> strings(maxEntry+1);
151 (
pos != std::string::npos) && (
n <= maxEntry);
155 const auto nPos = line.find(separator_,
pos);
157 if (nPos == std::string::npos)
159 strings.push_back(line.substr(
pos));
164 strings.push_back(
line.substr(
pos, nPos-
pos));
169 if (strings.size() <= 1)
174 if (strings.size() <= maxEntry)
177 <<
"Not enough columns near line " << lineNo
178 <<
". Require " << (maxEntry+1) <<
" but found "
183 scalar
x = readScalar(strings[refColumn_]);
184 Type value = readValue(strings);
189 data.transfer(values);
196 const fileName& fName,
197 List<Tuple2<scalar, List<Tuple2<scalar, Type>>>>& data
209 os.writeEntry(
"hasHeaderLine", headerLine_);
210 os.writeEntry(
"refColumn", refColumn_);
214 os.writeEntry(
"componentColumns", componentColumns_);
217 os.writeEntry(
"separator",
string(separator_));
Various functions to operate on Lists.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
void push_back(const T &val)
Copy append an element to the end of this list.
@ ASCII
"ascii" (normal default)
bool good() const noexcept
True if next operation might succeed.
Generic input stream using a standard (STL) stream.
ISstream & getLine(std::string &str, char delim='\n')
Raw, low-level getline (until delimiter) into a string.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
void size(const label n)
Older name for setAddressableSize.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Reads an interpolation table from a file - CSV-format.
virtual void write(Ostream &os) const
Write the remaining parameters.
csvTableReader(const dictionary &dict)
Construct from dictionary.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
A class for handling file names.
Base class to read table data for the interpolationTable.
virtual void write(Ostream &os) const
Write additional information.
tableReader()=default
Default construct.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
dimensionedScalar pos(const dimensionedScalar &ds)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
List< label > labelList
A List of labels.
refPtr< fileOperation > fileHandler(std::nullptr_t)
Delete current file handler - forwards to fileOperation::handler().
label & setComponent(label &val, const direction) noexcept
Non-const access to integer-type (has no components).
label readLabel(const char *buf)
Parse entire buffer as a label, skipping leading/trailing whitespace.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
label findMax(const ListType &input, label start=0)
Linear search for the index of the max element, similar to std::max_element but for lists and returns...
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a).