dictionaryEntry.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011 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 Class
25  Foam::dictionaryEntry
26 
27 Description
28  A keyword and a list of tokens is a 'dictionaryEntry'.
29 
30  An dictionaryEntry can be read, written and printed, and the types and
31  values of its tokens analysed. A dictionaryEntry is a high-level building
32  block for data description. It is a front-end for the token parser.
33  A list of entries can be used as a set of keyword syntax elements,
34  for example.
35 
36 SourceFiles
37  dictionaryEntry.C
38  dictionaryEntryIO.C
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #ifndef dictionaryEntry_H
43 #define dictionaryEntry_H
44 
45 #include "entry.H"
46 #include "dictionary.H"
47 #include "InfoProxy.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 /*---------------------------------------------------------------------------*\
55  Class dictionaryEntry Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 class dictionaryEntry
59 :
60  public entry,
61  public dictionary
62 {
63  // Private Member Functions
64 
65  void readData(Istream&);
66 
67  //- Dissallow bitwise copy
69 
70 
71 public:
72 
73  // Constructors
74 
75  //- Construct from the parent dictionary and Istream
76  dictionaryEntry(const dictionary& parentDict, Istream&);
77 
78  //- Construct from the keyword, parent dictionary and a Istream
80  (
81  const keyType&,
82  const dictionary& parentDict,
83  Istream&
84  );
85 
86  //- Construct from the keyword, parent dictionary and a dictionary
88  (
89  const keyType&,
90  const dictionary& parentDict,
91  const dictionary& dict
92  );
93 
94  //- Construct as copy for the given parent dictionary
96  (
97  const dictionary& parentDict,
98  const dictionaryEntry&
99  );
100 
101  autoPtr<entry> clone(const dictionary& parentDict) const
102  {
103  return autoPtr<entry>(new dictionaryEntry(parentDict, *this));
104  }
105 
106 
107  // Member functions
108 
109  //- Return the local dictionary name (final part of scoped name)
110  const word dictName() const
111  {
112  return dictionary::dictName();
113  }
114 
115  //- Return the dictionary name (scoped, e.g. dictA::dictB::dictC)
116  const fileName& name() const
117  {
118  return dictionary::name();
119  }
120 
121  //- Return the dictionary name (scoped, e.g. dictA::dictB::dictC)
122  fileName& name()
123  {
124  return dictionary::name();
125  }
126 
127  //- Return line number of first token in dictionary
128  label startLineNumber() const;
129 
130  //- Return line number of last token in dictionary
131  label endLineNumber() const;
132 
133  //- This entry is not a primitive,
134  // calling this function generates a FatalError
135  ITstream& stream() const;
136 
137  //- Return true because this entry is a dictionary
138  bool isDict() const
139  {
140  return true;
141  }
142 
143  //- Return dictionary
144  const dictionary& dict() const;
145 
146  //- Return non-const access to dictionary
147  dictionary& dict();
148 
149  //- Write
150  void write(Ostream&) const;
151 
152  //- Return info proxy.
153  // Used to print token information to a stream
155  {
156  return *this;
157  }
158 
159 
160  // Ostream operator
161 
162  friend Ostream& operator<<(Ostream&, const dictionaryEntry&);
163 };
164 
165 
166 template<>
167 Ostream& operator<<(Ostream&, const InfoProxy<dictionaryEntry>&);
168 
169 
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171 
172 } // End namespace Foam
173 
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 
176 #endif
177 
178 // ************************************************************************* //
Foam::entry
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:65
Foam::dictionaryName::dictName
const word dictName() const
Return the local dictionary name (final part of scoped name)
Definition: dictionary.H:115
Foam::dictionaryEntry
A keyword and a list of tokens is a 'dictionaryEntry'.
Definition: dictionaryEntry.H:57
Foam::dictionaryEntry::clone
autoPtr< entry > clone(const dictionary &parentDict) const
Construct on freestore as copy with reference to the.
Definition: dictionaryEntry.H:100
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::InfoProxy
A helper class for outputting values to Ostream.
Definition: InfoProxy.H:45
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::dictionaryName::name
const fileName & name() const
Return the dictionary name.
Definition: dictionary.H:103
InfoProxy.H
entry.H
Foam::dictionaryEntry::dictionaryEntry
dictionaryEntry(const dictionary &)
Dissallow bitwise copy.
Foam::keyType
A class for handling keywords in dictionaries.
Definition: keyType.H:56
Foam::dictionaryEntry::stream
ITstream & stream() const
This entry is not a primitive,.
Definition: dictionaryEntry.C:81
Foam::label
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
Foam::dictionaryEntry::info
InfoProxy< dictionaryEntry > info() const
Return info proxy.
Definition: dictionaryEntry.H:153
Foam::ITstream
Input token stream.
Definition: ITstream.H:49
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::dictionaryEntry::readData
void readData(Istream &)
Foam::dictionaryEntry::name
const fileName & name() const
Return the dictionary name (scoped, e.g. dictA::dictB::dictC)
Definition: dictionaryEntry.H:115
Foam::operator<<
Ostream & operator<<(Ostream &, const edgeMesh &)
Definition: edgeMeshIO.C:130
Foam::dictionaryEntry::name
fileName & name()
Return the dictionary name (scoped, e.g. dictA::dictB::dictC)
Definition: dictionaryEntry.H:121
Foam::dictionaryEntry::dictName
const word dictName() const
Return the local dictionary name (final part of scoped name)
Definition: dictionaryEntry.H:109
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::dictionaryEntry::write
void write(Ostream &) const
Write.
Definition: dictionaryEntryIO.C:69
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::dictionaryEntry::isDict
bool isDict() const
Return true because this entry is a dictionary.
Definition: dictionaryEntry.H:137
Foam::dictionaryEntry::endLineNumber
label endLineNumber() const
Return line number of last token in dictionary.
Definition: dictionaryEntry.C:68
Foam::dictionaryEntry::dict
const dictionary & dict() const
Return dictionary.
Definition: dictionaryEntry.C:91
Foam::dictionaryEntry::operator<<
friend Ostream & operator<<(Ostream &, const dictionaryEntry &)
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::dictionary::clone
autoPtr< dictionary > clone() const
Construct and return clone.
Definition: dictionary.C:215
dictionary.H
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::dictionaryEntry::startLineNumber
label startLineNumber() const
Return line number of first token in dictionary.
Definition: dictionaryEntry.C:55