43#ifndef Foam_OCharStream_H
44#define Foam_OCharStream_H
70 virtual public std::ios,
75 typedef std::ostream stream_type;
85 stream_type(static_cast<buffer_type*>(this))
115 std::streamsize
count()
const
155 buffer_type::pubseekpos(0, std::ios_base::out);
156 stream_type::clear();
164 buffer_type::pubseekpos(
pos, std::ios_base::out);
165 stream_type::clear();
173 auto view(
size_t pos,
size_t len = std::string::npos)
const
190 std::string
str()
const
203 stream_type::clear();
207 template<
int SizeMin>
211 stream_type::clear();
218 stream_type::clear();
235 void push_back(
char c) { stream_type::put(c); }
254 void append(
const char* data, std::streamsize
count)
256 if (data &&
count > 0)
274 std::streamsize
count
333 template<
int SizeMin>
355 std::streamsize
count()
const {
return stream_.count(); }
380 auto view(
size_t pos,
size_t len = std::string::npos)
const
393 void swap(List<char>& other)
400 template<
int SizeMin>
432 os <<
"ocharstream: ";
453 void append(
const char* data, std::streamsize
count)
459 void append(std::string_view sv)
475 std::streamsize
count
A wrapper to hold a std::stream type for OpenFOAM wrapped streams. This is necessary since the OpenFO...
Foam::ocharstream stream_
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
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.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
An OSstream with internal List storage.
void swap(List< char > &other)
Exchange stream content and parameter contents, reset positions.
void overwrite(std::streampos pos, char c)
Overwrite a single character.
void setBlockSize(int n)
Block size was used in OpenFOAM-v2306 and earlier.
void swap(DynamicList< char, SizeMin > &other)
Exchange stream content and parameter contents, reset positions.
void reserve_exact(std::streamsize n)
Reserve output space for at least this amount. Does not apply min-size or capacity doubling etc.
void append(const char *data, std::streamsize count)
Append character content.
std::streampos tellp() const
Position of the put buffer.
void push_back(char c)
Append a single character to the end.
std::streamsize capacity() const
The put buffer capacity.
OCharStream(IOstreamOption streamOpt=IOstreamOption())
Default construct (empty output).
void append(std::streamsize count, char c)
Append repeated character content.
DynamicList< char > release()
Reset buffer and return contents.
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.
void extend(std::streamsize n)
Increase (reserve) space for another n entries.
UList< char > list() const
A list span of the current output characters (is modifiable!).
auto str() const
For OStringStream compatibility, return the buffer as string copy.
void seek(std::streampos pos)
Reposition the stream from the start.
void reserve(std::streamsize n)
Reserve output space for at least this amount.
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.
void append(std::string_view sv)
Append character content.
OCharStream(::Foam::DynamicList< char, SizeMin > &&buffer, IOstreamOption streamOpt=IOstreamOption())
Move construct from a DynamicList of initial storage (uses entire capacity).
std::streamsize count() const
The number of bytes outputted.
virtual void print(Ostream &os) const override
Print stream description.
void pop_back(int n=1)
Rewind the end by 1 or more elements.
OCharStream(::Foam::List< char > &&buffer, IOstreamOption streamOpt=IOstreamOption())
Move construct from a List of initial storage.
void extend_exact(std::streamsize n)
Increase (reserve) space for another n entries.
virtual void rewind()
Rewind the stream, clearing any old errors.
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.
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...
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.
void pop_back(int n=1)
Decrease the put area by 1 or more elements.
std::streamsize size_bytes() const
The span size (size of output buffer).
An output streambuf for memory access.
void swap(List< char > &other)
Exchange buffer content and parameter contents, reset positions.
void reserve_exact(const std::streamsize len)
Increase capacity for at least this size. Does not apply min-size or capacity doubling etc.
void extend(std::streamsize count)
Increase (reserve) space for another count entries.
DynamicList< char > release()
Reset buffer and return contents as a DynamicList. The list size corresponds to the region of output.
void extend_exact(std::streamsize count)
Increase (reserve) space for another count entries.
void reserve(const std::streamsize len)
Increase capacity (if needed) and adjust buffer pointers. Applies a min-size and capacity doubling.
Similar to std::ostringstream, but with the ability to swap character content. Has some similarity to...
void swap(List< char > &other)
Exchange stream content and parameter contents, reset positions.
void overwrite(std::streampos pos, char c)
Overwrite a single character.
char * data_bytes()
The output data (start of output characters).
ocharstream(DynamicList< char, SizeMin > &&buffer)
Move construct from DynamicList.
void swap(DynamicList< char, SizeMin > &other)
Exchange stream content and parameter contents, reset positions.
void reserve_exact(std::streamsize n)
Reserve output space for at least this amount. Does not apply min-size or capacity doubling etc.
void append(const char *data, std::streamsize count)
Append character content - like a plain write().
void push_back(char c)
Append a single character to the end.
std::streamsize capacity() const
The put buffer capacity.
void extend(std::streamsize count)
Increase (reserve) space for another count entries.
void append(std::streamsize count, char c)
Append repeated character content.
DynamicList< char > release()
Reset buffer and return contents.
auto view(size_t pos, size_t len=std::string::npos) const
A sub-slice string view of the buffer contents.
ocharstream(List< char > &&buffer)
Move construct from List.
void print(Ostream &os) const
Information about stream.
UList< char > list() const
A list span of current output contents (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 reserve(std::streamsize n)
Reserve output space for at least this amount. Applies a min-size and capacity doubling.
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.
std::streamsize count() const
The number of bytes outputted.
ocharstream()
Default construct - empty.
void rewind()
Rewind the stream, clearing any old errors.
void extend_exact(std::streamsize count)
Increase (reserve) space for another count entries.
void pop_back(int n=1)
Rewind the end by 1 or more elements.
std::string str() const
For ostringstream compatibility, return the buffer as string copy.
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)
dimensionedScalar pos(const dimensionedScalar &ds)
word format(conversionProperties.get< word >("format"))