|
LibSWOC++ 1.5.14
Solid Wall of C++
|
#include <BufferWriter.h>


Public Member Functions | |
| virtual BufferWriter & | write (char c)=0 |
| virtual BufferWriter & | write (void const *data, size_t length) |
| BufferWriter & | write (MemSpan< void const > span) |
| virtual const char * | data () const =0 |
| virtual bool | error () const =0 |
| virtual char * | aux_data () |
| virtual size_t | capacity () const =0 |
| virtual size_t | extent () const =0 |
| size_t | size () const |
| size_t | remaining () const |
| MemSpan< char > | aux_span () |
| virtual bool | commit (size_t n)=0 |
| virtual BufferWriter & | discard (size_t n)=0 |
| virtual BufferWriter & | restrict (size_t n)=0 |
| virtual BufferWriter & | restore (size_t n)=0 |
| virtual BufferWriter & | copy (size_t dst, size_t src, size_t n)=0 |
| template<typename... Args> | |
| BufferWriter & | print (const TextView &fmt, Args &&...args) |
| template<typename... Args> | |
| BufferWriter & | print_v (const TextView &fmt, const std::tuple< Args... > &args) |
| template<typename... Args> | |
| BufferWriter & | print (const bwf::Format &fmt, Args &&...args) |
| template<typename... Args> | |
| BufferWriter & | print_v (const bwf::Format &fmt, const std::tuple< Args... > &args) |
| template<typename Binding, typename Extractor> | |
| BufferWriter & | print_nfv (Binding &&names, Extractor &&ex, bwf::ArgPack const &args) |
| template<typename Binding, typename Extractor> | |
| BufferWriter & | print_nfv (Binding const &names, Extractor &&ex) |
| template<typename Binding> | |
| BufferWriter & | print_n (Binding const &names, TextView const &fmt) |
| template<typename T> | |
| BufferWriter & | format (bwf::Spec const &spec, T &&t) |
| template<typename T> | |
| BufferWriter & | format (bwf::Spec const &spec, T const &t) |
| virtual std::ostream & | operator>> (std::ostream &stream) const =0 |
Wrapper for operations on a buffer.
This maintains information about the size and amount in use of the buffer, preventing data overruns. In all cases, methods that write to the buffer clip the input to the size of the remaining buffer space. The error method can be used to detect such clipping. The theoretical size of the buffer is also tracked such that if there is not enough buffer space, the amount needed can be determined by the method extent.
Definition at line 35 of file BufferWriter.h.
|
inlinevirtual |
Definition at line 458 of file BufferWriter.h.
|
inlinevirtual |
Address of the first unused byte in the output buffer.
The address is fragile and calls to non-const methods can invalidate it.
nullptr if there is no remaining capacity. Reimplemented in swoc::FixedBufferWriter.
Definition at line 483 of file BufferWriter.h.
|
inline |
A memory span of the unused bytes.
This is a convenience method that is identical to
Definition at line 962 of file bwf_base.h.
|
pure virtual |
Implemented in swoc::FixedBufferWriter.
|
pure virtual |
Increase the extent by n bytes.
| n | Number of bytes. |
true if the commit is final, false if it should be retried.This is used to add data written in the aux_data to the written data in the buffer.
The return value should be true unless the write operation proceeding the call to commit along with the commit call should be retried. That is only reasonable if some state in the concrete implementation has changed to make success possible on the next try. Generally this will be because the implementation increased capacity.
Implemented in swoc::ArenaWriter, and swoc::FixedBufferWriter.
|
pure virtual |
Copy data from one part of the buffer to another.
The copy is guaranteed to be correct even if the src and dst overlap. The regions are clipped by the current extent. That is, bytes cannot be copied to nor from unwritten buffer. If the extent is currently more than the capacity, the copy is performed as if the buffer existed and then clipped to the actual buffer space.
| dst | Offset of the first by to copy onto. |
| src | Offset of the first byte to copy from. |
| n | Number of bytes to copy. |
*this Implemented in swoc::FixedBufferWriter.
|
pure virtual |
Implemented in swoc::FixedBufferWriter.
|
pure virtual |
Decrease the extent by n.
| n | Number of bytes to remove from the extent. |
The buffer content is unchanged, only the extent value is adjusted. This effectively discards n bytes of already written data.
Implemented in swoc::FixedBufferWriter.
|
pure virtual |
Get the error state.
true if in an error state, false if not. Implemented in swoc::FixedBufferWriter.
|
pure virtual |
Implemented in swoc::FixedBufferWriter.
| BufferWriter & swoc::BufferWriter::format | ( | bwf::Spec const & | spec, |
| T && | t ) |
Write formattted data.
| T | Data type. |
| spec | Format specifier. |
| t | Instance to print. |
Essentially this forwards t to bwformat.
Definition at line 1346 of file bwf_base.h.
| BufferWriter & swoc::BufferWriter::format | ( | bwf::Spec const & | spec, |
| T const & | t ) |
Write formattted data.
| T | Data type. |
| spec | Format specifier. |
| t | Instance to print. |
Essentially this forwards t to bwformat.
Definition at line 1340 of file bwf_base.h.
|
pure virtual |
IO stream operator.
| stream | Output stream. |
Write the buffer contents to stream.
Implemented in swoc::FixedBufferWriter.
| BufferWriter & swoc::BufferWriter::print | ( | const bwf::Format & | fmt, |
| Args &&... | args ) |
Formatted output to the buffer.
| Args | Types of the format input parameters. |
| fmt | Pre-condensed format. |
| args | Arguments for the format string. |
Definition at line 933 of file bwf_base.h.
| BufferWriter & swoc::BufferWriter::print | ( | const TextView & | fmt, |
| Args &&... | args ) |
Formatted output to the buffer.
| Args | Types of the format arguments. |
| fmt | Format string to control formatted output. |
| args | Parameters for the format string. |
The format string is Python style. See http://docs.solidwallofcode.com/libswoc/code/BW_Format.en.html for further information.
bwf_base.h. That file does not need to be included if formatted output is not used. Definition at line 927 of file bwf_base.h.
| BufferWriter & swoc::BufferWriter::print_n | ( | Binding const & | names, |
| TextView const & | fmt ) |
Write formatted output to this buffer.
| names | Name set for specifier names. |
| fmt | Format string. |
This is intended to be use with context name binding where names has the bindings and the format string fmt contains only references to those names, not to any arguments.
Definition at line 957 of file bwf_base.h.
| BufferWriter & swoc::BufferWriter::print_nfv | ( | Binding && | names, |
| Extractor && | ex, | ||
| bwf::ArgPack const & | args ) |
Write formatted output of args to this buffer.
| Binding | Type for the name binding instance. |
| Extractor | Format extractor type. |
| names | Name set for specifier names. |
| ex | Format processor instance, which parse the format piecewise. |
| args | The format parameters. |
Extractor must have at least two methods
bool that indicates if there is data left.bool ex(std::string_view& lit, bwf::Spec & spec)The latter must return whether a specifier was parsed, while filling in lit and spec as appropriate for the next chunk of format string. No literal is represented by a empty lit.
The name binding must have a function operator that takes two arguments, a BufferWriter& and a format specifier bwf::Spec. It is expected to generate output to the BufferWriter instance based on data in the format specifier (which contains, among other things, the name which caused the binding to be invoked).
Definition at line 865 of file bwf_base.h.
| BufferWriter & swoc::BufferWriter::print_nfv | ( | Binding const & | names, |
| Extractor && | ex ) |
Write formatted output of args to this buffer.
| Binding | Name binding functor. |
| Extractor | Format processor type. |
| names | Name set for specifier names. |
| ex | Format processor instance, which parse the format piecewise. |
Definition at line 951 of file bwf_base.h.
| BufferWriter & swoc::BufferWriter::print_v | ( | const bwf::Format & | fmt, |
| const std::tuple< Args... > & | args ) |
Formatted output to the buffer.
| Args | Types of the parameter for formatting. |
| fmt | Pre-condensed format string. |
| args | The format parameters in a tuple. |
This is the equivalent of the "va..." form for printing. Alternate front ends to formatted output should gather their formatting arguments into a tuple, usually using std::forward_as_tuple().
Definition at line 945 of file bwf_base.h.
| BufferWriter & swoc::BufferWriter::print_v | ( | const TextView & | fmt, |
| const std::tuple< Args... > & | args ) |
Formatted output to the buffer.
| Args | Types of the arguments for formatting. |
| fmt | Format string. |
| args | The format arguments in a tuple. |
This is the equivalent of the "va..." form for printing. Alternate front ends to formatted output should gather their formatting arguments into a tuple, usually using std::forward_as_tuple().
Definition at line 939 of file bwf_base.h.
|
inline |
Definition at line 493 of file BufferWriter.h.
|
pure virtual |
Restore n bytes of capacity. If there is an error condition, this function clears it and sets the extent to the size. It then increases the capacity by n characters.
restrict. Implemented in swoc::FixedBufferWriter.
|
pure virtual |
Reduce the capacity by n bytes If the capacity is reduced below the current size the instance goes in to an error state.
*this Implemented in swoc::FixedBufferWriter.
|
inline |
Definition at line 488 of file BufferWriter.h.
|
pure virtual |
Write c to the buffer.
| c | Character to write. |
Implemented in swoc::ArenaWriter, and swoc::FixedBufferWriter.
|
inline |
Write data to the buffer.
| span | Data source. |
Data from span is written directly to the buffer, and clipped to the size of the buffer.
Definition at line 478 of file BufferWriter.h.
|
inlinevirtual |
Write length bytes starting at data to the buffer.
| data | Source data. |
| length | Number of bytes in the source data. |
Reimplemented in swoc::ArenaWriter, and swoc::FixedBufferWriter.
Definition at line 461 of file BufferWriter.h.