mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add ROOTGREAT constants (symmetry with ROOTSMALL)
ENH: add some scalar constants for .org compatibility (#1881) Although it can very much be a moving target, it can prove partly useful to have some compatibility constants/methods. - The wholesale change of 'GREAT' -> 'great' etc (JAN-2018), makes user coding for multiple versions problematic. When COMPAT_OPENFOAM_ORG is defined, now define constants (aliases) named as per the openfoam.org version. Values, however, remain identical. - For type-safe dictionary value retrieval, we have the templated get<> methods added around NOV-2018 and deprecated the lookupType method. The .org version followed suit in NOV-2019, but opted for renaming the templated lookupType method as a templated 'lookup' method. Using this is discouraged, but allowed when COMPAT_OPENFOAM_ORG is defined.
This commit is contained in:
@ -1 +1 @@
|
||||
EXE_INC =
|
||||
EXE_INC = -DCOMPAT_OPENFOAM_ORG
|
||||
|
||||
@ -410,6 +410,30 @@ int main(int argc, char *argv[])
|
||||
// try_getScalar(dict2.findEntry("bad"), "bad");
|
||||
try_getScalar(dict2.findEntry("empty"), "empty");
|
||||
}
|
||||
|
||||
#ifdef COMPAT_OPENFOAM_ORG
|
||||
{
|
||||
Info<< nl
|
||||
<< "Test openfoam.org compatibility" << nl;
|
||||
|
||||
dictionary mydict
|
||||
(
|
||||
IStringStream
|
||||
(
|
||||
"scalar 3.14159;\n"
|
||||
"label 10;\n"
|
||||
)()
|
||||
);
|
||||
|
||||
Info<<"get<scalar> : " << mydict.get<scalar>("scalar") << nl;
|
||||
Info<<"get<label> : " << mydict.get<label>("label") << nl;
|
||||
|
||||
Info<<"lookup<scalar> : " << mydict.lookup<scalar>("scalar") << nl;
|
||||
Info<<"lookup<label> : " << mydict.lookup<label>("label") << nl;
|
||||
}
|
||||
#else
|
||||
Info<< "No openfoam.org compatibility methods" << nl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
EXE_INC = \
|
||||
-DCOMPAT_OPENFOAM_ORG \
|
||||
-I$(LIB_SRC)/fileFormats/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
|
||||
@ -69,7 +69,7 @@ inline Switch readSwitch(const std::string& str)
|
||||
|
||||
void printInfo(const Switch& sw)
|
||||
{
|
||||
Info<<"Switch " << sw.c_str() << " (enum=" << label(sw.type()) << ")\n";
|
||||
Info<< "Switch " << sw.c_str() << " (enum=" << label(sw.type()) << ")\n";
|
||||
}
|
||||
|
||||
|
||||
@ -86,6 +86,13 @@ Ostream& toString(Ostream& os, const UList<char>& list)
|
||||
}
|
||||
|
||||
|
||||
template<class T1, class T2>
|
||||
void printValPair(const char* desc, const T1& val1, const T2& val2)
|
||||
{
|
||||
Info<< desc << ' ' << val1 << ' ' << val2 << nl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
@ -360,6 +367,21 @@ int main(int argc, char *argv[])
|
||||
<< "Read " << flatOutput(dstList) << nl;
|
||||
}
|
||||
|
||||
#ifdef COMPAT_OPENFOAM_ORG
|
||||
Info<< nl << "compatibility sizes" << nl
|
||||
<< "name com org" << nl
|
||||
<< "---- --- ---" << nl;
|
||||
|
||||
printValPair("SMALL", SMALL, small);
|
||||
printValPair("GREAT", GREAT, great);
|
||||
printValPair("VSMALL", VSMALL, vSmall);
|
||||
printValPair("VGREAT", VGREAT, vGreat);
|
||||
printValPair("ROOTSMALL", ROOTSMALL, rootSmall);
|
||||
printValPair("ROOTGREAT", ROOTGREAT, rootGreat);
|
||||
#else
|
||||
Info<< nl << "no compatibility sizes" << nl;
|
||||
#endif
|
||||
|
||||
if (nFail)
|
||||
{
|
||||
Info<< nl << "failed " << nFail << " tests" << nl;
|
||||
|
||||
Reference in New Issue
Block a user