mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
- provide a lookupOrDefault constructor form, since this is a fairly
commonly used requirement and simplifies the calling sequence.
Before
dimensionedScalar rhoMax
(
dimensionedScalar::lookupOrDefault
(
"rhoMax",
pimple.dict(),
dimDensity,
GREAT
)
);
After
dimensionedScalar rhoMax("rhoMax", dimDensity, GREAT, pimple.dict());
- read, readIfPresent methods with alternative lookup names.
- Mark the Istream related constructors with compile-time deprecated
warnings.
BUG: read, readIfPresent methods not handling optional dimensions (#1148)
This commit is contained in:
@ -108,6 +108,7 @@ int main(int argc, char *argv[])
|
||||
dict.add("test1", scalar(10));
|
||||
dict.add("test2a", scalar(21));
|
||||
dict.add("test5", dimensionedScalar("", 50));
|
||||
dict.add("carp1", dimensionedScalar("test1", 11));
|
||||
// This will fail to tokenize:
|
||||
// dict.add("test5", dimensionedScalar(50));
|
||||
}
|
||||
@ -126,6 +127,36 @@ int main(int argc, char *argv[])
|
||||
Info<< "test5 : "
|
||||
<< dimensionedScalar::lookupOrAddToDict("test5", dict, -50) << nl;
|
||||
|
||||
// Deprecated
|
||||
Info<< "Deprecated constructors" << nl;
|
||||
Info<< "carp : "
|
||||
<< dimensionedScalar(dict.lookup("carp1")) << nl;
|
||||
|
||||
Info<< "carp : "
|
||||
<< dimensionedScalar("other", dict.lookup("test5")) << nl;
|
||||
|
||||
Info<< "carp : "
|
||||
<< dimensionedScalar("carp", dimless, dict.lookup("carp1")) << nl;
|
||||
|
||||
Info<< "alt : "
|
||||
<< dimensionedScalar("myName", dimless, dict, "carp1") << nl;
|
||||
|
||||
Info<< "alt : "
|
||||
<< dimensionedScalar("myName", dimless, dict, "test5") << nl;
|
||||
|
||||
{
|
||||
dimensionedScalar scalar1("myName", dimless, Zero);
|
||||
|
||||
scalar1.read("test5", dict);
|
||||
Info<< "read in : " << scalar1 << nl;
|
||||
|
||||
scalar1.readIfPresent("test4", dict);
|
||||
Info<< "read in : " << scalar1 << nl;
|
||||
|
||||
scalar1.readIfPresent("test5", dict);
|
||||
Info<< "read in : " << scalar1 << nl;
|
||||
}
|
||||
|
||||
Info<< nl << "Dictionary is now: " << dict << nl;
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
Reference in New Issue
Block a user