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-2025 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, const label lineNumber)
41 :
42  IDLList<entry>::link(),
43  keyword_(keyword),
44  startLineNumber_(lineNumber)
45 {}
46 
47 
49 :
50  IDLList<entry>::link(),
51  keyword_(e.keyword_),
52  startLineNumber_(e.startLineNumber_)
53 {}
54 
55 
57 {
58  return clone(dictionary::null);
59 }
60 
61 
62 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
63 
65 {
66  // check for assignment to self
67  if (this == &e)
68  {
70  << "attempted assignment to self"
71  << abort(FatalError);
72  }
73 
74  keyword_ = e.keyword_;
75 }
76 
77 
78 bool Foam::entry::operator==(const entry& e) const
79 {
80  if (keyword_ != e.keyword_)
81  {
82  return false;
83  }
84  else
85  {
86  OStringStream oss1;
87  oss1 << *this;
88 
89  OStringStream oss2;
90  oss2 << e;
91 
92  return oss1.str() == oss2.str();
93  }
94 }
95 
96 
97 bool Foam::entry::operator!=(const entry& e) const
98 {
99  return !operator==(e);
100 }
101 
102 
103 // ************************************************************************* //
Template class for intrusive linked lists.
Definition: ILList.H:67
Output to memory buffer stream.
Definition: OStringStream.H:52
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: autoPtr.H:51
static const dictionary null
Null dictionary.
Definition: dictionary.H:273
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:68
void operator=(const entry &)
Definition: entry.C:64
virtual autoPtr< entry > clone() const
Construct on freestore as copy.
Definition: entry.C:56
entry(const keyType &keyword, const label lineNumber=-1)
Construct from keyword and optional line number.
Definition: entry.C:40
bool operator==(const entry &) const
Definition: entry.C:78
bool operator!=(const entry &) const
Definition: entry.C:97
static int disableFunctionEntries
Definition: entry.H:102
A class for handling keywords in dictionaries.
Definition: keyType.H:69
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
int infoSwitch(const char *name, const int defaultValue=0)
Lookup info switch or add default value.
Definition: debug.C:230
const doubleScalar e
Definition: doubleScalar.H:106
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
errorManip< error > abort(error &err)
Definition: errorManip.H:131
T clone(const T &t)
Definition: List.H:55
error FatalError