42#ifndef Foam_ITstream_H
43#define Foam_ITstream_H
78 void reserveCapacity(
const label newCapacity);
92 void reset(
const char* input,
size_t nbytes);
96 inline const token& peekNoFail(
const label i)
const noexcept
121 const string&
name =
"input"
128 const string&
name =
"input",
137 const string&
name =
"input"
145 const string&
name =
"input"
154 const string&
name =
"input"
163 const string&
name =
"input"
172 const string&
name =
"input"
177 reset(
s.data(),
s.size());
231 return parse_chars(input.
cdata(), input.
size(), streamOpt);
244 return parse_chars(input, strlen(input), streamOpt);
260 return parse_chars(
s.data(),
s.size(), streamOpt);
269 virtual const fileName&
name()
const override {
return name_; }
303 return peekNoFail(0);
322 return peekNoFail(tokenIndex_);
331 const token&
peekToken(
const label i)
const {
return peekNoFail(i); };
342 label old(tokenIndex_);
378 const
token::punctuationToken delimOpen,
379 const
token::punctuationToken delimClose,
434 virtual std::ios_base::fmtflags
flags()
const override
436 return std::ios_base::fmtflags(0);
441 std::ios_base::fmtflags
flags(std::ios_base::fmtflags)
override
443 return std::ios_base::fmtflags(0);
490 virtual bool endRawRead()
override {
return false; }
493 virtual void rewind()
override
503 void print(Ostream&
os)
const override;
513 using Istream::operator();
526 #ifdef Foam_IOstream_extras
A simple container for options an IOstream can normally have.
constexpr IOstreamOption(streamFormat fmt=streamFormat::ASCII, compressionType comp=compressionType::UNCOMPRESSED) noexcept
Default construct (ASCII, UNCOMPRESSED, currentVersion) or construct with format, compression.
streamFormat
Data format (ascii | binary | coherent).
label lineNumber() const noexcept
Const access to the current stream line number.
An input stream of tokens.
virtual const fileName & name() const override
The name of the input token stream.
virtual std::ios_base::fmtflags flags() const override
Return current stream flags. Dummy for token stream, returns 0.
virtual fileName & name()
The name of the input token stream, for modification.
std::ios_base::fmtflags flags(std::ios_base::fmtflags) override
Set stream flags, return old stream flags. Dummy for token stream, returns 0.
void append(const token &t, bool)
const Type * findCompound(label pos=0) const
Find compoundToken of specified Type, starting at the specified position. The position -1 indicates t...
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.
const token & front() const noexcept
Failsafe peek at the token at the front of the tokenList.
label tokenIndex(label num) noexcept
Set the token index (no checks).
virtual bool beginRawRead() override
Start of low-level raw binary read : no-op.
virtual Istream & read(token &tok) override
Return next token from stream.
ITstream(std::string_view s, IOstreamOption streamOpt=IOstreamOption(), const string &name="input")
Construct token list by parsing the input character sequence.
virtual bool endRawRead() override
End of low-level raw binary read : no-op.
static ITstream & empty_stream()
Return reference to an empty ITstream, for functions needing to return an ITstream reference but whic...
static tokenList parse(const UList< char > &input, IOstreamOption streamOpt=IOstreamOption())
Create token list by parsing the input character sequence until no good tokens remain.
ITstream(const string &name, List< token > &&tokens, IOstreamOption streamOpt=IOstreamOption())
Move construct from tokens, with given name.
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.
const token & back() const noexcept
Failsafe peek at the token at the back of the tokenList.
void push_back(const token &t, bool)
label tokenIndex() const noexcept
The current token index when reading, or the insertion point.
void seek(label pos) noexcept
Move tokenIndex to the specified position and adjust the stream status (open/good/eof ....
label endLineNumber() const
The line number of the last token in stream.
label nRemainingTokens() const noexcept
Number of tokens remaining.
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.
ITstream(const string &name, const UList< token > &tokens, IOstreamOption streamOpt=IOstreamOption())
Copy construct from tokens, with given name.
label & tokenIndex() noexcept
Non-const access to the current token index.
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.
label startLineNumber() const
The line number of the first token in stream.
virtual void rewind() override
Rewind the stream so that it may be read again. Same as seek(0).
ITstream extract(const labelRange &range)
Remove a (start,size) subset from the list and move remaining elements down.
virtual ~ITstream()=default
Destructor.
bool hasPutback() const noexcept
True if putback token is in use.
static tokenList parse(const char *input, IOstreamOption streamOpt=IOstreamOption())
Create token list by parsing the input character sequence until no good tokens remain.
const token & peekToken(const label i) const
Failsafe read access to token at given position in the tokenList.
virtual Istream & readRaw(char *data, std::streamsize count) override
Low-level raw binary read : triggers not implemented error.
static tokenList parse(std::string_view s, IOstreamOption streamOpt=IOstreamOption())
Create token list by parsing the input character sequence until no good tokens remain.
const token & currentToken() const noexcept
Read access to the token at the current tokenIndex.
const token & peekFirst() const
Same as front().
tokenList & tokens() noexcept
The token contents (read/write access).
void operator=(const ITstream &is)
Copy assignment, with rewind().
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
virtual void rewind()=0
Rewind the stream so that it may be read again.
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...
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...
UList(const UList< T > &) noexcept=default
Copy construct, shallow copy.
bool empty() const noexcept
True if List is empty (ie, size() is zero).
T & back()
Access last element of the list, position [size()-1].
const T * cdata() const noexcept
Return pointer to the underlying array serving as data storage.
T * data() noexcept
Return pointer to the underlying array serving as data storage.
T & front()
Access first element of the list, position [0].
void size(const label n)
Older name for setAddressableSize.
A class for handling file names.
A range or interval of labels defined by a start and a size.
A token holds an item read from Istream.
static const token undefinedToken
An undefined token.
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 ...
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))
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
dimensionedScalar pos(const dimensionedScalar &ds)
static List< T > extract(const word &key, const UPtrList< entry > &entries, const T &initValue)
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).
#define FOAM_DEPRECATED_STRICT(since, replacement)