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
28#include "functionEntry.H"
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.first();
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:58
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
void putBack(const token &tok)
Put back a token. Only a single put back is permitted.
Definition: Istream.C:70
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:139
T & first()
Return the first element of the list.
Definition: UListI.H:202
static List< StringType > readStringList(Istream &is)
A token holds an item read from Istream.
Definition: token.H:69
bool isStringType() const noexcept
Definition: tokenI.H:683