ENH: minor adjustments to token methods for more granularity
This commit is contained in:
parent
bb86eecdc4
commit
8ad448b803
@ -87,7 +87,7 @@ public:
|
||||
|
||||
// Pointer types
|
||||
WORD, //!< A Foam::word
|
||||
STRING, //!< A string
|
||||
STRING, //!< A string (usually double-quoted)
|
||||
DIRECTIVE, //!< A dictionary \c \#directive (word variant)
|
||||
VARIABLE, //!< A dictionary \c \$variable (string variant)
|
||||
VERBATIM, //!< Verbatim string content
|
||||
@ -456,6 +456,9 @@ public:
|
||||
//- Token is LABEL
|
||||
inline bool isLabel() const noexcept;
|
||||
|
||||
//- True if token is LABEL and equal to parameter
|
||||
inline bool isLabel(const label val) const noexcept;
|
||||
|
||||
//- Token is FLOAT
|
||||
inline bool isFloat() const noexcept;
|
||||
|
||||
@ -477,7 +480,10 @@ public:
|
||||
//- Token is DIRECTIVE (word variant)
|
||||
inline bool isDirective() const noexcept;
|
||||
|
||||
//- Token is STRING, VARIABLE or VERBATIM string
|
||||
//- Token is (quoted) STRING (string variant)
|
||||
inline bool isQuotedString() const noexcept;
|
||||
|
||||
//- Token is STRING, VARIABLE or VERBATIM (string variant)
|
||||
inline bool isString() const noexcept;
|
||||
|
||||
//- Token is VARIABLE (string variant)
|
||||
|
@ -496,6 +496,16 @@ inline bool Foam::token::isLabel() const noexcept
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::token::isLabel(const label val) const noexcept
|
||||
{
|
||||
return
|
||||
(
|
||||
type_ == tokenType::LABEL
|
||||
&& data_.labelVal == val
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::label Foam::token::labelToken() const
|
||||
{
|
||||
if (type_ == tokenType::LABEL)
|
||||
@ -630,6 +640,12 @@ inline const Foam::word& Foam::token::wordToken() const
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::token::isQuotedString() const noexcept
|
||||
{
|
||||
return (type_ == tokenType::STRING);
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::token::isString() const noexcept
|
||||
{
|
||||
return
|
||||
@ -921,11 +937,7 @@ inline bool Foam::token::operator==(const std::string& s) const
|
||||
|
||||
inline bool Foam::token::operator==(const label val) const noexcept
|
||||
{
|
||||
return
|
||||
(
|
||||
type_ == tokenType::LABEL
|
||||
&& data_.labelVal == val
|
||||
);
|
||||
return isLabel(val);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user