From e3d9084c62ae46790d85b992254c4853cf0aeadd Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 10 Feb 2017 09:55:37 +0100 Subject: [PATCH] ENH: support ASCII List output on a single-line - Introduce writeList(Ostream&, label) method in various List classes to provide more flexibility and avoid hard-coded limits when deciding if a list is too long and should be broken up into multiple lines (ASCII only). - The old hard-code limit (10) is retained in the operator<< versions - This functionality is wrapped in the FlatOutput output adapter class and directly accessible via the 'flatOutput()' function. Eg, #include "ListOps.H" Info<< "methods: " << flatOutput(myLongList) << endl; // OR Info<< "methods: "; myLongList.writeList(os) << endl; --- applications/test/List/Test-List.C | 34 +++- .../test/PackedList4/Test-PackedList4.C | 13 +- .../containers/Lists/FixedList/FixedList.H | 5 +- .../containers/Lists/FixedList/FixedListIO.C | 159 ++++++++++-------- .../containers/Lists/ListOps/FlatOutput.H | 96 +++++++++++ .../containers/Lists/ListOps/ListOps.H | 3 +- .../containers/Lists/PackedList/PackedList.C | 28 ++- .../containers/Lists/PackedList/PackedList.H | 42 +++-- .../Lists/UIndirectList/UIndirectList.H | 12 +- .../Lists/UIndirectList/UIndirectListIO.C | 41 +++-- src/OpenFOAM/containers/Lists/UList/UList.H | 5 +- src/OpenFOAM/containers/Lists/UList/UListIO.C | 33 +++- 12 files changed, 325 insertions(+), 146 deletions(-) create mode 100644 src/OpenFOAM/containers/Lists/ListOps/FlatOutput.H diff --git a/applications/test/List/Test-List.C b/applications/test/List/Test-List.C index fc8fab5178..bbba8219b3 100644 --- a/applications/test/List/Test-List.C +++ b/applications/test/List/Test-List.C @@ -40,7 +40,6 @@ See also #include "IStringStream.H" #include "scalar.H" #include "vector.H" -#include "ListOps.H" #include "labelRange.H" #include "ListOps.H" @@ -140,11 +139,36 @@ int main(int argc, char *argv[]) Info<< "Elements " << map << " out of " << list3 << " => " << subList3 << endl; + // test flattened output + { + Info<< nl; + + labelList longLabelList = identity(15); + + Info<< "labels (contiguous=" << contiguous