61 tokens[
count] = std::move(tok);
98 IOstreamOption streamOpt
101 ISpanStream is(
s, nbytes, streamOpt);
111 void Foam::ITstream::reset(
const char*
input,
size_t nbytes)
113 ISpanStream is(
input, nbytes, static_cast<IOstreamOption>(*
this));
122 void Foam::ITstream::reserveCapacity(
const label newCapacity)
128 if (len < newCapacity)
138 while (len < newCapacity);
149 Istream(static_cast<IOstreamOption>(is)),
163 name_(
std::move(is.name_)),
247 const std::string&
input,
275 os <<
"ITstream : " << name_.c_str() <<
", line ";
287 if (toks.front().lineNumber() < toks.back().lineNumber())
302 return std::string();
324 for (++iter; (iter != last); (void)++iter)
330 const auto view = buf.view();
332 return std::string(view.data(), view.size());
344 return peekNoFail(tokenIndex_);
353 <<
"Token index " << tokenIndex_ <<
" out of range [0," 451 const label nToks = toks.size();
453 if (tokenIndex_ < nToks)
455 tok = toks[tokenIndex_++];
456 lineNumber_ = tok.lineNumber();
458 if (tokenIndex_ == nToks)
468 <<
"attempt to read beyond EOF" 481 tok.lineNumber(toks.back().lineNumber());
485 tok.lineNumber(this->lineNumber());
511 if (tok.isPunctuation())
513 if (tok.isPunctuation(delimOpen))
523 else if (tok.isPunctuation(delimClose))
536 slice.size() = (
pos - slice.start()) + 1;
551 static_cast<IOstreamOption>(*
this),
569 result.resize(label(last - first));
572 std::move(first, last, result.begin());
576 (void)
remove(slice);
601 if (slice.contains(tokenIndex_))
604 seek(slice.begin_value());
607 else if (tokenIndex_ >= slice.end_value())
699 reserveCapacity(tokenIndex_ + 1);
708 reserveCapacity(tokenIndex_ + 1);
717 const label len = toks.
size();
718 reserveCapacity(tokenIndex_ + len);
727 const label len = toks.
size();
728 reserveCapacity(tokenIndex_ + len);
743 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.
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)
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)
const token & currentToken() const noexcept
Read access to the token at the current tokenIndex.
errorManip< error > abort(error &err)
iterator begin() noexcept
Return an iterator to begin traversing the UList.
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.
const token & peek() const noexcept
Failsafe peek at what the next read would return, including handling of any putback.
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 specified position. The position -1 indicates to continue from the present tokenIndex() position.
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.
const T * cdata() const noexcept
Return pointer to the underlying array serving as data storage.
void print(Ostream &os) const override
Print stream description to Ostream.
bool skip(label n=1) noexcept
Move tokenIndex relative to the current position.
iterator end() noexcept
Return an iterator to end traversing the UList.
ITstream(const ITstream &is)
Copy construct.
void operator=(const ITstream &is)
Copy assignment, with rewind()
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
void seek(label pos) noexcept
Move tokenIndex to the specified position and adjust the stream status (open/good/eof ...
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 ...