reworked stringListOps to improve the flexibility

- added subsetStrings and inplaceSubsetString

- added class wordReListMatcher to wrap a match() for a UList<wordRe>
This commit is contained in:
Mark Olesen
2009-10-08 11:32:26 +02:00
parent 1194af6a8a
commit c45ea2c4f1
12 changed files with 511 additions and 135 deletions

View File

@ -27,6 +27,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "stringListOps.H"
#include "IStringStream.H"
#include "IOstreams.H"
using namespace Foam;
@ -36,21 +37,59 @@ using namespace Foam;
int main(int argc, char *argv[])
{
stringList sl(3);
sl[0] = "hello";
sl[1] = "heello";
sl[2] = "heeello";
stringList strLst
(
IStringStream
(
"("
"\"hello\""
"\"heello\""
"\"heeello\""
"\"bye\""
"\"bbye\""
"\"bbbye\""
"\"okey\""
"\"okkey\""
"\"okkkey\""
")"
)()
);
labelList matches = findStrings(".*ee.*", sl);
wordReList reLst(IStringStream("( okey \"[hy]e+.*\" )")());
Info<< "matches found for regexp .*ee.* : ";
Info<< "stringList " << strLst << nl;
labelList matches = findStrings(".*ee.*", strLst);
Info<< "matches found for regexp .*ee.* :" << nl << matches << nl;
forAll(matches, i)
{
Info<< " " << sl[matches[i]];
Info<< " -> " << strLst[matches[i]] << nl;
}
Info<< endl;
Info << "End\n" << endl;
matches = findStrings(reLst, strLst);
Info<< "matches found for " << reLst << nl << matches << nl;
forAll(matches, i)
{
Info<< " -> " << strLst[matches[i]] << nl;
}
Info<< endl;
stringList subLst = subsetStrings(".*ee.*", strLst);
Info<< "subset stringList: " << subLst << nl;
subLst = subsetStrings(reLst, strLst);
Info<< "subset stringList: " << subLst << nl;
inplaceSubsetStrings(reLst, strLst);
Info<< "subsetted stringList: " << strLst << nl;
inplaceSubsetStrings(".*l.*", strLst);
Info<< "subsetted stringList: " << strLst << nl;
Info<< "\nEnd\n" << endl;
return 0;
}