ENH: consistency improvements for keyType and wordRe
- simplify compile/uncompile, reading, assignment - implicit construct wordRe from keyType (was explicit) to simplify future API changes. - make Foam::isspace consistent with std::isspace (C-locale) by including vertical tab and form feed ENH: improve #ifeq float/label comparisons
This commit is contained in:
committed by
Andrew Heather
parent
57c1fceabf
commit
96a1b86fb9
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -59,6 +59,26 @@ inline bool Foam::string::hasExt() const
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::string::hasExt(const char* ending) const
|
||||
{
|
||||
return (ending && string::hasExt(std::string(ending)));
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::string::hasExt(const std::string& ending) const
|
||||
{
|
||||
const auto len = ending.size();
|
||||
auto i = find_ext();
|
||||
if (i == npos || !len)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
++i; // Compare *after* the dot
|
||||
return ((size() - i) == len) && !compare(i, npos, ending);
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::string::removePath()
|
||||
{
|
||||
const auto i = rfind('/');
|
||||
@ -128,12 +148,12 @@ inline Foam::string::string(const size_type len, const char c)
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class String>
|
||||
template<class StringType>
|
||||
inline bool Foam::string::valid(const std::string& str)
|
||||
{
|
||||
for (auto iter = str.cbegin(); iter != str.cend(); ++iter)
|
||||
{
|
||||
if (!String::valid(*iter))
|
||||
if (!StringType::valid(*iter))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -143,10 +163,10 @@ inline bool Foam::string::valid(const std::string& str)
|
||||
}
|
||||
|
||||
|
||||
template<class String>
|
||||
template<class StringType>
|
||||
inline bool Foam::string::stripInvalid(std::string& str)
|
||||
{
|
||||
if (!valid<String>(str))
|
||||
if (!string::valid<StringType>(str))
|
||||
{
|
||||
size_type nChar = 0;
|
||||
iterator outIter = str.begin();
|
||||
@ -155,7 +175,7 @@ inline bool Foam::string::stripInvalid(std::string& str)
|
||||
{
|
||||
const char c = *iter;
|
||||
|
||||
if (String::valid(c))
|
||||
if (StringType::valid(c))
|
||||
{
|
||||
*outIter = c;
|
||||
++outIter;
|
||||
@ -172,17 +192,17 @@ inline bool Foam::string::stripInvalid(std::string& str)
|
||||
}
|
||||
|
||||
|
||||
template<class String>
|
||||
inline String Foam::string::validate(const std::string& str)
|
||||
template<class StringType>
|
||||
inline StringType Foam::string::validate(const std::string& str)
|
||||
{
|
||||
String out;
|
||||
StringType out;
|
||||
out.resize(str.size());
|
||||
|
||||
size_type len = 0;
|
||||
for (auto iter = str.cbegin(); iter != str.cend(); ++iter)
|
||||
{
|
||||
const char c = *iter;
|
||||
if (String::valid(c))
|
||||
if (StringType::valid(c))
|
||||
{
|
||||
out[len] = c;
|
||||
++len;
|
||||
|
||||
Reference in New Issue
Block a user