Go to the documentation of this file.
21 #ifndef __anyList_hpp__
22 #define __anyList_hpp__
83 template<
typename T,
typename... Args>
89 "variable name "<< name <<
" already exists in the anyList."<<
endl<<
94 types_.push_back(getTypeName<T>());
96 std::in_place_type<T>,
97 std::forward<Args>(args)...);
107 "variable name "<< name <<
" already exists in the anyList."<<
endl<<
113 return anyList_.emplace_back(std::in_place_type<T>, other);
123 "variable name "<< name <<
" already exists in the anyList."<<
endl<<
129 return anyList_.emplace_back(std::in_place_type<T>, std::forward<T>(other));
136 if(getTypeName<T>() !=
types_[i])
139 "requested object type is "<<getTypeName<T>()<<
140 " while strored type is "<<
types_[i]<<
149 "any does not have a value for dereferencing. "<<
150 "index in anyList is "<<i<<
"."<<
endl;
153 return *std::any_cast<T>(a);
164 "variable name "<< name <<
" does not exist in the anyList."<<
endl<<
168 return getObject<T>(
static_cast<size_t>(i));
179 "variable name "<< name <<
" does not exist in the anyList."<<
endl<<
183 return getObject<T>(
static_cast<size_t>(i));
190 if(getTypeName<T>() !=
types_[i])
193 "requested object type is "<<getTypeName<T>()<<
194 " while strored type is "<<
types_[i]<<
203 "any does not have a value for dereferencing. "<<
204 "index in anyList is "<<i<<
"."<<
endl;
207 return *std::any_cast<const T>(a);
214 if(i>=
size())
return nullptr;
216 if(getTypeName<T>() !=
types_[i])
219 "requested object type is "<<getTypeName<T>()<<
220 " while strored type is "<<
types_[i]<<
228 return std::any_cast<T>(a);
240 if(i>=
size())
return nullptr;
241 if(getTypeName<T>() !=
types_[i])
244 "requested object type is "<<getTypeName<T>()<<
245 " while strored type is "<<
types_[i]<<
253 return std::any_cast<const T>(a);
268 #endif //__anyList_hpp__
const T & getObject(const word &name) const
Get the const reference to variable by name.
wordList names_
List of variable names in anyList_.
#define fatalExit
Fatal exit.
T & getObject(size_t i)
Get the reference to variable by index.
T * getObjectPtr(size_t i)
Get the pointer to variable by index.
#define warningInFunction
Report a warning.
typename listType::const_iterator const_iterator
bool contains(const word &name) const
Does container contain this variable name?
bool empty() const
Is container empty.
iOstream & endl(iOstream &os)
Add newline and flush stream.
reference emplaceBack(const word &name, T &&other)
Create variable using move constructor.
typename anyListType::reference reference
int32 findi(const T &val) const
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
typename listType::iterator iterator
typename anyListType::const_iterator const_iterator
typename listType::reference reference
typename anyListType::iterator iterator
const T * getObjectPtr(size_t i) const
Get the const pointer to variable by index.
auto pos(size_t i, bool noError=false)
const T & getObject(size_t i) const
Get the const reference to object by index.
reference emplaceBack(const word &name, const T &other)
Create variable using copy constructor.
size_t size() const
Size of container.
reference emplaceBack(const word &name, Args &&... args)
Create variable using constructor in-place.
anyListType anyList_
Contains a list of variables with any type.
T & getObject(const word &name)
Get the reference to variable by name.
const wordList & names() const
List of varibales names.