Missing file
This commit is contained in:
parent
d92cbc982f
commit
6d0c34e97d
1 changed files with 308 additions and 0 deletions
308
src/OpenFOAM/primitives/Lists/stringListOps.H
Normal file
308
src/OpenFOAM/primitives/Lists/stringListOps.H
Normal file
|
@ -0,0 +1,308 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright held by original author
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
InNamspace
|
||||
Foam
|
||||
|
||||
Description
|
||||
Operations on lists of strings.
|
||||
|
||||
SourceFiles
|
||||
stringListOpsTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef stringListOps_H
|
||||
#define stringListOps_H
|
||||
|
||||
#include "regExp.H"
|
||||
#include "labelList.H"
|
||||
#include "stringList.H"
|
||||
#include "wordReList.H"
|
||||
#include "wordReListMatcher.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
// single-string matches:
|
||||
|
||||
//- Return true if string matches one of the regular expressions
|
||||
inline bool findStrings
|
||||
(
|
||||
const wordReListMatcher& matcher,
|
||||
const std::string& str
|
||||
)
|
||||
{
|
||||
return matcher.match(str);
|
||||
}
|
||||
|
||||
// multi-string matches:
|
||||
|
||||
//- Return list indices for matching strings
|
||||
template<class Matcher, class StringType>
|
||||
labelList findMatchingStrings
|
||||
(
|
||||
const Matcher&,
|
||||
const UList<StringType>&,
|
||||
const bool invert=false
|
||||
);
|
||||
|
||||
//- Return list indices for strings matching the regular expression
|
||||
// Template partial specialization of findMatchingStrings
|
||||
template<class StringType>
|
||||
labelList findStrings
|
||||
(
|
||||
const regExp& re,
|
||||
const UList<StringType>& lst,
|
||||
const bool invert=false
|
||||
)
|
||||
{
|
||||
return findMatchingStrings(re, lst, invert);
|
||||
}
|
||||
|
||||
//- Return list indices for strings matching the regular expression
|
||||
// Template partial specialization of findMatchingStrings
|
||||
template<class StringType>
|
||||
labelList findStrings
|
||||
(
|
||||
const char* rePattern,
|
||||
const UList<StringType>& lst,
|
||||
const bool invert=false
|
||||
)
|
||||
{
|
||||
return findStrings(regExp(rePattern), lst, invert);
|
||||
}
|
||||
|
||||
//- Return list indices for strings matching the regular expression
|
||||
// Template partial specialization of findMatchingStrings
|
||||
template<class StringType>
|
||||
labelList findStrings
|
||||
(
|
||||
const std::string& rePattern,
|
||||
const UList<StringType>& lst,
|
||||
const bool invert=false
|
||||
)
|
||||
{
|
||||
return findMatchingStrings(regExp(rePattern), lst, invert);
|
||||
}
|
||||
|
||||
//- Return list indices for strings matching the regular expression
|
||||
// Template partial specialization of findMatchingStrings
|
||||
template<class StringType>
|
||||
labelList findStrings
|
||||
(
|
||||
const wordRe& wre,
|
||||
const UList<StringType>& lst,
|
||||
const bool invert=false
|
||||
)
|
||||
{
|
||||
return findMatchingStrings(wre, lst, invert);
|
||||
}
|
||||
|
||||
|
||||
//- Return list indices for strings matching one of the regular expression
|
||||
// Template partial specialization of findMatchingStrings
|
||||
template<class StringType>
|
||||
labelList findStrings
|
||||
(
|
||||
const wordReListMatcher& matcher,
|
||||
const UList<StringType>& lst,
|
||||
const bool invert=false
|
||||
)
|
||||
{
|
||||
return findMatchingStrings(matcher, lst, invert);
|
||||
}
|
||||
|
||||
// subsetting multi-string matches (similar to ListOp):
|
||||
|
||||
//- Extract elements of StringList when regular expression matches
|
||||
// optionally invert the match
|
||||
// eg, to extract all selected elements:
|
||||
// subsetMatchingStrings<regExp, stringList>(myRegExp, lst);
|
||||
template<class Matcher, class StringListType>
|
||||
StringListType subsetMatchingStrings
|
||||
(
|
||||
const Matcher&,
|
||||
const StringListType&,
|
||||
const bool invert=false
|
||||
);
|
||||
|
||||
//- Extract elements of StringList when regular expression matches
|
||||
// Template partial specialization of subsetMatchingStrings
|
||||
template<class StringListType>
|
||||
StringListType subsetStrings
|
||||
(
|
||||
const regExp& re,
|
||||
const StringListType& lst,
|
||||
const bool invert=false
|
||||
)
|
||||
{
|
||||
return subsetMatchingStrings(re, lst, invert);
|
||||
}
|
||||
|
||||
//- Extract elements of StringList when regular expression matches
|
||||
// Template partial specialization of subsetMatchingStrings
|
||||
template<class StringListType>
|
||||
StringListType subsetStrings
|
||||
(
|
||||
const char* rePattern,
|
||||
const StringListType& lst,
|
||||
const bool invert=false
|
||||
)
|
||||
{
|
||||
return subsetMatchingStrings(regExp(rePattern), lst, invert);
|
||||
}
|
||||
|
||||
//- Extract elements of StringList when regular expression matches
|
||||
// Template partial specialization of subsetMatchingStrings
|
||||
template<class StringListType>
|
||||
StringListType subsetStrings
|
||||
(
|
||||
const std::string& rePattern,
|
||||
const StringListType& lst,
|
||||
const bool invert=false
|
||||
)
|
||||
{
|
||||
return subsetMatchingStrings(regExp(rePattern), lst, invert);
|
||||
}
|
||||
|
||||
//- Extract elements of StringList when regular expression matches
|
||||
// Template partial specialization of subsetMatchingStrings
|
||||
template<class StringListType>
|
||||
StringListType subsetStrings
|
||||
(
|
||||
const wordRe& wre,
|
||||
const StringListType& lst,
|
||||
const bool invert=false
|
||||
)
|
||||
{
|
||||
return subsetMatchingStrings(wre, lst, invert);
|
||||
}
|
||||
|
||||
//- Extract elements of StringList when regular expression matches
|
||||
// Template partial specialization of subsetMatchingStrings
|
||||
template<class StringListType>
|
||||
StringListType subsetStrings
|
||||
(
|
||||
const wordReListMatcher& matcher,
|
||||
const StringListType& lst,
|
||||
const bool invert=false
|
||||
)
|
||||
{
|
||||
return subsetMatchingStrings(matcher, lst, invert);
|
||||
}
|
||||
|
||||
|
||||
//- Inplace extract elements of StringList when regular expression matches
|
||||
// optionally invert the match
|
||||
// eg, to extract all selected elements:
|
||||
// inplaceSubsetMatchingStrings<regExp, stringList>(myRegExp, lst);
|
||||
template<class Matcher, class StringListType>
|
||||
void inplaceSubsetMatchingStrings
|
||||
(
|
||||
const Matcher&,
|
||||
StringListType&,
|
||||
const bool invert=false
|
||||
);
|
||||
|
||||
//- Inplace extract elements of StringList when regular expression matches
|
||||
// Template partial specialization of inplaceSubsetMatchingStrings
|
||||
template<class StringListType>
|
||||
void inplaceSubsetStrings
|
||||
(
|
||||
const regExp& re,
|
||||
StringListType& lst,
|
||||
const bool invert=false
|
||||
)
|
||||
{
|
||||
inplaceSubsetMatchingStrings(re, lst, invert);
|
||||
}
|
||||
|
||||
//- Inplace extract elements of StringList when regular expression matches
|
||||
// Template partial specialization of inplaceSubsetMatchingStrings
|
||||
template<class StringListType>
|
||||
void inplaceSubsetStrings
|
||||
(
|
||||
const char* rePattern,
|
||||
StringListType& lst,
|
||||
const bool invert=false
|
||||
)
|
||||
{
|
||||
inplaceSubsetMatchingStrings(regExp(rePattern), lst, invert);
|
||||
}
|
||||
|
||||
//- Inplace extract elements of StringList when regular expression matches
|
||||
// Template partial specialization of inplaceSubsetMatchingStrings
|
||||
template<class StringListType>
|
||||
void inplaceSubsetStrings
|
||||
(
|
||||
const std::string& rePattern,
|
||||
StringListType& lst,
|
||||
const bool invert=false
|
||||
)
|
||||
{
|
||||
inplaceSubsetMatchingStrings(regExp(rePattern), lst, invert);
|
||||
}
|
||||
|
||||
//- Inplace extract elements of StringList when regular expression matches
|
||||
// Template partial specialization of inplaceSubsetMatchingStrings
|
||||
template<class StringListType>
|
||||
void inplaceSubsetStrings
|
||||
(
|
||||
const wordRe& wre,
|
||||
StringListType& lst,
|
||||
const bool invert=false
|
||||
)
|
||||
{
|
||||
inplaceSubsetMatchingStrings(wre, lst, invert);
|
||||
}
|
||||
|
||||
//- Inplace extract elements of StringList when regular expression matches
|
||||
// Template partial specialization of inplaceSubsetMatchingStrings
|
||||
template<class StringListType>
|
||||
void inplaceSubsetStrings
|
||||
(
|
||||
const wordReListMatcher& matcher,
|
||||
StringListType& lst,
|
||||
const bool invert=false
|
||||
)
|
||||
{
|
||||
inplaceSubsetMatchingStrings(matcher, lst, invert);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "stringListOpsTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
Reference in a new issue