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 dictionaryContent_H
36 #define dictionaryContent_H
37 
38 #include "dictionary.H"
39 #include "wordRes.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 /*---------------------------------------------------------------------------*\
47  Class dictionaryContent Declaration
48 \*---------------------------------------------------------------------------*/
49 
51 {
52  // Private Data
53 
54  //- The dictionary content
55  dictionary dict_;
56 
57 public:
58 
59  // Constructors
60 
61  //- Default construct
62  dictionaryContent() = default;
63 
64  //- Copy construct
65  dictionaryContent(const dictionaryContent&) = default;
66 
67  //- Move construct
69 
70  //- Copy construct from dictionary
71  explicit dictionaryContent(const dictionary& dict)
72  :
73  dict_(dict)
74  {}
75 
76  //- Move construct from dictionary
78  :
79  dict_(std::move(dict))
80  {}
81 
82 
83  //- Destructor
84  virtual ~dictionaryContent() = default;
85 
86 
87  // Member Functions
88 
89  //- Copy construct a dictionary,
90  //- filtered by simple allow/deny lists
91  //
92  // An empty 'allow' list accepts everything not in the 'deny' list.
93  //
94  // \return filtered dictionary copy
95  static dictionary copyDict
96  (
97  const dictionary& input,
98  const wordList& allow = wordList(),
99  const wordList& deny = wordList()
100  );
101 
102  //- Copy construct a dictionary,
103  //- filtered by a combination of allow/deny lists
104  //
105  // An empty 'allow' list accepts everything not in the 'deny' list.
106  // A literal match has higher priority over a regex match.
107  //
108  // \verbatim
109  // input: ( abc apple wall wall1 wall2 )
110  // allow: ( abc def "wall.*" )
111  // deny: ( "[ab].*" wall )
112  //
113  // result: (abc wall1 wall2)
114  // \endverbatim
115  //
116  // \return filtered dictionary copy
117  static dictionary copyDict
118  (
119  const dictionary& input,
120  const wordRes& allow,
121  const wordRes& deny = wordRes()
122  );
123 
124 
125  //- Read-access to the content
126  const dictionary& dict() const noexcept
127  {
128  return dict_;
129  }
130 
131  //- Copy assign new content
132  void dict(const dictionary& dict)
133  {
134  dict_ = dict;
135  }
136 
137  //- Move assign new content
138  void dict(dictionary&& dict)
139  {
140  dict_ = std::move(dict);
141  }
142 
143 
144  // Operators
145 
146  //- No copy assignment
147  void operator=(const dictionaryContent&) = delete;
148 
149  //- No move assignment
150  void operator=(dictionaryContent&&) = delete;
151 };
152 
153 
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 
156 } // End namespace Foam
157 
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 
160 #endif
161 
162 // ************************************************************************* //
wordRes.H
Foam::dictionaryContent::copyDict
static dictionary copyDict(const dictionary &input, const wordList &allow=wordList(), const wordList &deny=wordList())
Definition: dictionaryContent.C:78
Foam::dictionaryContent::dictionaryContent
dictionaryContent(dictionary &&dict)
Move construct from dictionary.
Definition: dictionaryContent.H:76
Foam::dictionaryContent::~dictionaryContent
virtual ~dictionaryContent()=default
Destructor.
Foam::dictionaryContent
A wrapper for dictionary content, without operators that could affect inheritance patterns.
Definition: dictionaryContent.H:49
Foam::dictionaryContent::dict
void dict(dictionary &&dict)
Move assign new content.
Definition: dictionaryContent.H:137
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:62
Foam::dictionaryContent::dictionaryContent
dictionaryContent(const dictionary &dict)
Copy construct from dictionary.
Definition: dictionaryContent.H:70
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::dictionaryContent::operator=
void operator=(const dictionaryContent &)=delete
No copy assignment.
Foam::dictionaryContent::dictionaryContent
dictionaryContent()=default
Default construct.
Foam::dictionaryContent::dict
const dictionary & dict() const noexcept
Read-access to the content.
Definition: dictionaryContent.H:125
Foam::List< word >
dictionary.H
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51
Foam::input
static Istream & input(Istream &is, IntRange< T > &range)
Definition: IntRanges.C:55
Foam::dictionaryContent::dict
void dict(const dictionary &dict)
Copy assign new content.
Definition: dictionaryContent.H:131