Commit 7ab7eaa4 authored by Mark Olesen's avatar Mark Olesen
Browse files

stringListOps - allow 'const char*' and 'const std::string&' arguments

parent a83961a0
......@@ -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,35 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
template<class StringType>
Foam::labelList Foam::findStrings
(
const char* 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>
labelList findStrings
Foam::labelList Foam::findStrings
(
const string& pattern,
const std::string& pattern,
const UList<StringType>& lst
)
{
......@@ -59,7 +79,7 @@ labelList findStrings
template<class StringType>
labelList findStrings
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
// ************************************************************************* //
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment