ENH: expose ITstream hasPutback to allow better handling

STYLE: relocate ITstream::parseStream from static to file-scope
This commit is contained in:
Mark Olesen
2021-11-16 09:51:40 +01:00
parent 4e59ad9d8d
commit 96735dce20
3 changed files with 19 additions and 19 deletions

View File

@ -77,7 +77,7 @@ protected:
// Protected Member Functions
//- True if putback token is in use
inline bool hasPutback() const noexcept
bool hasPutback() const noexcept
{
return putBackAvail_;
}

View File

@ -31,34 +31,31 @@ License
#include "StringStream.H"
#include "UIListStream.H"
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
namespace
namespace Foam
{
// Failsafe read-access.
// Return the token at location, or undefinedToken.
inline static const Foam::token& peekTokenAt
inline static const token& peekTokenAt
(
const Foam::UList<Foam::token>& list,
const Foam::label i
const UList<token>& list,
const label i
)
{
return
(
i >= 0 && i < list.size()
? list[i]
: Foam::token::undefinedToken
: token::undefinedToken
);
}
} // End anonymous namespace
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
Foam::label Foam::ITstream::parseStream(ISstream& is, tokenList& tokens)
// Convert input sequence into a list of tokens.
// Return the number of tokens in the resulting list.
static label parseStream(ISstream& is, tokenList& tokens)
{
label nTok = 0;
@ -76,6 +73,10 @@ Foam::label Foam::ITstream::parseStream(ISstream& is, tokenList& tokens)
return nTok;
}
} // End namespace Foam
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
Foam::tokenList Foam::ITstream::parse
(

View File

@ -46,9 +46,6 @@ SourceFiles
namespace Foam
{
// Forward Declarations
class ISstream;
/*---------------------------------------------------------------------------*\
Class ITstream Declaration
\*---------------------------------------------------------------------------*/
@ -69,10 +66,6 @@ class ITstream
// Private Member Functions
//- Convert input sequence into a list of tokens.
// \return the number of tokens in the resulting list.
static label parseStream(ISstream& input, tokenList& tokens);
//- An ad hoc combination of reserve and setCapacity somewhat
//- similar to DynamicList.
//
@ -187,6 +180,12 @@ public:
// Token Access
//- True if putback token is in use
bool hasPutback() const noexcept
{
return Istream::hasPutback();
}
//- Failsafe peek at the \b first token in the list.
// \return \c undefinedToken if the list is empty.
const token& peekFirst() const;