All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
entry.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) 2011-2018 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 "entry.H"
27 #include "dictionary.H"
28 #include "OStringStream.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
33 (
34  Foam::debug::infoSwitch("disableFunctionEntries", 0)
35 );
36 
37 
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 
40 Foam::entry::entry(const keyType& keyword)
41 :
42  IDLList<entry>::link(),
43  keyword_(keyword)
44 {}
45 
46 
48 :
49  IDLList<entry>::link(),
50  keyword_(e.keyword_)
51 {}
52 
53 
55 {
56  return clone(dictionary::null);
57 }
58 
59 
60 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
61 
63 {
64  // check for assignment to self
65  if (this == &e)
66  {
68  << "attempted assignment to self"
69  << abort(FatalError);
70  }
71 
72  keyword_ = e.keyword_;
73 }
74 
75 
76 bool Foam::entry::operator==(const entry& e) const
77 {
78  if (keyword_ != e.keyword_)
79  {
80  return false;
81  }
82  else
83  {
84  OStringStream oss1;
85  oss1 << *this;
86 
87  OStringStream oss2;
88  oss2 << e;
89 
90  return oss1.str() == oss2.str();
91  }
92 }
93 
94 
95 bool Foam::entry::operator!=(const entry& e) const
96 {
97  return !operator==(e);
98 }
99 
100 
101 // ************************************************************************* //
Template class for intrusive linked lists.
Definition: ILList.H:50
A class for handling keywords in dictionaries.
Definition: keyType.H:66
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
static const dictionary null
Null dictionary.
Definition: dictionary.H:241
int infoSwitch(const char *name, const int defaultValue=0)
Lookup info switch or add default value.
Definition: debug.C:187
bool operator==(const entry &) const
Definition: entry.C:76
entry(const keyType &)
Construct from keyword.
Definition: entry.C:40
static int disableFunctionEntries
Definition: entry.H:86
errorManip< error > abort(error &err)
Definition: errorManip.H:131
void operator=(const entry &)
Definition: entry.C:62
bool operator!=(const entry &) const
Definition: entry.C:95
virtual autoPtr< entry > clone() const
Construct on freestore as copy.
Definition: entry.C:54
string str() const
Return the string.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
const doubleScalar e
Elementary charge.
Definition: doubleScalar.H:105
Output to memory buffer stream.
Definition: OStringStream.H:49
A keyword and a list of tokens is an &#39;entry&#39;.
Definition: entry.H:65