mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: ensure self-assignment and self-swapping are a no-op for string types
- simplifies their use when reordering lists etc. (word, fileName, keyType, wordRe) - "unfriend" IO operators for string types. They require no internal access - add compile/uncompile methods to keyType for symmetry with wordRe - when outputting keyType/wordRe, be more explicit about them using writeQuoted()
This commit is contained in:
committed by
Andrew Heather
parent
df35627e69
commit
60c314150c
@ -84,7 +84,7 @@ public:
|
|||||||
// - range: '[', ']' \n
|
// - range: '[', ']' \n
|
||||||
//
|
//
|
||||||
// \note The presence of '{', '}' regex bounds is not considered
|
// \note The presence of '{', '}' regex bounds is not considered
|
||||||
inline static bool meta(const char c);
|
inline static bool meta(char c);
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|||||||
@ -28,7 +28,7 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline bool Foam::regExp::meta(const char c)
|
inline bool Foam::regExp::meta(char c)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
(
|
(
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -35,9 +35,10 @@ License
|
|||||||
|
|
||||||
void Foam::Ostream::decrIndent()
|
void Foam::Ostream::decrIndent()
|
||||||
{
|
{
|
||||||
if (indentLevel_ == 0)
|
if (!indentLevel_)
|
||||||
{
|
{
|
||||||
cerr<< "Ostream::decrIndent() : attempt to decrement 0 indent level"
|
std::cerr
|
||||||
|
<< "Ostream::decrIndent() : attempt to decrement 0 indent level"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -56,17 +57,17 @@ Foam::Ostream& Foam::Ostream::write(const keyType& kw)
|
|||||||
Foam::Ostream& Foam::Ostream::writeKeyword(const keyType& kw)
|
Foam::Ostream& Foam::Ostream::writeKeyword(const keyType& kw)
|
||||||
{
|
{
|
||||||
indent();
|
indent();
|
||||||
write(kw);
|
writeQuoted(kw, kw.isPattern());
|
||||||
|
|
||||||
label nSpaces = entryIndentation_ - label(kw.size());
|
label nSpaces = entryIndentation_ - label(kw.size());
|
||||||
|
|
||||||
// pattern is surrounded by quotes
|
// Account for quotes surrounding pattern
|
||||||
if (kw.isPattern())
|
if (kw.isPattern())
|
||||||
{
|
{
|
||||||
nSpaces -= 2;
|
nSpaces -= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// could also increment by indentSize_ ...
|
// Could also increment by indentSize_ ...
|
||||||
if (nSpaces < 1)
|
if (nSpaces < 1)
|
||||||
{
|
{
|
||||||
nSpaces = 1;
|
nSpaces = 1;
|
||||||
@ -81,9 +82,9 @@ Foam::Ostream& Foam::Ostream::writeKeyword(const keyType& kw)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::Ostream::beginBlock(const keyType& keyword)
|
Foam::Ostream& Foam::Ostream::beginBlock(const keyType& kw)
|
||||||
{
|
{
|
||||||
indent(); write(keyword); write('\n');
|
indent(); writeQuoted(kw, kw.isPattern()); write('\n');
|
||||||
beginBlock();
|
beginBlock();
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
|
|||||||
@ -185,7 +185,7 @@ public:
|
|||||||
|
|
||||||
//- Write begin block group with the given name
|
//- Write begin block group with the given name
|
||||||
// Increments indentation, adds newline.
|
// Increments indentation, adds newline.
|
||||||
virtual Ostream& beginBlock(const keyType& keyword);
|
virtual Ostream& beginBlock(const keyType& kw);
|
||||||
|
|
||||||
//- Write begin block group without a name
|
//- Write begin block group without a name
|
||||||
// Increments indentation, adds newline.
|
// Increments indentation, adds newline.
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -55,15 +55,6 @@ SourceFiles
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declaration of classes
|
|
||||||
class Ostream;
|
|
||||||
|
|
||||||
// Forward declaration of friend functions and operators
|
|
||||||
class SHA1;
|
|
||||||
class SHA1Digest;
|
|
||||||
Ostream& operator<<(Ostream&, const SHA1&);
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class SHA1 Declaration
|
Class SHA1 Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -91,6 +82,7 @@ class SHA1
|
|||||||
//- The input processing buffer
|
//- The input processing buffer
|
||||||
uint32_t buffer_[32];
|
uint32_t buffer_[32];
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Process data block-wise, LEN must be a multiple of 64!
|
//- Process data block-wise, LEN must be a multiple of 64!
|
||||||
@ -172,16 +164,15 @@ public:
|
|||||||
//- Convert to a SHA1Digest,
|
//- Convert to a SHA1Digest,
|
||||||
// calculate current %digest from appended data
|
// calculate current %digest from appended data
|
||||||
inline operator SHA1Digest() const;
|
inline operator SHA1Digest() const;
|
||||||
|
|
||||||
|
|
||||||
// Friend Operators
|
|
||||||
|
|
||||||
//- Output the %digest
|
|
||||||
inline friend Ostream& operator<<(Ostream&, const SHA1&);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// IOstream Operators
|
||||||
|
|
||||||
|
//- Output the %digest
|
||||||
|
inline Ostream& operator<<(Ostream& os, const SHA1& sha);
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|||||||
@ -136,7 +136,7 @@ inline Foam::SHA1::operator Foam::SHA1Digest() const
|
|||||||
|
|
||||||
inline Foam::Ostream& Foam::operator<<(Ostream& os, const SHA1& sha)
|
inline Foam::Ostream& Foam::operator<<(Ostream& os, const SHA1& sha)
|
||||||
{
|
{
|
||||||
return os << sha.digest();
|
return (os << sha.digest());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
@ -62,10 +62,6 @@ typedef List<word> wordList;
|
|||||||
class wordRe;
|
class wordRe;
|
||||||
class fileName;
|
class fileName;
|
||||||
|
|
||||||
Istream& operator>>(Istream&, fileName&);
|
|
||||||
Ostream& operator<<(Ostream&, const fileName&);
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class fileName Declaration
|
Class fileName Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -74,12 +70,6 @@ class fileName
|
|||||||
:
|
:
|
||||||
public string
|
public string
|
||||||
{
|
{
|
||||||
// Private Member Functions
|
|
||||||
|
|
||||||
//- Strip invalid characters
|
|
||||||
inline void stripInvalid();
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//- Enumerations to handle directory entry types.
|
//- Enumerations to handle directory entry types.
|
||||||
@ -94,7 +84,10 @@ public:
|
|||||||
|
|
||||||
// Static data members
|
// Static data members
|
||||||
|
|
||||||
|
//- The typeName
|
||||||
static const char* const typeName;
|
static const char* const typeName;
|
||||||
|
|
||||||
|
//- Debugging
|
||||||
static int debug;
|
static int debug;
|
||||||
|
|
||||||
//- An empty fileName
|
//- An empty fileName
|
||||||
@ -161,6 +154,8 @@ public:
|
|||||||
//- that ignores duplicate or trailing slashes.
|
//- that ignores duplicate or trailing slashes.
|
||||||
static bool equals(const std::string& s1, const std::string& s2);
|
static bool equals(const std::string& s1, const std::string& s2);
|
||||||
|
|
||||||
|
//- Strip invalid characters
|
||||||
|
inline void stripInvalid();
|
||||||
|
|
||||||
//- Cleanup filename
|
//- Cleanup filename
|
||||||
//
|
//
|
||||||
@ -353,15 +348,17 @@ public:
|
|||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
// Member operators
|
// Member Operators
|
||||||
|
|
||||||
// Assignment
|
// Assignment
|
||||||
|
|
||||||
//- Copy assignment, no character validation required
|
//- Copy assignment, no character validation required
|
||||||
fileName& operator=(const fileName&) = default;
|
// Self-assignment is a no-op.
|
||||||
|
inline fileName& operator=(const fileName& str);
|
||||||
|
|
||||||
//- Move assignment, no character validation required
|
//- Move assignment, no character validation required
|
||||||
fileName& operator=(fileName&&) = default;
|
// Self-assignment is a no-op.
|
||||||
|
inline fileName& operator=(fileName&& str);
|
||||||
|
|
||||||
//- Copy assignment, no character validation required
|
//- Copy assignment, no character validation required
|
||||||
inline fileName& operator=(const word& str);
|
inline fileName& operator=(const word& str);
|
||||||
@ -390,15 +387,18 @@ public:
|
|||||||
//- Append a path element with '/' separator.
|
//- Append a path element with '/' separator.
|
||||||
// No '/' separator is added if this or the argument are empty.
|
// No '/' separator is added if this or the argument are empty.
|
||||||
fileName& operator/=(const string& other);
|
fileName& operator/=(const string& other);
|
||||||
|
|
||||||
|
|
||||||
// IOstream operators
|
|
||||||
|
|
||||||
friend Istream& operator>>(Istream& is, fileName& fn);
|
|
||||||
friend Ostream& operator<<(Ostream& os, const fileName& fn);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// IOstream Operators
|
||||||
|
|
||||||
|
//- Read operator
|
||||||
|
Istream& operator>>(Istream& is, fileName& val);
|
||||||
|
|
||||||
|
//- Write operator
|
||||||
|
Ostream& operator<<(Ostream& os, const fileName& val);
|
||||||
|
|
||||||
|
|
||||||
// Global Operators
|
// Global Operators
|
||||||
|
|
||||||
//- Assemble words and fileNames as pathnames by adding a '/' separator.
|
//- Assemble words and fileNames as pathnames by adding a '/' separator.
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011 OpenFOAM Foundation
|
| Copyright (C) 2011 OpenFOAM Foundation
|
||||||
@ -25,32 +25,7 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include <iostream> // for std::cerr
|
#include <iostream> // For std::cerr
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
|
||||||
|
|
||||||
inline void Foam::fileName::stripInvalid()
|
|
||||||
{
|
|
||||||
// Skip stripping unless debug is active (to avoid costly operations)
|
|
||||||
if (debug && string::stripInvalid<fileName>(*this))
|
|
||||||
{
|
|
||||||
std::cerr
|
|
||||||
<< "fileName::stripInvalid() called for invalid fileName "
|
|
||||||
<< this->c_str() << std::endl;
|
|
||||||
|
|
||||||
if (debug > 1)
|
|
||||||
{
|
|
||||||
std::cerr
|
|
||||||
<< " For debug level (= " << debug
|
|
||||||
<< ") > 1 this is considered fatal" << std::endl;
|
|
||||||
std::abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
removeRepeated('/');
|
|
||||||
removeTrailing('/');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -134,6 +109,29 @@ inline bool Foam::fileName::valid(char c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void Foam::fileName::stripInvalid()
|
||||||
|
{
|
||||||
|
// Only strip when debug is active (potentially costly operation)
|
||||||
|
if (debug && string::stripInvalid<fileName>(*this))
|
||||||
|
{
|
||||||
|
std::cerr
|
||||||
|
<< "fileName::stripInvalid() called for invalid fileName "
|
||||||
|
<< this->c_str() << std::endl;
|
||||||
|
|
||||||
|
if (debug > 1)
|
||||||
|
{
|
||||||
|
std::cerr
|
||||||
|
<< " For debug level (= " << debug
|
||||||
|
<< ") > 1 this is considered fatal" << std::endl;
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
removeRepeated('/');
|
||||||
|
removeTrailing('/');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::fileName::isAbsolute(const std::string& str)
|
inline bool Foam::fileName::isAbsolute(const std::string& str)
|
||||||
{
|
{
|
||||||
return !str.empty() && str[0] == '/';
|
return !str.empty() && str[0] == '/';
|
||||||
@ -258,6 +256,28 @@ inline Foam::fileName& Foam::fileName::ext(const word& ending)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
inline Foam::fileName& Foam::fileName::operator=(const fileName& str)
|
||||||
|
{
|
||||||
|
// Self-assignment is a no-op
|
||||||
|
if (this != &str)
|
||||||
|
{
|
||||||
|
assign(str);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::fileName& Foam::fileName::operator=(fileName&& str)
|
||||||
|
{
|
||||||
|
// Self-assignment is a no-op
|
||||||
|
if (this != &str)
|
||||||
|
{
|
||||||
|
assign(std::move(str));
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::fileName& Foam::fileName::operator=(const word& str)
|
inline Foam::fileName& Foam::fileName::operator=(const word& str)
|
||||||
{
|
{
|
||||||
assign(str);
|
assign(str);
|
||||||
|
|||||||
@ -72,9 +72,9 @@ Foam::Istream& Foam::operator>>(Istream& is, fileName& val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::operator<<(Ostream& os, const fileName& fn)
|
Foam::Ostream& Foam::operator<<(Ostream& os, const fileName& val)
|
||||||
{
|
{
|
||||||
os.write(fn);
|
os.write(val);
|
||||||
os.check(FUNCTION_NAME);
|
os.check(FUNCTION_NAME);
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2015 OpenFOAM Foundation
|
| Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
@ -76,12 +76,13 @@ Foam::Istream& Foam::operator>>(Istream& is, keyType& val)
|
|||||||
if (t.isWord())
|
if (t.isWord())
|
||||||
{
|
{
|
||||||
val = t.wordToken();
|
val = t.wordToken();
|
||||||
|
val.uncompile(); // Non-regex
|
||||||
}
|
}
|
||||||
else if (t.isString())
|
else if (t.isString())
|
||||||
{
|
{
|
||||||
// Assign from string, treat as regular expression
|
// Assign from string, treat as regular expression
|
||||||
val = t.stringToken();
|
val = t.stringToken();
|
||||||
val.isPattern_ = true;
|
val.compile(); // As regex
|
||||||
|
|
||||||
// Flag empty strings as an error
|
// Flag empty strings as an error
|
||||||
if (val.empty())
|
if (val.empty())
|
||||||
@ -108,9 +109,9 @@ Foam::Istream& Foam::operator>>(Istream& is, keyType& val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::operator<<(Ostream& os, const keyType& kw)
|
Foam::Ostream& Foam::operator<<(Ostream& os, const keyType& val)
|
||||||
{
|
{
|
||||||
os.write(kw);
|
os.writeQuoted(val, val.isPattern());
|
||||||
os.check(FUNCTION_NAME);
|
os.check(FUNCTION_NAME);
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -48,13 +48,9 @@ SourceFiles
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declarations
|
// Forward Declarations
|
||||||
class keyType;
|
|
||||||
class Istream;
|
class Istream;
|
||||||
class Ostream;
|
class Ostream;
|
||||||
Istream& operator>>(Istream& is, keyType& kw);
|
|
||||||
Ostream& operator<<(Ostream& os, const keyType& kw);
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class keyType Declaration
|
Class keyType Declaration
|
||||||
@ -64,9 +60,9 @@ class keyType
|
|||||||
:
|
:
|
||||||
public word
|
public word
|
||||||
{
|
{
|
||||||
// Private data
|
// Private Data
|
||||||
|
|
||||||
//- Is the keyType a pattern (regular expression)
|
//- Treat keyType as a pattern (regular expression)
|
||||||
bool isPattern_;
|
bool isPattern_;
|
||||||
|
|
||||||
|
|
||||||
@ -78,13 +74,13 @@ class keyType
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Static data members
|
// Static Data Members
|
||||||
|
|
||||||
//- An empty keyType
|
//- An empty keyType
|
||||||
static const keyType null;
|
static const keyType null;
|
||||||
|
|
||||||
|
|
||||||
// Public data types
|
// Public Data Types
|
||||||
|
|
||||||
//- Enumeration for search/match modes as bitmask
|
//- Enumeration for search/match modes as bitmask
|
||||||
// eg, (keyType::REGEX | keyType::RECURSIVE)
|
// eg, (keyType::REGEX | keyType::RECURSIVE)
|
||||||
@ -142,18 +138,40 @@ public:
|
|||||||
// permit brace-brackets, which are valid for some regexs.
|
// permit brace-brackets, which are valid for some regexs.
|
||||||
inline static bool valid(char c);
|
inline static bool valid(char c);
|
||||||
|
|
||||||
|
|
||||||
|
// Access
|
||||||
|
|
||||||
//- The keyType is treated as literal, not as pattern.
|
//- The keyType is treated as literal, not as pattern.
|
||||||
inline bool isLiteral() const;
|
inline bool isLiteral() const;
|
||||||
|
|
||||||
//- The keyType is treated as a pattern, not as literal string.
|
//- The keyType is treated as a pattern, not as literal string.
|
||||||
inline bool isPattern() const;
|
inline bool isPattern() const;
|
||||||
|
|
||||||
//- Swap contents
|
|
||||||
|
// Infrastructure
|
||||||
|
|
||||||
|
//- Mark as regular expression
|
||||||
|
inline bool compile();
|
||||||
|
|
||||||
|
//- Mark as literal, instead of a regular expression.
|
||||||
|
// Optionally strip invalid word characters.
|
||||||
|
inline void uncompile(bool doStrip = false);
|
||||||
|
|
||||||
|
|
||||||
|
// Editing
|
||||||
|
|
||||||
|
//- Clear string and set as literal
|
||||||
|
inline void clear();
|
||||||
|
|
||||||
|
//- Swap contents. Self-swapping is a no-op.
|
||||||
inline void swap(keyType& s);
|
inline void swap(keyType& s);
|
||||||
|
|
||||||
|
|
||||||
|
// Matching/Searching
|
||||||
|
|
||||||
//- Smart match as regular expression or as a string.
|
//- Smart match as regular expression or as a string.
|
||||||
// Optionally force a literal match only
|
// Optionally force a literal match only
|
||||||
bool match(const std::string& text, bool literal = false) const;
|
bool match(const std::string& text, bool literal=false) const;
|
||||||
|
|
||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
@ -164,9 +182,11 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
//- Copy assignment, retaining type (literal or regex)
|
//- Copy assignment, retaining type (literal or regex)
|
||||||
|
// Self-assignment is a no-op.
|
||||||
inline void operator=(const keyType& s);
|
inline void operator=(const keyType& s);
|
||||||
|
|
||||||
//- Move assignment, retaining type (literal or regex)
|
//- Move assignment, retaining type (literal or regex)
|
||||||
|
// Self-assignment is a no-op.
|
||||||
inline void operator=(keyType&& s);
|
inline void operator=(keyType&& s);
|
||||||
|
|
||||||
//- Assign as word, treat as literal
|
//- Assign as word, treat as literal
|
||||||
@ -177,15 +197,18 @@ public:
|
|||||||
|
|
||||||
//- Assign as word, treat as literal
|
//- Assign as word, treat as literal
|
||||||
inline void operator=(const char* s);
|
inline void operator=(const char* s);
|
||||||
|
|
||||||
|
|
||||||
// IOstream Operators
|
|
||||||
|
|
||||||
friend Istream& operator>>(Istream& is, keyType& kw);
|
|
||||||
friend Ostream& operator<<(Ostream& os, const keyType& kw);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// IOstream Operators
|
||||||
|
|
||||||
|
//- Read operator
|
||||||
|
Istream& operator>>(Istream& is, keyType& val);
|
||||||
|
|
||||||
|
//- Write operator
|
||||||
|
Ostream& operator<<(Ostream& os, const keyType& val);
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -130,8 +130,40 @@ inline bool Foam::keyType::isPattern() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool Foam::keyType::compile()
|
||||||
|
{
|
||||||
|
isPattern_ = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void Foam::keyType::uncompile(bool doStrip)
|
||||||
|
{
|
||||||
|
// Only strip when debug is active (potentially costly operation)
|
||||||
|
if (isPattern_ && doStrip && word::debug)
|
||||||
|
{
|
||||||
|
string::stripInvalid<word>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
isPattern_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void Foam::keyType::clear()
|
||||||
|
{
|
||||||
|
word::clear();
|
||||||
|
isPattern_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void Foam::keyType::swap(keyType& s)
|
inline void Foam::keyType::swap(keyType& s)
|
||||||
{
|
{
|
||||||
|
// Self-swapping is a no-op
|
||||||
|
if (this == &s)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
word::swap(static_cast<word&>(s));
|
word::swap(static_cast<word&>(s));
|
||||||
std::swap(isPattern_, s.isPattern_);
|
std::swap(isPattern_, s.isPattern_);
|
||||||
}
|
}
|
||||||
@ -147,6 +179,12 @@ inline bool Foam::keyType::operator()(const std::string& text) const
|
|||||||
|
|
||||||
inline void Foam::keyType::operator=(const keyType& s)
|
inline void Foam::keyType::operator=(const keyType& s)
|
||||||
{
|
{
|
||||||
|
// Self-assignment is a no-op
|
||||||
|
if (this == &s)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
assign(s); // Bypasses char checking
|
assign(s); // Bypasses char checking
|
||||||
isPattern_ = s.isPattern_;
|
isPattern_ = s.isPattern_;
|
||||||
}
|
}
|
||||||
@ -154,6 +192,12 @@ inline void Foam::keyType::operator=(const keyType& s)
|
|||||||
|
|
||||||
inline void Foam::keyType::operator=(keyType&& s)
|
inline void Foam::keyType::operator=(keyType&& s)
|
||||||
{
|
{
|
||||||
|
// Self-assignment is a no-op
|
||||||
|
if (this == &s)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
swap(s);
|
swap(s);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,20 +58,16 @@ Description
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declarations
|
// Forward Declarations
|
||||||
class Ostream;
|
|
||||||
class CStringList;
|
|
||||||
template<class String> class SubStrings;
|
template<class String> class SubStrings;
|
||||||
|
|
||||||
Ostream& operator<<(Ostream& os, const CStringList& list);
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class CStringList Declaration
|
Class CStringList Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class CStringList
|
class CStringList
|
||||||
{
|
{
|
||||||
// Private data
|
// Private Data
|
||||||
|
|
||||||
//- Number of strings
|
//- Number of strings
|
||||||
int argc_;
|
int argc_;
|
||||||
@ -127,7 +123,7 @@ public:
|
|||||||
inline explicit CStringList(const SubStrings<StringType>& input);
|
inline explicit CStringList(const SubStrings<StringType>& input);
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor. Invokes clear() to free memory.
|
||||||
inline ~CStringList();
|
inline ~CStringList();
|
||||||
|
|
||||||
|
|
||||||
@ -196,15 +192,15 @@ public:
|
|||||||
|
|
||||||
//- Return element at the given index. No bounds checking.
|
//- Return element at the given index. No bounds checking.
|
||||||
inline const char* operator[](int i) const;
|
inline const char* operator[](int i) const;
|
||||||
|
|
||||||
|
|
||||||
// IOstream Operators
|
|
||||||
|
|
||||||
friend Ostream& operator<<(Ostream& os, const CStringList& list);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// IOstream Operators
|
||||||
|
|
||||||
|
//- Output space-separated list
|
||||||
|
Ostream& operator<<(Ostream& os, const CStringList& list);
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|||||||
@ -47,11 +47,6 @@ SourceFiles
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declarations
|
|
||||||
class hashedWordList;
|
|
||||||
inline Istream& operator>>(Istream& is, hashedWordList& list);
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class hashedWordList Declaration
|
Class hashedWordList Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -182,9 +177,6 @@ public:
|
|||||||
//- Move assignment from list of words. Rehashes the indices.
|
//- Move assignment from list of words. Rehashes the indices.
|
||||||
inline void operator=(wordList&& list);
|
inline void operator=(wordList&& list);
|
||||||
|
|
||||||
//- Read from an input stream. Rehashes the indices.
|
|
||||||
inline friend Istream& operator>>(Istream& is, hashedWordList& list);
|
|
||||||
|
|
||||||
|
|
||||||
// Housekeeping
|
// Housekeeping
|
||||||
|
|
||||||
@ -198,6 +190,10 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//- Read from an input stream. Rehashes the indices.
|
||||||
|
inline Istream& operator>>(Istream& is, hashedWordList& list);
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|||||||
@ -63,13 +63,8 @@ namespace Foam
|
|||||||
// Forward Declarations
|
// Forward Declarations
|
||||||
class word;
|
class word;
|
||||||
class wordRe;
|
class wordRe;
|
||||||
class string;
|
|
||||||
class Istream;
|
class Istream;
|
||||||
class Ostream;
|
class Ostream;
|
||||||
Istream& operator>>(Istream& is, string& s);
|
|
||||||
Ostream& operator<<(Ostream& os, const string& s);
|
|
||||||
Ostream& operator<<(Ostream& os, const std::string& s);
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class string Declaration
|
Class string Declaration
|
||||||
@ -294,20 +289,32 @@ public:
|
|||||||
bool endsWith(const std::string& text) const;
|
bool endsWith(const std::string& text) const;
|
||||||
|
|
||||||
|
|
||||||
|
// Editing
|
||||||
|
|
||||||
|
//- Swap contents. Self-swapping is a no-op.
|
||||||
|
inline void swap(std::string& str);
|
||||||
|
|
||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
|
|
||||||
//- Test for equality. Allows use as a predicate.
|
//- Test for equality. Allows use as a predicate.
|
||||||
// \return True when strings match literally.
|
// \return True when strings match literally.
|
||||||
inline bool operator()(const std::string& text) const;
|
inline bool operator()(const std::string& text) const;
|
||||||
|
|
||||||
|
|
||||||
// IOstream Operators
|
|
||||||
|
|
||||||
friend Istream& operator>>(Istream& is, string& s);
|
|
||||||
friend Ostream& operator<<(Ostream& os, const string& s);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// IOstream Operators
|
||||||
|
|
||||||
|
//- Read operator
|
||||||
|
Istream& operator>>(Istream& is, string& val);
|
||||||
|
|
||||||
|
//- Write operator
|
||||||
|
Ostream& operator<<(Ostream& os, const string& val);
|
||||||
|
|
||||||
|
//- Write operator
|
||||||
|
Ostream& operator<<(Ostream& os, const std::string& val);
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2015 OpenFOAM Foundation
|
| Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
@ -262,6 +262,16 @@ inline bool Foam::string::match(const std::string& text) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void Foam::string::swap(std::string& str)
|
||||||
|
{
|
||||||
|
// Self-swapping is a no-op
|
||||||
|
if (this != &str)
|
||||||
|
{
|
||||||
|
std::string::swap(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline bool Foam::string::operator()(const std::string& text) const
|
inline bool Foam::string::operator()(const std::string& text) const
|
||||||
|
|||||||
@ -70,17 +70,17 @@ Foam::Istream& Foam::operator>>(Istream& is, string& val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::operator<<(Ostream& os, const string& s)
|
Foam::Ostream& Foam::operator<<(Ostream& os, const string& val)
|
||||||
{
|
{
|
||||||
os.write(s);
|
os.write(val);
|
||||||
os.check(FUNCTION_NAME);
|
os.check(FUNCTION_NAME);
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::operator<<(Ostream& os, const std::string& s)
|
Foam::Ostream& Foam::operator<<(Ostream& os, const std::string& val)
|
||||||
{
|
{
|
||||||
os.write(string(s));
|
os.write(string(val));
|
||||||
os.check(FUNCTION_NAME);
|
os.check(FUNCTION_NAME);
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -63,18 +63,14 @@ class word
|
|||||||
:
|
:
|
||||||
public string
|
public string
|
||||||
{
|
{
|
||||||
// Private Member Functions
|
|
||||||
|
|
||||||
//- Strip invalid characters from this word
|
|
||||||
// Trips an abort on invalid characters for debug 2 or greater
|
|
||||||
inline void stripInvalid();
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Static data members
|
// Static Data Members
|
||||||
|
|
||||||
|
//- The typeName
|
||||||
static const char* const typeName;
|
static const char* const typeName;
|
||||||
|
|
||||||
|
//- Debugging
|
||||||
static int debug;
|
static int debug;
|
||||||
|
|
||||||
//- An empty word
|
//- An empty word
|
||||||
@ -136,7 +132,6 @@ public:
|
|||||||
const PrimitiveType& val
|
const PrimitiveType& val
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
//- Is this character valid for a word?
|
//- Is this character valid for a word?
|
||||||
inline static bool valid(char c);
|
inline static bool valid(char c);
|
||||||
|
|
||||||
@ -155,6 +150,10 @@ public:
|
|||||||
const bool prefix=false
|
const bool prefix=false
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//- Strip invalid characters from this word
|
||||||
|
// Trips an abort on invalid characters for debug 2 or greater
|
||||||
|
inline void stripInvalid();
|
||||||
|
|
||||||
|
|
||||||
// File-like Functions
|
// File-like Functions
|
||||||
|
|
||||||
@ -182,15 +181,17 @@ public:
|
|||||||
inline bool removeExt();
|
inline bool removeExt();
|
||||||
|
|
||||||
|
|
||||||
// Member operators
|
// Member Operators
|
||||||
|
|
||||||
// Assignment
|
// Assignment
|
||||||
|
|
||||||
//- Copy assignment, no character validation required
|
//- Copy assignment, no character validation required.
|
||||||
word& operator=(const word&) = default;
|
// Self-assignment is a no-op
|
||||||
|
inline word& operator=(const word& s);
|
||||||
|
|
||||||
//- Move assignment, no character validation required
|
//- Move assignment, no character validation required
|
||||||
word& operator=(word&& w) = default;
|
// Self-assignment is a no-op
|
||||||
|
inline word& operator=(word&& s);
|
||||||
|
|
||||||
//- Copy assignment from Foam::string, stripping invalid characters
|
//- Copy assignment from Foam::string, stripping invalid characters
|
||||||
inline word& operator=(const string& s);
|
inline word& operator=(const string& s);
|
||||||
@ -206,15 +207,18 @@ public:
|
|||||||
|
|
||||||
//- Copy, stripping invalid characters
|
//- Copy, stripping invalid characters
|
||||||
inline word& operator=(const char* s);
|
inline word& operator=(const char* s);
|
||||||
|
|
||||||
|
|
||||||
// IOstream operators
|
|
||||||
|
|
||||||
friend Istream& operator>>(Istream& is, word& w);
|
|
||||||
friend Ostream& operator<<(Ostream& os, const word& w);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// IOstream Operators
|
||||||
|
|
||||||
|
//- Read operator
|
||||||
|
Istream& operator>>(Istream& is, word& val);
|
||||||
|
|
||||||
|
//- Write operator
|
||||||
|
Ostream& operator<<(Ostream& os, const word& val);
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
//- Join words as camelCase, capitalizing the first letter of b.
|
//- Join words as camelCase, capitalizing the first letter of b.
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
@ -56,28 +56,6 @@ inline Foam::word Foam::word::printf
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
|
||||||
|
|
||||||
inline void Foam::word::stripInvalid()
|
|
||||||
{
|
|
||||||
// Skip stripping unless debug is active (to avoid costly operations)
|
|
||||||
if (debug && string::stripInvalid<word>(*this))
|
|
||||||
{
|
|
||||||
std::cerr
|
|
||||||
<< "word::stripInvalid() called for word "
|
|
||||||
<< this->c_str() << std::endl;
|
|
||||||
|
|
||||||
if (debug > 1)
|
|
||||||
{
|
|
||||||
std::cerr
|
|
||||||
<< " For debug level (= " << debug
|
|
||||||
<< ") > 1 this is considered fatal" << std::endl;
|
|
||||||
std::abort();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline Foam::word::word(const string& s, bool doStrip)
|
inline Foam::word::word(const string& s, bool doStrip)
|
||||||
@ -163,6 +141,26 @@ inline bool Foam::word::valid(char c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void Foam::word::stripInvalid()
|
||||||
|
{
|
||||||
|
// Only strip when debug is active (potentially costly operation)
|
||||||
|
if (debug && string::stripInvalid<word>(*this))
|
||||||
|
{
|
||||||
|
std::cerr
|
||||||
|
<< "word::stripInvalid() called for word "
|
||||||
|
<< this->c_str() << std::endl;
|
||||||
|
|
||||||
|
if (debug > 1)
|
||||||
|
{
|
||||||
|
std::cerr
|
||||||
|
<< " For debug level (= " << debug
|
||||||
|
<< ") > 1 this is considered fatal" << std::endl;
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::word::hasExt() const
|
inline bool Foam::word::hasExt() const
|
||||||
{
|
{
|
||||||
return string::hasExt();
|
return string::hasExt();
|
||||||
@ -177,6 +175,28 @@ inline bool Foam::word::removeExt()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
inline Foam::word& Foam::word::operator=(const word& s)
|
||||||
|
{
|
||||||
|
// Self-assignment is a no-op
|
||||||
|
if (this != &s)
|
||||||
|
{
|
||||||
|
assign(s);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::word& Foam::word::operator=(word&& s)
|
||||||
|
{
|
||||||
|
// Self-assignment is a no-op
|
||||||
|
if (this != &s)
|
||||||
|
{
|
||||||
|
assign(std::move(s));
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::word& Foam::word::operator=(const string& s)
|
inline Foam::word& Foam::word::operator=(const string& s)
|
||||||
{
|
{
|
||||||
assign(s);
|
assign(s);
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2015 OpenFOAM Foundation
|
| Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
@ -87,9 +87,9 @@ Foam::Istream& Foam::operator>>(Istream& is, word& val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::operator<<(Ostream& os, const word& w)
|
Foam::Ostream& Foam::operator<<(Ostream& os, const word& val)
|
||||||
{
|
{
|
||||||
os.write(w);
|
os.write(val);
|
||||||
os.check(FUNCTION_NAME);
|
os.check(FUNCTION_NAME);
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -47,6 +47,21 @@ Foam::wordRe::wordRe(Istream& is)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::Ostream& Foam::wordRe::info(Ostream& os) const
|
||||||
|
{
|
||||||
|
if (isPattern())
|
||||||
|
{
|
||||||
|
os << "wordRe(regex) " << *this;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
os << "wordRe(plain) \"" << *this << '"';
|
||||||
|
}
|
||||||
|
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Istream& Foam::operator>>(Istream& is, wordRe& val)
|
Foam::Istream& Foam::operator>>(Istream& is, wordRe& val)
|
||||||
{
|
{
|
||||||
token t(is);
|
token t(is);
|
||||||
@ -94,27 +109,12 @@ Foam::Istream& Foam::operator>>(Istream& is, wordRe& val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::operator<<(Ostream& os, const wordRe& w)
|
Foam::Ostream& Foam::operator<<(Ostream& os, const wordRe& val)
|
||||||
{
|
{
|
||||||
os.writeQuoted(w, w.isPattern());
|
os.writeQuoted(val, val.isPattern());
|
||||||
os.check(FUNCTION_NAME);
|
os.check(FUNCTION_NAME);
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::wordRe::info(Ostream& os) const
|
|
||||||
{
|
|
||||||
if (isPattern())
|
|
||||||
{
|
|
||||||
os << "wordRe(regex) " << *this;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
os << "wordRe(plain) \"" << *this << '"';
|
|
||||||
}
|
|
||||||
|
|
||||||
return os;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -61,15 +61,10 @@ SourceFiles
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declarations
|
// Forward Declarations
|
||||||
class wordRe;
|
|
||||||
class Istream;
|
class Istream;
|
||||||
class Ostream;
|
class Ostream;
|
||||||
|
|
||||||
Istream& operator>>(Istream& is, wordRe& w);
|
|
||||||
Ostream& operator<<(Ostream& os, const wordRe& w);
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class wordRe Declaration
|
Class wordRe Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -78,21 +73,21 @@ class wordRe
|
|||||||
:
|
:
|
||||||
public word
|
public word
|
||||||
{
|
{
|
||||||
// Private member data
|
// Private Member Data
|
||||||
|
|
||||||
//- The regular expression
|
//- The regular expression
|
||||||
mutable regExp re_;
|
regExp re_;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Static data members
|
// Static Data Members
|
||||||
|
|
||||||
//- An empty wordRe
|
//- An empty wordRe
|
||||||
static const wordRe null;
|
static const wordRe null;
|
||||||
|
|
||||||
|
|
||||||
// Public data types
|
// Public Data Types
|
||||||
|
|
||||||
//- Enumeration with compile options
|
//- Enumeration with compile options
|
||||||
// Note that 'REGEX' is implicit if 'ICASE' is specified alone.
|
// Note that 'REGEX' is implicit if 'ICASE' is specified alone.
|
||||||
@ -109,18 +104,6 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//- Is this a meta character?
|
|
||||||
inline static bool meta(const char c);
|
|
||||||
|
|
||||||
//- Is this character valid for a wordRe?
|
|
||||||
// This is largely identical with what word accepts, but also
|
|
||||||
// permit brace-brackets, which are valid for some regexs.
|
|
||||||
inline static bool valid(char c);
|
|
||||||
|
|
||||||
//- Test string for regular expression meta characters
|
|
||||||
inline static bool isPattern(const std::string& str);
|
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null
|
//- Construct null
|
||||||
@ -169,9 +152,21 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- Is this a meta character?
|
||||||
|
inline static bool meta(char c);
|
||||||
|
|
||||||
|
//- Is this character valid for a wordRe?
|
||||||
|
// This is largely identical with what word accepts, but also
|
||||||
|
// permit brace-brackets, which are valid for some regexs.
|
||||||
|
inline static bool valid(char c);
|
||||||
|
|
||||||
|
//- Test string for regular expression meta characters
|
||||||
|
inline static bool isPattern(const std::string& str);
|
||||||
|
|
||||||
|
|
||||||
// Access
|
// Access
|
||||||
|
|
||||||
//- The wordRe is treated as literal, not as pattern.
|
//- The wordRe is treated as literal string, not as pattern.
|
||||||
inline bool isLiteral() const;
|
inline bool isLiteral() const;
|
||||||
|
|
||||||
//- The wordRe is treated as a pattern, not as literal string.
|
//- The wordRe is treated as a pattern, not as literal string.
|
||||||
@ -181,14 +176,14 @@ public:
|
|||||||
// Infrastructure
|
// Infrastructure
|
||||||
|
|
||||||
//- Compile the regular expression
|
//- Compile the regular expression
|
||||||
inline bool compile() const;
|
inline bool compile();
|
||||||
|
|
||||||
//- Possibly compile the regular expression, with greater control
|
//- Possibly compile the regular expression, with greater control
|
||||||
inline bool compile(const compOption opt) const;
|
inline bool compile(const compOption opt);
|
||||||
|
|
||||||
//- Make wordRe a literal again, instead of a regular expression.
|
//- Make wordRe a literal again, instead of a regular expression.
|
||||||
// Optionally strip invalid word characters.
|
// Optionally strip invalid word characters.
|
||||||
inline void uncompile(bool doStrip = false) const;
|
inline void uncompile(bool doStrip = false);
|
||||||
|
|
||||||
|
|
||||||
// Editing
|
// Editing
|
||||||
@ -202,7 +197,7 @@ public:
|
|||||||
//- Clear string and regular expression
|
//- Clear string and regular expression
|
||||||
inline void clear();
|
inline void clear();
|
||||||
|
|
||||||
//- Swap contents
|
//- Swap contents. Self-swapping is a no-op
|
||||||
inline void swap(wordRe& str);
|
inline void swap(wordRe& str);
|
||||||
|
|
||||||
|
|
||||||
@ -230,6 +225,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
//- Copy assignment, retaining type (literal or regex)
|
//- Copy assignment, retaining type (literal or regex)
|
||||||
|
// Self-assignment is a no-op.
|
||||||
inline void operator=(const wordRe& str);
|
inline void operator=(const wordRe& str);
|
||||||
|
|
||||||
//- Copy word, never a regular expression
|
//- Copy word, never a regular expression
|
||||||
@ -252,16 +248,20 @@ public:
|
|||||||
inline void operator=(const char* str);
|
inline void operator=(const char* str);
|
||||||
|
|
||||||
//- Move assignment.
|
//- Move assignment.
|
||||||
|
// Self-assignment is a no-op.
|
||||||
inline void operator=(wordRe&& str);
|
inline void operator=(wordRe&& str);
|
||||||
|
|
||||||
|
|
||||||
// IOstream Operators
|
|
||||||
|
|
||||||
friend Istream& operator>>(Istream& is, wordRe& w);
|
|
||||||
friend Ostream& operator<<(Ostream& os, const wordRe& w);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// IOstream Operators
|
||||||
|
|
||||||
|
//- Read operator
|
||||||
|
Istream& operator>>(Istream& is, wordRe& val);
|
||||||
|
|
||||||
|
//- Write operator
|
||||||
|
Ostream& operator<<(Ostream& os, const wordRe& val);
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -27,7 +27,7 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline bool Foam::wordRe::meta(const char c)
|
inline bool Foam::wordRe::meta(char c)
|
||||||
{
|
{
|
||||||
return regExp::meta(c);
|
return regExp::meta(c);
|
||||||
}
|
}
|
||||||
@ -171,7 +171,7 @@ inline bool Foam::wordRe::isPattern() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::wordRe::compile(const compOption opt) const
|
inline bool Foam::wordRe::compile(const compOption opt)
|
||||||
{
|
{
|
||||||
if (opt)
|
if (opt)
|
||||||
{
|
{
|
||||||
@ -202,24 +202,18 @@ inline bool Foam::wordRe::compile(const compOption opt) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::wordRe::compile() const
|
inline bool Foam::wordRe::compile()
|
||||||
{
|
{
|
||||||
return re_.set(*this);
|
return re_.set(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void Foam::wordRe::uncompile(bool doStrip) const
|
inline void Foam::wordRe::uncompile(bool doStrip)
|
||||||
{
|
{
|
||||||
if (re_.clear() && doStrip)
|
// Only strip when debug is active (potentially costly operation)
|
||||||
|
if (re_.clear() && doStrip && word::debug)
|
||||||
{
|
{
|
||||||
// Skip stripping unless debug is active to avoid costly operations
|
string::stripInvalid<word>(*this);
|
||||||
if (word::debug)
|
|
||||||
{
|
|
||||||
string::stripInvalid<word>
|
|
||||||
(
|
|
||||||
const_cast<word&>(static_cast<const word&>(*this))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,6 +258,12 @@ inline void Foam::wordRe::set(const char* str, const compOption opt)
|
|||||||
|
|
||||||
inline void Foam::wordRe::swap(wordRe& str)
|
inline void Foam::wordRe::swap(wordRe& str)
|
||||||
{
|
{
|
||||||
|
// Self-swapping is a no-op
|
||||||
|
if (this == &str)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
word::swap(static_cast<word&>(str));
|
word::swap(static_cast<word&>(str));
|
||||||
re_.swap(str.re_);
|
re_.swap(str.re_);
|
||||||
}
|
}
|
||||||
@ -279,6 +279,12 @@ inline bool Foam::wordRe::operator()(const std::string& text) const
|
|||||||
|
|
||||||
inline void Foam::wordRe::operator=(const wordRe& str)
|
inline void Foam::wordRe::operator=(const wordRe& str)
|
||||||
{
|
{
|
||||||
|
// Self-assignment is a no-op
|
||||||
|
if (this == &str)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
assign(str);
|
assign(str);
|
||||||
if (str.isPattern())
|
if (str.isPattern())
|
||||||
{
|
{
|
||||||
@ -335,6 +341,12 @@ inline void Foam::wordRe::operator=(const char* str)
|
|||||||
|
|
||||||
inline void Foam::wordRe::operator=(wordRe&& str)
|
inline void Foam::wordRe::operator=(wordRe&& str)
|
||||||
{
|
{
|
||||||
|
// Self-assignment is a no-op
|
||||||
|
if (this == &str)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
swap(str);
|
swap(str);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -56,11 +56,6 @@ class FileName
|
|||||||
:
|
:
|
||||||
public fileName
|
public fileName
|
||||||
{
|
{
|
||||||
// Private Member Functions
|
|
||||||
|
|
||||||
//- Strip invalid characters
|
|
||||||
inline void stripInvalid();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
@ -80,6 +75,9 @@ public:
|
|||||||
//- Is this character valid for an ensight file-name
|
//- Is this character valid for an ensight file-name
|
||||||
inline static bool valid(char c);
|
inline static bool valid(char c);
|
||||||
|
|
||||||
|
//- Strip invalid characters
|
||||||
|
inline void stripInvalid();
|
||||||
|
|
||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -53,6 +53,17 @@ inline Foam::ensight::FileName::FileName(const std::string& s)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
inline bool Foam::ensight::FileName::valid(char c)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
(
|
||||||
|
fileName::valid(c) // includes space, quotes
|
||||||
|
&& c != '*' // wild-card
|
||||||
|
&& c != '%' // structured block continuation
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void Foam::ensight::FileName::stripInvalid()
|
inline void Foam::ensight::FileName::stripInvalid()
|
||||||
{
|
{
|
||||||
string::stripInvalid<FileName>(*this);
|
string::stripInvalid<FileName>(*this);
|
||||||
@ -69,15 +80,4 @@ inline void Foam::ensight::FileName::stripInvalid()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::ensight::FileName::valid(char c)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
(
|
|
||||||
fileName::valid(c) // includes space, quotes
|
|
||||||
&& c != '*' // wild-card
|
|
||||||
&& c != '%' // structured block continuation
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -58,11 +58,6 @@ class VarName
|
|||||||
:
|
:
|
||||||
public word
|
public word
|
||||||
{
|
{
|
||||||
// Private Member Functions
|
|
||||||
|
|
||||||
//- Strip invalid characters
|
|
||||||
inline void stripInvalid();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
@ -82,6 +77,9 @@ public:
|
|||||||
//- Is this character valid for an ensight var-name
|
//- Is this character valid for an ensight var-name
|
||||||
inline static bool valid(char c);
|
inline static bool valid(char c);
|
||||||
|
|
||||||
|
//- Strip invalid characters
|
||||||
|
inline void stripInvalid();
|
||||||
|
|
||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -51,29 +51,8 @@ inline Foam::ensight::VarName::VarName(const std::string& s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline void Foam::ensight::VarName::stripInvalid()
|
|
||||||
{
|
|
||||||
string::stripInvalid<VarName>(*this);
|
|
||||||
|
|
||||||
if (empty())
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "ensight::VarName empty after stripping" << nl
|
|
||||||
<< exit(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
// prefix with '_' to avoid starting with leading digits
|
|
||||||
std::string::iterator iter = begin();
|
|
||||||
if (isdigit(*iter))
|
|
||||||
{
|
|
||||||
insert(iter, '_');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::ensight::VarName::valid(char c)
|
inline bool Foam::ensight::VarName::valid(char c)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
@ -97,4 +76,24 @@ inline bool Foam::ensight::VarName::valid(char c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void Foam::ensight::VarName::stripInvalid()
|
||||||
|
{
|
||||||
|
string::stripInvalid<VarName>(*this);
|
||||||
|
|
||||||
|
if (empty())
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "ensight::VarName empty after stripping" << nl
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prefix with '_' to avoid starting with leading digits
|
||||||
|
std::string::iterator iter = begin();
|
||||||
|
if (isdigit(*iter))
|
||||||
|
{
|
||||||
|
insert(iter, '_');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
Reference in New Issue
Block a user