61 tokens[
count] = std::move(tok);
110 const std::string&
input,
138 void Foam::ITstream::reserveCapacity(
const label newCapacity)
144 if (len < newCapacity)
154 while (len < newCapacity);
165 Istream(static_cast<IOstreamOption>(is)),
179 name_(
std::move(is.name_)),
266 const std::string&
input,
300 os <<
"ITstream : " << name_.c_str() <<
", line ";
312 if (toks.front().lineNumber() < toks.back().lineNumber())
327 return std::string();
349 for (++iter; (iter != last); (void)++iter)
355 const auto view = buf.view();
357 return std::string(view.data(), view.size());
369 return peekNoFail(tokenIndex_);
378 <<
"Token index " << tokenIndex_ <<
" out of range [0," 391 const label nToks = toks.size();
400 lineNumber_ = toks.front().lineNumber();
406 else if (pos < 0 || pos >= nToks)
413 lineNumber_ = toks.back().lineNumber();
425 lineNumber_ = toks[tokenIndex_].lineNumber();
491 const label nToks = toks.size();
493 if (tokenIndex_ < nToks)
495 tok = toks[tokenIndex_++];
496 lineNumber_ = tok.lineNumber();
498 if (tokenIndex_ == nToks)
508 <<
"attempt to read beyond EOF" 521 tok.lineNumber(toks.back().lineNumber());
525 tok.lineNumber(this->lineNumber());
551 if (tok.isPunctuation())
553 if (tok.isPunctuation(delimOpen))
563 else if (tok.isPunctuation(delimClose))
576 slice.size() = (
pos - slice.start()) + 1;
591 static_cast<IOstreamOption>(*
this),
609 result.resize(label(last - first));
612 std::move(first, last, result.begin());
615 (void)
remove(slice);
640 if (slice.contains(tokenIndex_))
643 seek(slice.begin_value());
646 else if (tokenIndex_ >= slice.end_value())
744 reserveCapacity(tokenIndex_ + 1);
753 reserveCapacity(tokenIndex_ + 1);
762 const label len = toks.
size();
763 reserveCapacity(tokenIndex_ + len);
772 const label len = toks.
size();
773 reserveCapacity(tokenIndex_ + len);
788 Istream::operator=(is);
void add_tokens(const token &tok)
Copy append a token at the current tokenIndex, incrementing the index.
bool good() const noexcept
True if token is not UNDEFINED or ERROR.
const_iterator cend() const noexcept
Return const_iterator to end traversing the constant UList.
void size(const label n)
Older name for setAddressableSize.
const token & peekBack() const noexcept
Examine putback token without removing it.
bool getBack(token &tok)
Retrieve the put-back token if there is one.
Input/output streams with (internal or external) character storage.
void seek(label pos)
Move tokenIndex to the specified position.
bool bad() const noexcept
True if stream is corrupted.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void resize(const label len)
Adjust allocated size of list.
static std::unique_ptr< Foam::ITstream > emptyStreamPtr_
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
A range or interval of labels defined by a start and a size.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
bool empty() const noexcept
True if List is empty (ie, size() is zero)
A token holds an item read from Istream.
T & front()
Access first element of the list, position [0].
label remove(const labelRange &range)
Remove a (start,size) subset from the list and move remaining elements down.
A simple container for options an IOstream can normally have.
std::string toString() const
Concatenate tokens into a space-separated std::string. The resulting string may contain quote charact...
List< token > tokenList
List of token, used for dictionary primitive entry (for example)
const token & peek() const
Failsafe peek at what the next read would return, including handling of any putback.
static tokenList parse(const UList< char > &input, IOstreamOption streamOpt=IOstreamOption())
Create token list by parsing the input character sequence until no good tokens remain.
T & operator[](const label i)
Return element of UList.
dimensionedScalar pos(const dimensionedScalar &ds)
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
virtual Istream & read(token &tok) override
Return next token from stream.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
void operator=(const UList< T > &list)
Assignment to UList operator. Takes linear time.
void clear()
Clear the list, i.e. set size to zero.
virtual Istream & readRaw(char *data, std::streamsize count) override
Low-level raw binary read : triggers not implemented error.
A class for handling words, derived from Foam::string.
static Istream & input(Istream &is, IntRange< T > &range)
punctuationToken
Standard punctuation tokens (a character)
errorManip< error > abort(error &err)
iterator begin() noexcept
Return an iterator to begin traversing the UList.
const token & currentToken() const
Read access to the token at the current tokenIndex.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
An Ostream is an abstract base class for all output systems (streams, files, token lists...
label size() const noexcept
The number of elements in the container.
OBJstream os(runTime.globalPath()/outputName)
virtual void print(Ostream &os) const
Print stream description to Ostream.
virtual Istream & read(token &t) override
Return next token from stream.
unsigned scalarByteSize(const std::string &str)
Extract scalar size (in bytes) from "scalar=" tag in string.
label lineNumber() const noexcept
Const access to the current stream line number.
word format(conversionProperties.get< word >("format"))
const std::string version
OpenFOAM version (name or stringified number) as a std::string.
Generic input stream using a standard (STL) stream.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
bool hasPutback() const noexcept
True if putback token is in use.
labelRange find(const token::punctuationToken delimOpen, const token::punctuationToken delimClose, label pos=0) const
Find range containing matching delimiter pair, starting at the the specified position. The position -1 indicates to continue from the present tokenIndex() position.
T & back()
Access last element of the list, position [size()-1].
unsigned labelByteSize(const std::string &str)
Extract label size (in bytes) from "label=" tag in string.
static ITstream & empty_stream()
Return reference to an empty ITstream, for functions needing to return an ITstream reference but whic...
static label parseStream(ISstream &is, tokenList &tokens)
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
const_iterator cbegin() const noexcept
Return const_iterator to begin traversing the constant UList.
virtual void rewind() override
Rewind the stream so that it may be read again. Same as seek(0)
void print(Ostream &os) const override
Print stream description to Ostream.
iterator end() noexcept
Return an iterator to end traversing the UList.
bool skip(label n=1)
Move tokenIndex relative to the current position.
ITstream(const ITstream &is)
Copy construct.
void operator=(const ITstream &is)
Copy assignment, with rewind()
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Similar to IStringStream but using an externally managed buffer for its input. This allows the input ...
An input stream of tokens.
ITstream extract(const labelRange &range)
Remove a (start,size) subset from the list and move remaining elements down.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...