mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -66,20 +66,23 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (true)
|
||||
{
|
||||
cout<<"IOstreamOption:" << sizeof(IOstreamOption) << nl;
|
||||
cout<<"IOstream:" << sizeof(IOstream) << nl;
|
||||
cout<<"Istream:" << sizeof(Istream) << nl;
|
||||
cout<<"IPstream:" << sizeof(IPstream) << nl;
|
||||
cout<<"ISstream:" << sizeof(ISstream) << nl;
|
||||
|
||||
cout<<"Ostream:" << sizeof(Ostream) << nl;
|
||||
cout<<"OPstream:" << sizeof(OPstream) << nl;
|
||||
|
||||
cout<<"ISstream:" << sizeof(ISstream) << nl;
|
||||
cout<<"OSstream:" << sizeof(OSstream) << nl;
|
||||
|
||||
cout<<"IPstream:" << sizeof(IPstream) << nl;
|
||||
cout<<"OPstream:" << sizeof(OPstream) << nl;
|
||||
}
|
||||
|
||||
{
|
||||
nil x;
|
||||
cout<<"nil:" << sizeof(x) << nl;
|
||||
}
|
||||
#if 0
|
||||
{
|
||||
argList x(argc, argv);
|
||||
cout<<"argList:" << sizeof(x) << nl;
|
||||
@ -87,6 +90,7 @@ int main(int argc, char *argv[])
|
||||
TimePaths y(x);
|
||||
cout<<"TimePaths:" << sizeof(y) << nl;
|
||||
}
|
||||
#endif
|
||||
{
|
||||
zero x;
|
||||
cout<<"zero:" << sizeof(x) << nl;
|
||||
@ -117,6 +121,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
{
|
||||
cout<<"short:" << sizeof(short) << nl;
|
||||
cout<<"int:" << sizeof(int) << nl;
|
||||
cout<<"long:" << sizeof(long) << nl;
|
||||
cout<<"float:" << sizeof(float) << nl;
|
||||
|
||||
Reference in New Issue
Block a user