64#ifndef Foam_ISpanStream_H
65#define Foam_ISpanStream_H
94 virtual public std::ios,
99 typedef std::istream stream_type;
109 stream_type(static_cast<buffer_type*>(this))
115 buffer_type(const_cast<char*>(buffer), nbytes),
116 stream_type(static_cast<buffer_type*>(this))
122 buffer_type(const_cast<char*>(
s.data()),
s.size()),
123 stream_type(static_cast<buffer_type*>(this))
162 auto view(
size_t pos,
size_t len = std::string::npos)
const
169 std::string
str()
const
181 buffer_type::pubseekpos(0, std::ios_base::in);
182 stream_type::clear();
190 buffer_type::pubseekpos(
pos, std::ios_base::in);
191 stream_type::clear();
196 void reset(
const char* buffer,
size_t nbytes)
199 stream_type::clear();
205 reset(
s, (
s ? std::char_traits<char>::length(
s) : 0));
209 void reset(
const std::string&
s)
212 stream_type::clear();
216 void reset(std::string_view
s)
219 stream_type::clear();
279 (buffer ? std::char_traits<char>::length(buffer) : 0)
286 const std::string&
s,
307 const ::Foam::UList<char>& buffer,
318 std::streampos
tellg()
const {
return stream_.input_pos(); }
337 auto view(
size_t pos,
size_t len = std::string::npos)
const
351 void reset(
const char* buffer,
size_t nbytes)
358 void reset(
const std::string&
s)
365 void reset(std::string_view
s)
372 virtual void rewind()
override
389 os <<
"ispanstream: ";
A wrapper to hold a std::stream type for OpenFOAM wrapped streams. This is necessary since the OpenFO...
Foam::ispanstream stream_
A simple container for options an IOstream can normally have.
versionNumber version() const noexcept
Get the stream version.
constexpr IOstreamOption(streamFormat fmt=streamFormat::ASCII, compressionType comp=compressionType::UNCOMPRESSED) noexcept
Default construct (ASCII, UNCOMPRESSED, currentVersion) or construct with format, compression.
streamFormat format() const noexcept
Get the current stream format.
Similar to IStringStream but using an externally managed buffer for its input. This allows the input ...
void reset(const std::string &s)
Reset input area to use data from a string.
ISpanStream(const std::string &s, IOstreamOption streamOpt=IOstreamOption())
Use data area from string content.
ISpanStream(const char *buffer)
Construct using specified nul-terminated buffer.
std::streamsize remaining() const
The number of characters remaining in the get area. Same as (capacity() - input_pos()).
std::streampos tellg() const
Position of the get buffer.
Istream & operator()() const
A non-const reference to const Istream.
std::streamsize capacity() const
The get buffer capacity.
auto view(size_t pos, size_t len=std::string::npos) const
A sub-slice string view of the buffer contents.
UList< char > list() const
A list span of the input characters (is modifiable!).
auto str() const
For IStringStream compatibility, return the buffer as string copy.
void seek(std::streampos pos)
Reposition the stream from the start.
ISpanStream(const ::Foam::UList< char > &buffer, IOstreamOption streamOpt=IOstreamOption())
Construct using data area from a List and its inherent storage size.
ISpanStream(IOstreamOption streamOpt=IOstreamOption())
Default construct (empty), optionally with specified stream option.
ISpanStream(std::string_view s, IOstreamOption streamOpt=IOstreamOption())
Use data area from string_view content.
label size() const
The input list size. Same as capacity().
auto view() const
A string_view of buffer contents.
ISpanStream(const char *buffer, size_t nbytes, IOstreamOption streamOpt=IOstreamOption())
Construct using specified buffer and number of bytes.
virtual void rewind() override
Rewind the stream, clearing any old errors.
std::streampos input_pos() const
The current get position within the buffer (tellg).
virtual void print(Ostream &os) const override
Print stream description.
void reset(const char *buffer, size_t nbytes)
Reset input area, position to buffer start and clear errors.
void reset(std::string_view s)
Reset input area to use data from a std::string_view.
Generic input stream using a standard (STL) stream.
void syncState()
Set stream state to match that of the std::istream.
ISstream(std::istream &is, const string &streamName, IOstreamOption streamOpt=IOstreamOption())
Construct wrapper around std::istream, set stream status.
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.
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...
Similar to std::istringstream, but with an externally managed input buffer which makes it most simila...
void reset(const std::string &s)
Reset the get buffer area to use the data from a string.
std::streamsize remaining() const
The number of characters remaining in the get area. Same as (capacity() - input_pos()).
std::streamsize capacity() const
The get buffer capacity.
ispanstream(std::string_view s)
Construct (shallow copy) from std::string_view content.
auto view(size_t pos, size_t len=std::string::npos) const
A sub-slice string view of the buffer contents.
void print(Ostream &os) const
Information about stream.
UList< char > list() const
A list span of the input characters (is modifiable!).
void debug_info(Ostream &os) const
Some information about the input buffer position/capacity.
ispanstream(const char *buffer, size_t nbytes)
Construct (shallow copy) for character array and number of bytes.
void seek(std::streampos pos)
Reposition the stream from the start.
auto view() const
A string_view of buffer contents.
void reset(const char *s)
Reset the get buffer area to use the nul-terminated buffer.
void rewind()
Rewind the stream, clearing any old errors.
std::streampos input_pos() const
The current get position within the buffer (tellg).
ispanstream()
Default construct - empty.
void reset(const char *buffer, size_t nbytes)
Reset the get buffer area.
void reset(std::string_view s)
Reset the get buffer area to use the data from a string_view.
std::string str() const
For istringstream compatibility, return the buffer as string copy.
The base input streambuf with memory access.
void resetg(char *s, std::streamsize n)
Reset get buffer with character data (can be nullptr) and count.
char * data_bytes() const
The span data (start of input characters).
std::streamsize span_capacity() const
The get buffer capacity.
bool in_range(std::streampos pos) const
True if position is within the current input range.
std::streamsize span_remaining() const
The number of characters remaining in the get area.
auto view() const
A string view of the current input region.
std::streamsize span_tellg() const
The current buffer get position.
std::streamsize size_bytes() const
The span size (number of input characters).
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))
dimensionedScalar pos(const dimensionedScalar &ds)
word format(conversionProperties.get< word >("format"))