mirror of
https://github.com/OpenFOAM/OpenFOAM-6.git
synced 2025-12-08 06:57:46 +00:00
NamedEnum: Check range of names array index to avoid warning from gcc
This commit is contained in:
committed by
Chris Greenshields
parent
6db30e661c
commit
c60fb65681
@ -3,7 +3,7 @@
|
||||
# ========= |
|
||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
# \\ / O peration |
|
||||
# \\ / A nd | Copyright (C) 2015-2017 OpenFOAM Foundation
|
||||
# \\ / A nd | Copyright (C) 2015-2018 OpenFOAM Foundation
|
||||
# \\/ M anipulation |
|
||||
#-------------------------------------------------------------------------------
|
||||
# License
|
||||
@ -44,7 +44,6 @@ usage() {
|
||||
cat <<USAGE
|
||||
|
||||
Usage: ${0##*/} [OPTIONS] ...
|
||||
options:
|
||||
options:
|
||||
-case | -c <dir> specify case directory (default = local dir)
|
||||
-dir | -d <dir> post-processing directory <dir> (default = postProcessing)
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -120,4 +120,25 @@ Foam::wordList Foam::NamedEnum<Enum, nEnum>::words()
|
||||
}
|
||||
|
||||
|
||||
template<class Enum, unsigned int nEnum>
|
||||
const char* Foam::NamedEnum<Enum, nEnum>::operator[](const Enum e) const
|
||||
{
|
||||
unsigned int ue = unsigned(e);
|
||||
|
||||
if (ue < nEnum)
|
||||
{
|
||||
return names[ue];
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "names array index " << ue << " out of range 0-"
|
||||
<< nEnum - 1
|
||||
<< exit(FatalError);
|
||||
|
||||
return names[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -38,7 +38,6 @@ SourceFiles
|
||||
#include "HashTable.H"
|
||||
#include "stringList.H"
|
||||
#include "wordList.H"
|
||||
#include <type_traits>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -108,10 +107,7 @@ public:
|
||||
}
|
||||
|
||||
//- Return the name of the given enumeration element
|
||||
const char* operator[](const Enum e) const
|
||||
{
|
||||
return names[unsigned(e)];
|
||||
}
|
||||
const char* operator[](const Enum e) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user