Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
e5b3af9c
Commit
e5b3af9c
authored
Feb 08, 2019
by
Mark OLESEN
Committed by
Andrew Heather
Feb 08, 2019
Browse files
ENH: add failsafe version of Enum::get()
parent
27c58dde
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/primitives/enums/Enum.C
View file @
e5b3af9c
...
...
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017-201
8
OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017-201
9
OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
...
...
@@ -77,6 +77,24 @@ EnumType Foam::Enum<EnumType>::get(const word& enumName) const
}
template
<
class
EnumType
>
EnumType
Foam
::
Enum
<
EnumType
>::
get
(
const
word
&
enumName
,
const
EnumType
defaultValue
)
const
{
const
label
idx
=
find
(
enumName
);
if
(
idx
<
0
)
{
return
defaultValue
;
}
return
EnumType
(
vals_
[
idx
]);
}
template
<
class
EnumType
>
EnumType
Foam
::
Enum
<
EnumType
>::
read
(
Istream
&
is
)
const
{
...
...
src/OpenFOAM/primitives/enums/Enum.H
View file @
e5b3af9c
...
...
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017-201
8
OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017-201
9
OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
...
...
@@ -130,6 +130,10 @@ public:
// FatalError if not found.
EnumType
get
(
const
word
&
enumName
)
const
;
//- The enumeration corresponding to the given name.
// \return The enumeration or default if not found.
EnumType
get
(
const
word
&
enumName
,
const
EnumType
defaultValue
)
const
;
//- The name corresponding to the given enumeration.
// Return an empty word if not found.
inline
const
word
&
get
(
const
EnumType
e
)
const
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment