50 if (count >= tokens.
size())
56 tokens[count] = std::move(tok);
72 static std::unique_ptr<ITstream> singleton;
76 singleton = std::make_unique<ITstream>(
Foam::zero{},
"empty-stream");
80 singleton->ITstream::clear();
81 singleton->ITstream::seek(0);
110void Foam::ITstream::reset(
const char* input,
size_t nbytes)
113 if (input && nbytes > 0)
130void Foam::ITstream::reserveCapacity(
const label newCapacity)
136 if (len < newCapacity)
146 while (len < newCapacity);
157 Istream(static_cast<IOstreamOption>(is)),
171 name_(std::move(is.name_)),
264 reset(input, strlen(input));
273 os <<
"ITstream : " << name_.c_str() <<
", line ";
285 if (toks.front().lineNumber() < toks.back().lineNumber())
300 return std::string();
322 for (++iter; (iter != last); (void)++iter)
328 const auto view = buf.view();
330 return std::string(
view.data(),
view.size());
342 return peekNoFail(tokenIndex_);
351 <<
"Token index " << tokenIndex_ <<
" out of range [0,"
444 lineNumber_ = tok.lineNumber();
449 const label nToks = toks.size();
451 if (tokenIndex_ < nToks)
453 tok = toks[tokenIndex_++];
454 lineNumber_ = tok.lineNumber();
456 if (tokenIndex_ == nToks)
466 <<
"attempt to read beyond EOF"
479 tok.lineNumber(toks.back().lineNumber());
483 tok.lineNumber(this->lineNumber());
509 if (tok.isPunctuation())
511 if (tok.isPunctuation(delimOpen))
521 else if (tok.isPunctuation(delimClose))
534 slice.size() = (
pos - slice.start()) + 1;
599 if (
slice.contains(tokenIndex_))
605 else if (tokenIndex_ >= slice.end_value())
718 reserveCapacity(tokenIndex_ + 1);
727 reserveCapacity(tokenIndex_ + 1);
736 const label len = toks.
size();
737 reserveCapacity(tokenIndex_ + len);
746 const label len = toks.
size();
747 reserveCapacity(tokenIndex_ + len);
762 Istream::operator=(is);
Input/output streams with (internal or external) character storage.
A simple container for options an IOstream can normally have.
versionNumber version() const noexcept
Get the stream version.
streamFormat format() const noexcept
Get the current stream format.
void setBad() noexcept
Set stream state to be 'bad'.
label lineNumber() const noexcept
Const access to the current stream line number.
unsigned scalarByteSize() const noexcept
The sizeof (scalar) in bytes associated with the stream.
bool bad() const noexcept
True if stream is corrupted.
virtual void print(Ostream &os) const
Print stream description to Ostream.
label lineNumber_
The file line.
void setEof() noexcept
Set stream state as reached 'eof'.
void setLabelByteSize(unsigned nbytes) noexcept
Set the sizeof (label) in bytes associated with the stream.
bool eof() const noexcept
True if end of input seen.
void setScalarByteSize(unsigned nbytes) noexcept
Set the sizeof (scalar) in bytes associated with the stream.
unsigned labelByteSize() const noexcept
The sizeof (label) in bytes associated with the stream.
void setGood() noexcept
Set stream state to be good.
void setOpened() noexcept
Set stream opened.
Similar to IStringStream but using an externally managed buffer for its input. This allows the input ...
Generic input stream using a standard (STL) stream.
virtual Istream & read(token &t) override
Return next token from stream.
An input stream of tokens.
virtual const fileName & name() const override
The name of the input token stream.
std::string toString() const
Concatenate tokens into a space-separated std::string. The resulting string may contain quote charact...
label remove(const labelRange &range)
Remove a (start,size) subset from the list and move remaining elements down.
virtual Istream & read(token &tok) override
Return next token from stream.
static ITstream & empty_stream()
Return reference to an empty ITstream, for functions needing to return an ITstream reference but whic...
void print(Ostream &os) const override
Print stream description to Ostream.
void add_tokens(const token &tok)
Copy append a token at the current tokenIndex, incrementing the index.
void seek(label pos) noexcept
Move tokenIndex to the specified position and adjust the stream status (open/good/eof ....
bool skip(label n=1) noexcept
Move tokenIndex relative to the current position.
const tokenList & tokens() const noexcept
The token contents (read-only access).
const token & peek() const noexcept
Failsafe peek at what the next read would return, including handling of any putback.
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....
ITstream(const ITstream &is)
Copy construct.
ITstream extract(const labelRange &range)
Remove a (start,size) subset from the list and move remaining elements down.
virtual Istream & readRaw(char *data, std::streamsize count) override
Low-level raw binary read : triggers not implemented error.
const token & currentToken() const noexcept
Read access to the token at the current tokenIndex.
void operator=(const ITstream &is)
Copy assignment, with rewind().
IntType size() const noexcept
The size of the range.
bool contains(IntType value) const noexcept
True if the (global) value is within the range.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
bool getBack(token &tok)
Retrieve the put-back token if there is one.
const token & peekBack() const noexcept
Examine putback token without removing it.
bool hasPutback() const noexcept
True if putback token is in use.
Istream(const Istream &)=default
Copy construct.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void operator=(const UList< token > &list)
void resize(const label len)
Adjust allocated size of list.
void clear()
Clear the list, i.e. set size to zero.
An OSstream with internal List storage.
auto view() const
A string_view of buffer contents.
virtual int precision() const override
Get precision of output field.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
T & first()
Access first element of the list, position [0].
iterator begin() noexcept
Return an iterator to begin traversing the UList.
bool empty() const noexcept
True if List is empty (ie, size() is zero).
T & back()
Access last element of the list, position [size()-1].
iterator end() noexcept
Return an iterator to end traversing the UList.
const_iterator cend() const noexcept
Return const_iterator to end traversing the constant UList.
std::string_view view() const
Return a string_view of the charList. Content is non-modifiable.
const T * cdata() const noexcept
Return pointer to the underlying array serving as data storage.
const_iterator cbegin() const noexcept
Return const_iterator to begin traversing the constant UList.
SubList< T > slice(const label pos, label len=-1)
Return SubList slice (non-const access) - no range checking.
T & front()
Access first element of the list, position [0].
label size() const noexcept
The number of elements in the container.
void size(const label n)
Older name for setAddressableSize.
std::streamsize size_bytes() const noexcept
Number of contiguous bytes for the List data.
T & operator[](const label i)
Return element of UList.
T & last()
Access last element of the list, position [size()-1].
A range or interval of labels defined by a start and a size.
A token holds an item read from Istream.
label lineNumber() const noexcept
The line number for the token.
bool isPunctuation() const noexcept
Token is PUNCTUATION.
punctuationToken
Standard punctuation tokens (a character).
bool good() const noexcept
True if token is not UNDEFINED or ERROR.
void reset()
Reset token to UNDEFINED and clear any allocated storage.
A class for handling words, derived from Foam::string.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
limits reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL))
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
OBJstream os(runTime.globalPath()/outputName)
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))
unsigned scalarByteSize(const std::string &str)
Extract scalar size (in bytes) from "scalar=" tag in string.
unsigned labelByteSize(const std::string &str)
Extract label size (in bytes) from "label=" tag in string.
dimensionedScalar pos(const dimensionedScalar &ds)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
static label parseStream(ISstream &is, tokenList &tokens)
errorManip< error > abort(error &err)
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
List< token > tokenList
List of token, used for dictionary primitive entry (for example).
errorManipArg< error, int > exit(error &err, const int errNo=1)
word format(conversionProperties.get< word >("format"))