ENH: add value_type to dimensioned type. Add Switch::name(bool)
This commit is contained in:
parent
311f29947d
commit
4d18fea8e1
@ -44,7 +44,7 @@ void testTransfer1(autoPtr<labelList> ap)
|
||||
// Passed in copy, so automatically removes content
|
||||
// Transfer would be nice, but not actually needed
|
||||
|
||||
Info<< "recv " << Switch(ap.valid()).c_str() << nl;
|
||||
Info<< "recv " << Switch::name(ap.valid()) << nl;
|
||||
}
|
||||
|
||||
|
||||
@ -53,7 +53,7 @@ void testTransfer1(autoPtr<labelList> ap)
|
||||
void testTransfer2(autoPtr<labelList>&& ap)
|
||||
{
|
||||
// As rvalue, so this time we actually get to manage content
|
||||
Info<< "recv " << Switch(ap.valid()).c_str() << nl;
|
||||
Info<< "recv " << Switch::name(ap.valid()) << nl;
|
||||
}
|
||||
|
||||
|
||||
@ -161,7 +161,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
testTransfer2(std::move(list));
|
||||
|
||||
Info<<"now have valid=" << Switch(list.valid()).c_str();
|
||||
Info<<"now have valid=" << Switch::name(list.valid());
|
||||
|
||||
if (list)
|
||||
{
|
||||
@ -209,7 +209,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
testTransfer2(std::move(list));
|
||||
|
||||
Info<<"now have valid=" << Switch(list.valid()).c_str();
|
||||
Info<<"now have valid=" << Switch::name(list.valid());
|
||||
|
||||
if (list.valid())
|
||||
{
|
||||
|
@ -114,6 +114,9 @@ class dimensioned
|
||||
|
||||
public:
|
||||
|
||||
//- The underlying data type
|
||||
typedef Type value_type;
|
||||
|
||||
//- Component type
|
||||
typedef typename pTraits<Type>::cmptType cmptType;
|
||||
|
||||
@ -157,7 +160,7 @@ public:
|
||||
// If the optional dimensions are present, they are read and
|
||||
// used without further verification.
|
||||
// If no dimensions are found, the quantity is dimensionless.
|
||||
// Fatal if not a primitiveEntry or if the number of tokens is incorrect.
|
||||
// Fatal if not primitiveEntry or if number of tokens is incorrect.
|
||||
explicit dimensioned(const primitiveEntry& e);
|
||||
|
||||
//- Construct from primitive entry with given name and dimensions.
|
||||
@ -168,7 +171,7 @@ public:
|
||||
// If the optional name is found, it is used for renaming.
|
||||
// If the optional dimensions are present, they are read and
|
||||
// verified against the expected dimensions.
|
||||
// Fatal if not a primitiveEntry or if the number of tokens is incorrect.
|
||||
// Fatal if not primitiveEntry or if number of tokens is incorrect.
|
||||
explicit dimensioned(const primitiveEntry& e, const dimensionSet& dims);
|
||||
|
||||
//- Construct from dictionary lookup with a given name.
|
||||
|
@ -56,6 +56,12 @@ static const char* names[9] =
|
||||
|
||||
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
const char* Foam::Switch::name(const bool b) noexcept
|
||||
{
|
||||
return names[(b ? 0 : 1)];
|
||||
}
|
||||
|
||||
|
||||
Foam::Switch::switchType Foam::Switch::parse
|
||||
(
|
||||
const std::string& str,
|
||||
|
@ -189,6 +189,12 @@ public:
|
||||
);
|
||||
|
||||
|
||||
// Static Member Functions
|
||||
|
||||
//- A string representation of bool as "false" / "true"
|
||||
static const char* name(const bool b) noexcept;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- True if the Switch represents a valid enumeration
|
||||
|
Loading…
Reference in New Issue
Block a user