mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: stringOps removeComments and inplaceRemoveComments
- useful for manual handling of string with comments
This commit is contained in:
committed by
Andrew Heather
parent
603849383d
commit
13967565a6
@ -44,6 +44,20 @@ Description
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
void testCommentStripping(const std::string& s)
|
||||
{
|
||||
Info<< "input" << nl
|
||||
<< "========" << nl
|
||||
<< s << nl
|
||||
<< "========" << nl;
|
||||
|
||||
Info<< "output" << nl
|
||||
<< "========" << nl
|
||||
<< stringOps::removeComments(s) << nl
|
||||
<< "========" << nl << nl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
@ -158,6 +172,35 @@ int main(int argc, char *argv[])
|
||||
Info<<"trimRight: " << stringOps::trimRight(test) << endl;
|
||||
Info<<"trim: " << stringOps::trim(test) << endl;
|
||||
|
||||
// Test comment stripping
|
||||
{
|
||||
Info<< nl << "Test comment stripping" << nl;
|
||||
testCommentStripping
|
||||
(
|
||||
"/String without comments/"
|
||||
);
|
||||
testCommentStripping
|
||||
(
|
||||
"Removed some/* C-comments */ / C comments"
|
||||
);
|
||||
testCommentStripping
|
||||
(
|
||||
"Removed some//C++ comments\n / C++ comments"
|
||||
);
|
||||
testCommentStripping
|
||||
(
|
||||
"Partly degenerate C comment </*/ C-comment..."
|
||||
);
|
||||
testCommentStripping
|
||||
(
|
||||
"Truncated C comment </* C-comment..."
|
||||
);
|
||||
testCommentStripping
|
||||
(
|
||||
"Truncated C++ comment <// C++ comment..."
|
||||
);
|
||||
}
|
||||
|
||||
if (false)
|
||||
{
|
||||
Info<<"test move construct - string size:" << test.size() << nl;
|
||||
|
||||
Reference in New Issue
Block a user