Loading...
Searching...
No Matches
functionEntryTemplates.C
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) 2017-2019 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
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\*---------------------------------------------------------------------------*/
27
29#include "ISstream.H"
30
31// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
32
33template<class StringType>
36{
38
39 ISstream& iss = dynamic_cast<ISstream&>(is);
40 token firstToken(iss);
41
42 const bool isStringTok = firstToken.isStringType();
43
44 iss.putBack(firstToken);
45
46 if (isStringTok)
47 {
48 // The first token appears viable as non-list
49 // - treated like list with a single entry
50
51 list.resize(1);
52 iss >> list.front();
53 }
54 else
55 {
56 iss >> list;
57 }
58
59 return list;
60}
61
62
63// ************************************************************************* //
Generic input stream using a standard (STL) stream.
Definition ISstream.H:54
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
void putBack(const token &tok)
Put back a token (copy). Only a single put back is permitted.
Definition Istream.C:71
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
void resize(const label len)
Adjust allocated size of list.
Definition ListI.H:153
T & front()
Access first element of the list, position [0].
Definition UListI.H:239
static List< StringType > readStringList(Istream &is)
Read a List of strings values, treating a single entry like a list of size 1.
A token holds an item read from Istream.
Definition token.H:70
bool isStringType() const noexcept
Token is word-variant or string-variant (WORD, DIRECTIVE, STRING, EXPRESSION, VARIABLE,...
Definition tokenI.H:1070