From 12c903bba80bec7ab2c5142ee1330f00706c8309 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 19 Sep 2018 15:32:04 +0200 Subject: [PATCH] ENH: define nameOp<>, typeOp<>, sizeOp<> functors (issue #1013) --- applications/test/fileName/Test-fileName.C | 1 + applications/test/string/Test-string.C | 31 +++++++++---------- .../foamRestoreFields/foamRestoreFields.C | 4 +-- src/OpenFOAM/containers/Lists/UList/UList.H | 13 +++++++- src/OpenFOAM/primitives/Scalar/Scalar.H | 14 ++++++++- .../primitives/VectorSpace/VectorSpace.H | 4 +-- src/OpenFOAM/primitives/ints/int16/int16.H | 15 +++++++-- src/OpenFOAM/primitives/ints/int32/int32.H | 16 ++++++++-- src/OpenFOAM/primitives/ints/int64/int64.H | 16 ++++++++-- src/OpenFOAM/primitives/ints/uint16/uint16.H | 16 ++++++++-- src/OpenFOAM/primitives/ints/uint32/uint32.H | 15 +++++++-- src/OpenFOAM/primitives/ints/uint64/uint64.H | 16 ++++++++-- .../primitives/strings/fileName/fileName.C | 2 +- .../primitives/strings/fileName/fileName.H | 2 +- src/OpenFOAM/primitives/strings/word/word.H | 28 +++++++++++++++-- 15 files changed, 149 insertions(+), 44 deletions(-) diff --git a/applications/test/fileName/Test-fileName.C b/applications/test/fileName/Test-fileName.C index 42b3fe4d7a..3ad28e5f77 100644 --- a/applications/test/fileName/Test-fileName.C +++ b/applications/test/fileName/Test-fileName.C @@ -617,6 +617,7 @@ int main(int argc, char *argv[]) fileName pathName(wrdList); Info<< "pathName = " << pathName << nl + << "nameOp = " << nameOp()(pathName) << nl << "pathName.name() = >" << pathName.name() << "<\n" << "pathName.path() = " << pathName.path() << nl << "pathName.ext() = >" << pathName.ext() << "<\n" diff --git a/applications/test/string/Test-string.C b/applications/test/string/Test-string.C index 2d6bdfac2e..81c126b8af 100644 --- a/applications/test/string/Test-string.C +++ b/applications/test/string/Test-string.C @@ -271,32 +271,31 @@ int main(int argc, char *argv[]) Info<< "hash: = " << word::printf("0x%012X", string::hash()(s2)) << endl; - // test formatting on int + // Test formatting on int { label val = 25; - Info<<"val: " << val << "\n"; - - Info<< "int " << val << " as word >" - << Foam::name(val) << "< or " - << word::printf("formatted >%08d<", val) << "\n"; + Info<< "int " << val << " nameOp='" + << nameOp