dictionaryContent.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2021 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::dictionaryContent
28 
29 Description
30  A wrapper for dictionary content, \em without operators that could
31  affect inheritance patterns.
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef Foam_dictionaryContent_H
36 #define Foam_dictionaryContent_H
37 
38 #include "dictionary.H"
39 #include "wordList.H"
40 #include "wordRes.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 /*---------------------------------------------------------------------------*\
48  Class dictionaryContent Declaration
49 \*---------------------------------------------------------------------------*/
50 
52 {
53  // Private Data
54 
55  //- The dictionary content
56  dictionary dict_;
57 
58 public:
59 
60  // Constructors
61 
62  //- Default construct
63  dictionaryContent() = default;
64 
65  //- Copy construct
66  dictionaryContent(const dictionaryContent&) = default;
67 
68  //- Move construct
70 
71  //- Copy construct from dictionary
72  explicit dictionaryContent(const dictionary& dict)
73  :
74  dict_(dict)
75  {}
76 
77  //- Move construct from dictionary
79  :
80  dict_(std::move(dict))
81  {}
82 
83 
84  //- Destructor
85  virtual ~dictionaryContent() = default;
86 
87 
88  // Member Functions
89 
90  //- Copy construct a dictionary,
91  //- filtered by simple allow/deny lists
92  //
93  // An empty 'allow' list accepts everything not in the 'deny' list.
94  //
95  // \return filtered dictionary copy
96  static dictionary copyDict
97  (
98  const dictionary& input,
99  const wordList& allow = wordList(),
100  const wordList& deny = wordList()
101  );
102 
103  //- Copy construct a dictionary,
104  //- filtered by a combination of allow/deny lists
105  //
106  // An empty 'allow' list accepts everything not in the 'deny' list.
107  // A literal match has higher priority over a regex match.
108  //
109  // \verbatim
110  // input: ( abc apple wall wall1 wall2 )
111  // allow: ( abc def "wall.*" )
112  // deny: ( "[ab].*" wall )
113  //
114  // result: (abc wall1 wall2)
115  // \endverbatim
116  //
117  // \return filtered dictionary copy
118  static dictionary copyDict
119  (
120  const dictionary& input,
121  const wordRes& allow,
122  const wordRes& deny = wordRes()
123  );
124 
125 
126  //- Read-access to the content
127  const dictionary& dict() const noexcept
128  {
129  return dict_;
130  }
131 
132  //- Copy assign new content
133  void dict(const dictionary& dict)
134  {
135  dict_ = dict;
136  }
137 
138  //- Move assign new content
139  void dict(dictionary&& dict)
140  {
141  dict_ = std::move(dict);
142  }
143 
144 
145  // Operators
146 
147  //- No copy assignment
148  void operator=(const dictionaryContent&) = delete;
149 
150  //- No move assignment
151  void operator=(dictionaryContent&&) = delete;
152 };
153 
154 
155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156 
157 } // End namespace Foam
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160 
161 #endif
162 
163 // ************************************************************************* //
virtual ~dictionaryContent()=default
Destructor.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
const dictionary & dict() const noexcept
Read-access to the content.
static Istream & input(Istream &is, IntRange< T > &range)
Definition: IntRanges.C:33
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:53
static dictionary copyDict(const dictionary &input, const wordList &allow=wordList(), const wordList &deny=wordList())
Copy construct a dictionary, filtered by simple allow/deny lists.
A wrapper for dictionary content, without operators that could affect inheritance patterns...
const direction noexcept
Definition: Scalar.H:258
List< word > wordList
List of word.
Definition: fileName.H:59
void operator=(const dictionaryContent &)=delete
No copy assignment.
dictionaryContent()=default
Default construct.
Namespace for OpenFOAM.