wordAndDictionary.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2020 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 \*---------------------------------------------------------------------------*/
25 
26 #include "wordAndDictionary.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
31 :
33 {}
34 
35 
37 :
39 {
40  is >> *this;
41 
42  is.check("wordAndDictionary::wordAndDictionary(Istream& is)");
43 }
44 
45 
46 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
47 
49 {}
50 
51 
52 // * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * //
53 
55 {
56  wd.first() = word(is);
57  wd.second().clear();
58 
59  token t(is);
60  is.putBack(t);
61 
62  if (t.isPunctuation() && t.pToken() == token::BEGIN_BLOCK)
63  {
64  dictionary d(is);
65  wd.second().transfer(d);
66  }
67 
68  return is;
69 }
70 
71 
73 {
74  os << wd.first();
75 
76  if (!wd.second().empty())
77  {
78  os << token::SPACE << wd.second();
79  }
80 
81  return os;
82 }
83 
84 
85 // ************************************************************************* //
punctuationToken pToken() const
Definition: tokenI.H:248
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:92
A 2-tuple for storing two objects of different types.
Definition: HashTable.H:65
~wordAndDictionary()
Destructor.
const Type1 & first() const
Return first.
Definition: Tuple2.H:116
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
A token holds items read from Istream.
Definition: token.H:72
void putBack(const token &)
Put back token.
Definition: Istream.C:30
Tuple of a word and dictionary, used to read in per-field options for function objects in the followi...
void transfer(dictionary &)
Transfer the contents of the argument and annul the argument.
Definition: dictionary.C:1472
A class for handling words, derived from string.
Definition: word.H:59
Istream & operator>>(Istream &, directionInfo &)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
wordAndDictionary()
Construct null.
Ostream & operator<<(Ostream &, const ensightPart &)
const Type2 & second() const
Return second.
Definition: Tuple2.H:128
void clear()
Clear the dictionary.
Definition: dictionary.C:1463
bool isPunctuation() const
Definition: tokenI.H:243