dictionaryEntry.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) 2011-2015 OpenFOAM Foundation
9  Copyright (C) 2017-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "dictionaryEntry.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
34 (
35  const keyType& key,
36  const dictionary& parentDict,
37  const dictionary& dict
38 )
39 :
40  entry(key),
41  dictionary(parentDict, dict)
42 {}
43 
44 
46 (
47  const dictionary& parentDict,
48  const dictionaryEntry& dictEnt
49 )
50 :
51  entry(dictEnt),
52  dictionary(parentDict, dictEnt)
53 {}
54 
55 
56 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
57 
59 {
60  if (size())
61  {
62  return first()->startLineNumber();
63  }
64 
65  return -1;
66 }
67 
68 
69 Foam::label Foam::dictionaryEntry::endLineNumber() const
70 {
71  if (size())
72  {
73  return last()->endLineNumber();
74  }
75 
76  return -1;
77 }
78 
79 
81 {
83  << "Attempt to return dictionary entry as a primitive"
84  << abort(FatalIOError);
85 
86  return lookup("");
87 }
88 
89 
91 {
92  return this;
93 }
94 
95 
97 {
98  return this;
99 }
100 
103 {
104  return *this;
105 }
106 
107 
109 {
110  return *this;
111 }
112 
113 
114 // ************************************************************************* //
A class for handling keywords in dictionaries.
Definition: keyType.H:66
dictionary dict
dictionaryEntry(const dictionaryEntry &)=delete
No copy construct.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
virtual ITstream & stream() const
This entry is not a primitive, calling this function generates a FatalError.
Lookup type of boundary radiation properties.
Definition: lookup.H:57
A keyword and a list of tokens is a &#39;dictionaryEntry&#39;.
virtual label endLineNumber() const
Return line number of last token in dictionary.
errorManip< error > abort(error &err)
Definition: errorManip.H:139
const direction noexcept
Definition: Scalar.H:258
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:607
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
Definition: foamGltfBase.H:103
virtual label startLineNumber() const
Return line number of first token in dictionary.
T * first()
The first entry in the list.
Definition: UILList.H:542
virtual const dictionary & dict() const noexcept
Return dictionary (ie, this)
virtual const dictionary * dictPtr() const noexcept
Return pointer to this dictionary.
An input stream of tokens.
Definition: ITstream.H:48
A keyword and a list of tokens is an &#39;entry&#39;.
Definition: entry.H:63
IOerror FatalIOError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL IO ERROR&#39; header text and ...