ENH: implement stringOps - trim, trimRight, inplaceTrim, inplaceTrimRight

This commit is contained in:
Mark Olesen
2011-02-23 10:13:10 +01:00
parent b7429ef5c4
commit 71d21f6de4
2 changed files with 44 additions and 11 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -26,6 +26,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "string.H"
#include "stringOps.H"
#include "IOstreams.H"
using namespace Foam;
@ -35,11 +36,19 @@ using namespace Foam;
int main(int argc, char *argv[])
{
string test("$HOME kjhkjhkjh \" \\$HOME/tyetyery ${FOAM_RUN} \n ; hkjh ;$");
string test
(
" $HOME kjhkjhkjh \" \\$HOME/tyetyery ${FOAM_RUN} \n ; hkjh ;$ "
);
Info<< "string:" << test << nl << "hash:"
<< unsigned(string::hash()(test)) << endl;
Info<<"trimLeft: " << stringOps::trimLeft(test) << endl;
Info<<"trimRight: " << stringOps::trimRight(test) << endl;
Info<<"trim: " << stringOps::trim(test) << endl;
// test sub-strings via iterators
string::const_iterator iter = test.end();
string::const_iterator iter2 = test.end();