ENH: improvements to IOstreamOption
* Support default values for format/compress enum lookups. - Avoids situations where the preferred default format is not ASCII. For example, with dictionary input: format binar; The typing mistake would previously have caused formatEnum to default to ASCII. We can now properly control its behaviour. IOstream::formatEnum ( dict.get<word>("format"), IOstream::BINARY ); Allowing us to switch ascii/binary, using BINARY by default even in the case of spelling mistakes. The mistakes are flagged, but the return value can be non-ASCII. * The format/compression lookup behave as pass-through if the lookup string is empty. - Allows the following to work without complaint IOstream::formatEnum ( dict.getOrDefault("format", word::null), IOstream::BINARY ); - Or use constructor-like failsafe method IOstream::formatEnum("format", dict, IOstream::BINARY); - Apply the same behaviour with setting stream format/compression from a word. is.format("binar"); will emit a warning, but leave the stream format UNCHANGED * Rationalize versionNumber construction - constexpr constructors where possible. Default construct is the "currentVersion" - Construct from token to shift the burden to versionNumber. Support token as argument to version(). Now: is.version(headerDict.get<token>("version")); or failsafe constructor method is.version ( IOstreamOption::versionNumber("version", headerDict) ); Before (controlled input): is.version ( IOstreamOption::versionNumber ( headerDict.get<float>("version") ) ); Old, uncontrolled input - has been removed: is.version(headerDict.lookup("version")); * improve consistency, default behaviour for IOstreamOption construct - constexpr constructors where possible - add copy construct with change of format. - construct IOstreamOption from streamFormat is now non-explicit. This is a commonly expected result with no ill-effects
Showing
- applications/test/sizeof/Test-sizeof.C 9 additions, 4 deletionsapplications/test/sizeof/Test-sizeof.C
- src/OpenFOAM/db/IOobject/IOobjectReadHeader.C 2 additions, 9 deletionssrc/OpenFOAM/db/IOobject/IOobjectReadHeader.C
- src/OpenFOAM/db/IOobjects/decomposedBlockData/decomposedBlockData.C 1 addition, 7 deletions...AM/db/IOobjects/decomposedBlockData/decomposedBlockData.C
- src/OpenFOAM/db/IOstreams/IOstreams/IOstreamOption.C 129 additions, 33 deletionssrc/OpenFOAM/db/IOstreams/IOstreams/IOstreamOption.C
- src/OpenFOAM/db/IOstreams/IOstreams/IOstreamOption.H 202 additions, 107 deletionssrc/OpenFOAM/db/IOstreams/IOstreams/IOstreamOption.H
- src/OpenFOAM/db/Time/TimeIO.C 2 additions, 8 deletionssrc/OpenFOAM/db/Time/TimeIO.C
- src/functionObjects/lagrangian/vtkCloud/vtkCloud.C 4 additions, 8 deletionssrc/functionObjects/lagrangian/vtkCloud/vtkCloud.C
- src/functionObjects/utilities/ensightWrite/ensightWrite.C 2 additions, 8 deletionssrc/functionObjects/utilities/ensightWrite/ensightWrite.C
- src/functionObjects/utilities/vtkWrite/vtkWrite.C 5 additions, 12 deletionssrc/functionObjects/utilities/vtkWrite/vtkWrite.C
- src/surfMesh/surfaceFormats/vtk/VTKsurfaceFormatCore.C 7 additions, 11 deletionssrc/surfMesh/surfaceFormats/vtk/VTKsurfaceFormatCore.C
- src/surfMesh/surfaceFormats/vtp/VTPsurfaceFormatCore.C 7 additions, 11 deletionssrc/surfMesh/surfaceFormats/vtp/VTPsurfaceFormatCore.C
- src/surfMesh/writers/ensight/ensightSurfaceWriter.C 2 additions, 8 deletionssrc/surfMesh/writers/ensight/ensightSurfaceWriter.C
- src/surfMesh/writers/raw/rawSurfaceWriter.C 2 additions, 5 deletionssrc/surfMesh/writers/raw/rawSurfaceWriter.C
- src/surfMesh/writers/vtk/vtkSurfaceWriter.C 7 additions, 13 deletionssrc/surfMesh/writers/vtk/vtkSurfaceWriter.C