includeEtcEntry.H
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-2026 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::functionEntries::includeEtcEntry
26 
27 Description
28  Specify an etc file to include when reading dictionaries, expects a
29  single string to follow.
30 
31  Searches for files from user/group/shipped directories.
32  The search scheme allows for version-specific and
33  version-independent files using the following hierarchy:
34  - \b user settings:
35  - ~/.OpenFOAM/<VERSION>
36  - ~/.OpenFOAM/
37  - \b group (site) settings (when $WM_PROJECT_SITE is set):
38  - $WM_PROJECT_SITE/<VERSION>/etc/
39  - $WM_PROJECT_SITE/etc/
40  - \b group (site) settings (when $WM_PROJECT_SITE is not set):
41  - $WM_PROJECT_INST_DIR/site/<VERSION>/etc/
42  - $WM_PROJECT_INST_DIR/site/etc/
43  - \b other (shipped) settings:
44  - $WM_PROJECT_DIR/etc/
45 
46  An example of the \c \#includeEtc directive:
47  \verbatim
48  #includeEtc "etcFile"
49  \endverbatim
50 
51  The usual expansion of environment variables and other constructs is
52  retained.
53 
54 See also
55  findEtcFile, fileName, string::expand()
56 
57 SourceFiles
58  includeEtcEntry.C
59 
60 \*---------------------------------------------------------------------------*/
61 
62 #ifndef includeEtcEntry_H
63 #define includeEtcEntry_H
64 
65 #include "includeEntry.H"
66 
67 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 
69 namespace Foam
70 {
71 namespace functionEntries
72 {
73 
74 /*---------------------------------------------------------------------------*\
75  Class includeEtcEntry Declaration
76 \*---------------------------------------------------------------------------*/
77 
78 class includeEtcEntry
79 :
80  public includeEntry
81 {
82 protected:
83 
84  // Protected Member Functions
85 
86  //- Expand include fileName and return
88  (
89  const fileName& dir,
90  const fileName&,
91  const dictionary&
92  ) const;
93 
94 
95 public:
96 
97  //- Runtime type information
98  FunctionTypeName("#includeEtc");
99 
100 
101  // Constructors
102 
103  //- Construct from line number, dictionary and Istream
105  (
106  const label lineNumber,
107  const dictionary& parentDict,
108  Istream& is
109  );
110 
111  //- Copy construct
112  includeEtcEntry(const includeEtcEntry&) = default;
113 
114  //- Clone
115  virtual autoPtr<entry> clone(const dictionary&) const
116  {
117  return autoPtr<entry>(new includeEtcEntry(*this));
118  }
119 
120 
121  // Member Functions
122 
123  //- Expand the functionEntry into the contextDict
124  virtual bool execute(dictionary& contextDict, Istream&);
125 
126  //- Expand the functionEntry into the contextEntry
127  static bool execute
128  (
129  const dictionary& contextDict,
130  primitiveEntry& contextEntry,
131  Istream&
132  );
133 
134 
135  // Member Operators
136 
137  //- Disallow default bitwise assignment
138  void operator=(const includeEtcEntry&) = delete;
139 };
140 
141 
142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 
144 } // End namespace functionEntries
145 } // End namespace Foam
146 
147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148 
149 #endif
150 
151 // ************************************************************************* //
label lineNumber() const
Return current stream line number.
Definition: IOstream.H:450
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
virtual autoPtr< entry > clone() const
Construct on freestore as copy.
Definition: entry.C:56
A class for handling file names.
Definition: fileName.H:82
Specify an include file when reading dictionaries.
Definition: includeEntry.H:78
Specify an etc file to include when reading dictionaries, expects a single string to follow.
FunctionTypeName("#includeEtc")
Runtime type information.
void operator=(const includeEtcEntry &)=delete
Disallow default bitwise assignment.
virtual fileName includeFileName(const fileName &dir, const fileName &, const dictionary &) const
Expand include fileName and return.
includeEtcEntry(const label lineNumber, const dictionary &parentDict, Istream &is)
Construct from line number, dictionary and Istream.
virtual bool execute(dictionary &contextDict, Istream &)
Expand the functionEntry into the contextDict.
A keyword and a list of tokens is a 'primitiveEntry'. An primitiveEntry can be read,...
Namespace for OpenFOAM.
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