82#ifndef Foam_OSpanStream_H
83#define Foam_OSpanStream_H
109 virtual public std::ios,
114 typedef std::ostream stream_type;
124 stream_type(static_cast<buffer_type*>(this))
130 buffer_type(buffer, nbytes),
131 stream_type(static_cast<buffer_type*>(this))
144 std::streamsize
count()
const
158 buffer_type::pubseekpos(0, std::ios_base::out);
159 stream_type::clear();
167 buffer_type::pubseekpos(
pos, std::ios_base::out);
168 stream_type::clear();
176 auto view(
size_t pos,
size_t len = std::string::npos)
const
182 UList<char>
list()
const
193 std::string
str()
const
203 void reset(
char* buffer,
size_t nbytes)
206 stream_type::clear();
210 void reset(std::string&
s)
212 s.resize(
s.capacity());
214 stream_type::clear();
240 std::streamsize
count
320 template<
int SizeMin>
354 auto view(
size_t pos,
size_t len = std::string::npos)
const
367 void reset(
char* buffer,
size_t nbytes)
374 void reset(std::string&
s)
397 os <<
"ospanstream: ";
406 void append(
const char* data, std::streamsize
count)
408 if (data &&
count > 0)
415 void append(std::string_view sv)
417 append(sv.data(), sv.size());
431 std::streamsize
count
A wrapper to hold a std::stream type for OpenFOAM wrapped streams. This is necessary since the OpenFO...
Foam::ospanstream stream_
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
label capacity() const noexcept
Size of the underlying storage.
void resize(const label len)
Alter addressable list size, allocating new space if required while recovering old content.
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 OCharStream but using an externally managed buffer for its output.
OSpanStream(std::string &buffer, IOstreamOption streamOpt=IOstreamOption())
Use data area from string content.
void overwrite(std::streampos pos, char c)
Overwrite a single character.
OSpanStream(::Foam::UList< char > &buffer, IOstreamOption streamOpt=IOstreamOption())
Construct using data area from a List and its inherent storage size.
void append(const char *data, std::streamsize count)
Append character content - same as writeRaw().
std::streampos tellp() const
Position of the put buffer.
std::streamsize capacity() const
The put buffer capacity.
void overwrite(std::streampos pos, std::string_view sv)
Overwrite a sub-slice with character content.
auto view(size_t pos, size_t len=std::string::npos) const
A sub-slice string view of the buffer contents.
OSpanStream(char *buffer, size_t nbytes, IOstreamOption streamOpt=IOstreamOption())
Construct using specified buffer and number of bytes.
UList< char > list() const
Span of the current output characters (is modifiable!).
auto str() const
For OStringStream compatibility, return buffer as string copy.
void seek(std::streampos pos)
Reposition the stream from the start.
void overwrite(std::streampos pos, const char *data, std::streamsize count)
Overwrite a sub-slice with character content.
label size() const
The current output size. Same as count(), output_pos(), tellp().
auto view() const
A string_view of buffer contents.
OSpanStream(::Foam::DynamicList< char, SizeMin > &buffer, IOstreamOption streamOpt=IOstreamOption())
Construct using full data area from DynamicList.
void append(std::string_view sv)
Append character content - same as writeRaw().
void reset(char *buffer, size_t nbytes)
Reset the put area.
std::streamsize count() const
The number of bytes outputted.
virtual void print(Ostream &os) const override
Print stream description.
virtual void rewind()
Rewind the stream, clearing any old errors.
OSpanStream(IOstreamOption streamOpt=IOstreamOption())
Default construct (empty output).
void reset(std::string &s)
Reset the put buffer area to use the data area from a string.
std::streampos output_pos() const
The current output position within the buffer (tellp).
Generic output stream using a standard (STL) stream.
OSstream(const OSstream &)=default
Copy construct.
virtual Ostream & writeRaw(const char *data, std::streamsize count) override
Low-level raw binary output.
void syncState()
Set stream state to match that of the std::ostream.
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...
An output streambuf for memory access.
void resetp(char *s, std::streamsize n)
Reset put buffer with character data (can be nullptr) and count.
std::streamsize span_tellp() const
The current buffer put position.
char * data_bytes() const
The span data (start of output characters).
std::streamsize span_capacity() const
The put buffer capacity.
bool in_range(std::streampos pos) const
True if position is within the current output range.
void overwrite(std::streampos pos, const char *data, std::streamsize count)
Overwrite a sub-slice with character content.
auto view() const
A string view of the current output region.
std::streamsize size_bytes() const
The span size (size of output buffer).
Similar to std::ostringstream, but with an externally managed output buffer which makes it most simil...
ospanstream()
Default construct - empty.
void overwrite(std::streampos pos, char c)
Overwrite a single character.
ospanstream(char *buffer, size_t nbytes)
Construct for character array and number of bytes.
char * data_bytes()
The output data (start of output characters).
std::streamsize capacity() const
The put buffer capacity.
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
Span of the current output characters (is modifiable!).
void debug_info(Ostream &os) const
Some information about the output buffer position/capacity.
void seek(std::streampos pos)
Reposition the stream from the start.
void overwrite(std::streampos pos, const char *data, std::streamsize count)
Overwrite a sub-slice with character content.
auto view() const
A string_view of buffer contents.
void reset(char *buffer, size_t nbytes)
Reset the put buffer area.
std::streamsize count() const
The number of bytes outputted.
void rewind()
Rewind the stream, clearing any old errors.
std::string str() const
For ostringstream compatibility, return the buffer as string copy.
void reset(std::string &s)
Reset the put buffer area to use the data area from a string.
std::streampos output_pos() const
The current output position within the buffer (tellp).
std::streamsize size_bytes() const
The current number of output characters.
const char * cdata_bytes() const
The output data (start of output 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"))