mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: cleanup wordRe interfaces etc.
- ensure that the string-related classes have consistently similar
matching methods. Use operator()(const std::string) as an entry
point for the match() method, which makes it easier to use for
filters and predicates. In some cases this will also permit using
a HashSet as a match predicate.
regExp
====
- the set method now returns a bool to signal that the requested
pattern was compiled.
wordRe
====
- have separate constructors with the compilation option (was previously
a default parameter). This leaves the single parameter constructor
explicit, but the two parameter version is now non-explicit, which
makes it easier to use when building lists.
- renamed compile-option from REGEX (to REGEXP) for consistency with
with the <regex.h>, <regex> header names etc.
wordRes
====
- renamed from wordReListMatcher -> wordRes. For reduced typing and
since it behaves as an entity only slightly related to its underlying
list nature.
- Provide old name as typedef and include for code transition.
- pass through some list methods into wordRes
hashedWordList
====
- hashedWordList[const word& name] now returns a -1 if the name is is
not found in the list of indices. That has been a pending change
ever since hashedWordList was generalized out of speciesTable
(Oct-2010).
- add operator()(const word& name) for easy use as a predicate
STYLE: adjust parameter names in stringListOps
- reflect if the parameter is being used as a primary matcher, or the
matcher will be derived from the parameter.
For example,
(const char* re), which first creates a regExp
versus (const regExp& matcher) which is used directly.
This commit is contained in:
@ -47,8 +47,8 @@ namespace Foam
|
||||
class hashedWordList;
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
Istream& operator>>(Istream&, hashedWordList&);
|
||||
Ostream& operator<<(Ostream&, const hashedWordList&);
|
||||
Istream& operator>>(Istream& is, hashedWordList& lst);
|
||||
Ostream& operator<<(Ostream& os, const hashedWordList& lst);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -97,7 +97,7 @@ public:
|
||||
);
|
||||
|
||||
//- Construct from an initializer list
|
||||
inline hashedWordList(std::initializer_list<word>);
|
||||
inline hashedWordList(std::initializer_list<word> lst);
|
||||
|
||||
//- Construct from the word keys of any HashTable, sorting immediately.
|
||||
// This also handles a wordHashSet, which is derived from a HashTable.
|
||||
@ -105,7 +105,7 @@ public:
|
||||
template<class AnyType, class AnyHash>
|
||||
explicit inline hashedWordList
|
||||
(
|
||||
const HashTable<AnyType, word, AnyHash>& h
|
||||
const HashTable<AnyType, word, AnyHash>& tbl
|
||||
);
|
||||
|
||||
//- Construct from number and list of words,
|
||||
@ -122,7 +122,7 @@ public:
|
||||
hashedWordList(const char** lst, const bool removeDuplicates=false);
|
||||
|
||||
//- Construct from Istream
|
||||
hashedWordList(Istream&);
|
||||
hashedWordList(Istream& is);
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -161,26 +161,33 @@ public:
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Assignment operator from list of words
|
||||
inline void operator=(const UList<word>& lst);
|
||||
|
||||
//- Assignment operator from initializer list
|
||||
inline void operator=(std::initializer_list<word> lst);
|
||||
|
||||
//- Assignment operator.
|
||||
inline void operator=(const hashedWordList& lst);
|
||||
|
||||
//- Return name corresponding to specified index
|
||||
inline const word& operator[](const label index) const;
|
||||
|
||||
//- Return index corresponding to specified name
|
||||
//- Return index corresponding to specified name, or -1 on failure
|
||||
inline label operator[](const word& name) const;
|
||||
|
||||
//- Does the list contain the specified name - same as found.
|
||||
// Makes hashedWordList suitable as a unary predicate.
|
||||
inline bool operator()(const word& name) const;
|
||||
|
||||
|
||||
// Assignment
|
||||
|
||||
//- Assignment operator from list of words. Rehashes the indices.
|
||||
inline void operator=(const UList<word>& lst);
|
||||
|
||||
//- Assignment operator from initializer list. Rehashes the indices.
|
||||
inline void operator=(std::initializer_list<word> lst);
|
||||
|
||||
//- Assignment operator. Rehashes the indices.
|
||||
inline void operator=(const hashedWordList& lst);
|
||||
|
||||
|
||||
// Istream operators
|
||||
|
||||
friend Istream& operator>>(Istream&, hashedWordList&);
|
||||
friend Ostream& operator<<(Ostream&, const hashedWordList&);
|
||||
friend Istream& operator>>(Istream& is, hashedWordList& lst);
|
||||
friend Ostream& operator<<(Ostream& os, const hashedWordList& lst);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user