mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
stringListOps - allow 'const char*' and 'const std::string&' arguments
This commit is contained in:
@ -44,12 +44,19 @@ SourceFiles
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
//- Return list indices for strings matching the regular expression
|
||||
template<class StringType>
|
||||
labelList findStrings
|
||||
(
|
||||
const char* regexpPattern,
|
||||
const UList<StringType>&
|
||||
);
|
||||
|
||||
//- Return list indices for strings matching the regular expression
|
||||
template<class StringType>
|
||||
labelList findStrings
|
||||
(
|
||||
const string& regexpPattern,
|
||||
const std::string& regexpPattern,
|
||||
const UList<StringType>&
|
||||
);
|
||||
|
||||
|
||||
@ -29,15 +29,11 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class StringType>
|
||||
labelList findStrings
|
||||
Foam::labelList Foam::findStrings
|
||||
(
|
||||
const string& pattern,
|
||||
const char* pattern,
|
||||
const UList<StringType>& lst
|
||||
)
|
||||
{
|
||||
@ -59,7 +55,31 @@ labelList findStrings
|
||||
|
||||
|
||||
template<class StringType>
|
||||
labelList findStrings
|
||||
Foam::labelList Foam::findStrings
|
||||
(
|
||||
const std::string& pattern,
|
||||
const UList<StringType>& lst
|
||||
)
|
||||
{
|
||||
regExp re(pattern);
|
||||
labelList matched(lst.size());
|
||||
|
||||
label matchI = 0;
|
||||
forAll(lst, elemI)
|
||||
{
|
||||
if (re.match(lst[elemI]))
|
||||
{
|
||||
matched[matchI++] = elemI;
|
||||
}
|
||||
}
|
||||
matched.setSize(matchI);
|
||||
|
||||
return matched;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
Foam::labelList Foam::findStrings
|
||||
(
|
||||
const wordRe& wre,
|
||||
const UList<StringType>& lst
|
||||
@ -82,7 +102,7 @@ labelList findStrings
|
||||
|
||||
|
||||
template<class StringType>
|
||||
labelList findStrings
|
||||
Foam::labelList Foam::findStrings
|
||||
(
|
||||
const UList<wordRe>& wreLst,
|
||||
const UList<StringType>& lst
|
||||
@ -109,7 +129,7 @@ labelList findStrings
|
||||
|
||||
|
||||
template<class StringType>
|
||||
bool findStrings
|
||||
bool Foam::findStrings
|
||||
(
|
||||
const UList<wordRe>& wreLst,
|
||||
const StringType& str
|
||||
@ -122,13 +142,9 @@ bool findStrings
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
Reference in New Issue
Block a user