mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: centralize checks for keyword age into Foam::error
STYLE: additional note about include/exclude HashTable.C
This commit is contained in:
@ -943,7 +943,7 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifndef NoHashTableC
|
||||
#ifndef NoHashTableC // Excluded from token.H
|
||||
#ifdef NoRepository
|
||||
#include "HashTable.C"
|
||||
#endif
|
||||
|
||||
@ -272,6 +272,7 @@ namespace Detail
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Previously excluded (via token.H)
|
||||
#ifdef NoRepository
|
||||
#include "HashTable.C"
|
||||
#endif
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,23 +28,6 @@ License
|
||||
#include "dictionary.H"
|
||||
#include "Pstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
// Should issue warning if there is +ve versioning (+ve version number)
|
||||
// and the this version number is older than the current OpenFOAM version
|
||||
// as conveyed by the OPENFOAM compiler define.
|
||||
|
||||
static inline constexpr bool shouldWarnVersion(const int version)
|
||||
{
|
||||
return (version > 0 && version < OPENFOAM);
|
||||
}
|
||||
|
||||
} // End anonymous namespace
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::dictionary::const_searcher Foam::dictionary::csearchCompat
|
||||
@ -61,9 +44,9 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchCompat
|
||||
return finder;
|
||||
}
|
||||
|
||||
for (const std::pair<const char*,int>& iter : compat)
|
||||
for (const std::pair<const char*,int>& alt : compat)
|
||||
{
|
||||
finder = csearch(word::validate(iter.first), matchOpt);
|
||||
finder = csearch(word::validate(alt.first), matchOpt);
|
||||
|
||||
if (finder.good())
|
||||
{
|
||||
@ -71,20 +54,20 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchCompat
|
||||
// Pstream::master() when Pstream has not yet been initialized
|
||||
if
|
||||
(
|
||||
shouldWarnVersion(iter.second)
|
||||
&& (Pstream::parRun() ? Pstream::master() : true)
|
||||
(Pstream::parRun() ? Pstream::master() : true)
|
||||
&& error::warnAboutAge(alt.second)
|
||||
)
|
||||
{
|
||||
std::cerr
|
||||
<< "--> FOAM IOWarning :" << nl
|
||||
<< " Found [v" << iter.second << "] '"
|
||||
<< iter.first << "' entry instead of '"
|
||||
<< " Found [v" << alt.second << "] '"
|
||||
<< alt.first << "' entry instead of '"
|
||||
<< keyword.c_str() << "' in dictionary \""
|
||||
<< name().c_str() << "\" "
|
||||
<< nl
|
||||
<< std::endl;
|
||||
|
||||
error::warnAboutAge("keyword", iter.second);
|
||||
error::warnAboutAge("keyword", alt.second);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@ -38,21 +38,23 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
void Foam::error::warnAboutAge(const char* what, const int version)
|
||||
bool Foam::error::warnAboutAge(const int version) noexcept
|
||||
{
|
||||
if (version <= 0)
|
||||
{
|
||||
// No warning for 0 (unversioned) or -ve values (silent versioning)
|
||||
}
|
||||
else if (version < 1000)
|
||||
{
|
||||
// Warning for things that predate the YYMM versioning
|
||||
// (eg, 240 for version 2.4)
|
||||
std::cerr
|
||||
<< " This " << what << " is very old.\n"
|
||||
<< std::endl;
|
||||
}
|
||||
else if (version < foamVersion::api)
|
||||
return ((version > 0) && (version < foamVersion::api));
|
||||
}
|
||||
|
||||
|
||||
bool Foam::error::warnAboutAge(const char* what, const int version)
|
||||
{
|
||||
// No warning for 0 (unversioned) or -ve values (silent versioning)
|
||||
const bool old = ((version > 0) && (version < foamVersion::api));
|
||||
|
||||
// Note:
|
||||
// No warning for (version >= foamVersion::api), which
|
||||
// can be used to denote future expiry dates of transition features.
|
||||
|
||||
if (old)
|
||||
{
|
||||
const int months =
|
||||
(
|
||||
@ -61,12 +63,22 @@ void Foam::error::warnAboutAge(const char* what, const int version)
|
||||
- (12 * (version/100) + (version % 100))
|
||||
);
|
||||
|
||||
if (version < 1000)
|
||||
{
|
||||
// For things that predate YYMM versioning (eg, 240 for version 2.4)
|
||||
std::cerr
|
||||
<< " This " << what << " is very old.\n"
|
||||
<< std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr
|
||||
<< " This " << what << " is " << months << " months old.\n"
|
||||
<< std::endl;
|
||||
}
|
||||
// No warning for (foamVersion::api < version).
|
||||
// We use this to denote future expiry dates of transition features.
|
||||
}
|
||||
|
||||
return old;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -116,12 +116,18 @@ public:
|
||||
|
||||
// Static Functions
|
||||
|
||||
//- Test if an age warning should be emitted.
|
||||
// \param version is the old version (YYMM) for determining the
|
||||
// age in months compared to the current OpenFOAM version
|
||||
// as conveyed by the \c foamVersion::api value.
|
||||
static bool warnAboutAge(const int version) noexcept;
|
||||
|
||||
//- Emit warning on stderr about something being old.
|
||||
// \param what description for the warning
|
||||
// \param version is the old version (YYMM) for determining the
|
||||
// age in months compared to the current OpenFOAM version
|
||||
// as conveyed by the \c foamVersion::api value.
|
||||
static void warnAboutAge(const char* what, const int version);
|
||||
static bool warnAboutAge(const char* what, const int version);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
@ -124,15 +124,15 @@ void Foam::timeControl::read(const dictionary& dict)
|
||||
{
|
||||
// Accept deprecated 'outputControl' instead of 'writeControl'
|
||||
|
||||
IOWarningInFunction(dict)
|
||||
<< "Using deprecated 'outputControl'" << nl
|
||||
<< " Please use 'writeControl' with 'writeInterval'"
|
||||
<< endl;
|
||||
error::warnAboutAge("outputControl", 1606);
|
||||
|
||||
// Change to the old names for this option
|
||||
controlName = "outputControl";
|
||||
intervalName = "outputInterval";
|
||||
|
||||
IOWarningInFunction(dict)
|
||||
<< "Found deprecated 'outputControl'" << nl
|
||||
<< " Use 'writeControl' with 'writeInterval'"
|
||||
<< endl;
|
||||
error::warnAboutAge("keyword", 1606);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -194,21 +194,6 @@ Foam::argList::initValidTables dummyInitValidTables;
|
||||
|
||||
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
// Should issue warning if there is +ve versioning (+ve version number)
|
||||
// and the this version number is older than the current OpenFOAM version
|
||||
// as conveyed by the OPENFOAM compiler define.
|
||||
|
||||
static inline constexpr bool shouldWarnVersion(const int version)
|
||||
{
|
||||
return (version > 0 && version < OPENFOAM);
|
||||
}
|
||||
|
||||
} // End anonymous namespace
|
||||
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
@ -553,22 +538,22 @@ Foam::word Foam::argList::optionCompat(const word& optName)
|
||||
|
||||
if (fnd.found())
|
||||
{
|
||||
const auto& iter = *fnd;
|
||||
const auto& alt = fnd.val();
|
||||
|
||||
if (shouldWarnVersion(iter.second))
|
||||
if (error::warnAboutAge(alt.second))
|
||||
{
|
||||
std::cerr
|
||||
<< "--> FOAM IOWarning :" << nl
|
||||
<< " Found [v" << iter.second << "] '"
|
||||
<< " Found [v" << alt.second << "] '"
|
||||
<< optName << "' instead of '-"
|
||||
<< iter.first << "' option"
|
||||
<< alt.first << "' option"
|
||||
<< nl
|
||||
<< std::endl;
|
||||
|
||||
error::warnAboutAge("option", iter.second);
|
||||
error::warnAboutAge("option", alt.second);
|
||||
}
|
||||
|
||||
return "-" + iter.first;
|
||||
return "-" + alt.first;
|
||||
}
|
||||
}
|
||||
|
||||
@ -587,23 +572,23 @@ int Foam::argList::optionIgnore(const word& optName)
|
||||
|
||||
if (fnd.found())
|
||||
{
|
||||
const auto& iter = *fnd;
|
||||
const auto& alt = fnd.val();
|
||||
|
||||
// Number to skip (including the option itself)
|
||||
// '-option ARG' or '-option'
|
||||
const int nskip = (iter.first ? 2 : 1);
|
||||
const int nskip = (alt.first ? 2 : 1);
|
||||
|
||||
if (shouldWarnVersion(iter.second))
|
||||
if (error::warnAboutAge(alt.second))
|
||||
{
|
||||
std::cerr
|
||||
<< "--> FOAM IOWarning :" << nl
|
||||
<< " Ignoring [v" << iter.second << "] '-"
|
||||
<< " Ignoring [v" << alt.second << "] '-"
|
||||
<< optName << (nskip > 1 ? " ARG" : "")
|
||||
<< "' option"
|
||||
<< nl
|
||||
<< std::endl;
|
||||
|
||||
error::warnAboutAge("option", iter.second);
|
||||
error::warnAboutAge("option", alt.second);
|
||||
}
|
||||
|
||||
return nskip;
|
||||
|
||||
Reference in New Issue
Block a user