![]() |
Spicy
|
#include <stream.h>
Public Member Functions | |
Stream () | |
Stream (std::vector< Byte > d) | |
Stream (const Bytes &d) | |
Stream (const char *d) | |
Stream (const char *d, Size n) | |
Stream (const stream::View &d) | |
template<int N> | |
Stream (std::vector< std::array< Byte, N >> d) | |
Stream (const Stream &other) noexcept | |
Stream (Stream &&other) noexcept | |
Stream & | operator= (Stream &&other) noexcept |
Stream & | operator= (const Stream &other) |
~Stream () | |
Size | size () const |
bool | isEmpty () const |
void | append (const Bytes &data) |
void | append (Bytes &&data) |
void | append (std::unique_ptr< const Byte *> data) |
void | append (const char *data, size_t len) |
void | trim (const SafeConstIterator &i) |
void | freeze () |
void | unfreeze () |
bool | isFrozen () const |
SafeConstIterator | begin () const |
SafeConstIterator | end () const |
UnsafeConstIterator | unsafeBegin () const |
UnsafeConstIterator | unsafeEnd () const |
SafeConstIterator | at (Offset offset) const |
View | view (bool expanding=true) const |
Bytes | data () const |
bool | operator== (const Bytes &other) const |
bool | operator== (const Stream &other) const |
bool | operator== (const stream::View &other) const |
bool | operator!= (const Bytes &other) const |
bool | operator!= (const Stream &other) const |
bool | operator!= (const stream::View &other) const |
int | numberOfChunks () const |
void | debugPrint (std::ostream &out) const |
Static Public Member Functions | |
static void | debugPrint (std::ostream &out, const stream::detail::Chain *chain) |
Container for raw binary data that's going to be processed in streaming mode. The underlying data storage is optimized for cheap append operations even with large instances, but does not allow for any modifications to existing data. It also ensures that iterators bound to an instance can reliably detect if the instance gets deleted.
Internally, almost all functionality is delegated to a Chain instance, which resides on the heap.
|
inline |
Constructor.
|
inlineexplicit |
Creates an instance from a vector of Bytes
.
d | vector to create the stream from |
|
explicit |
Creates an instance from a bytes instance.
d | Bytes instance to the create the stream from |
|
inlineexplicit |
Creates an instance for C-style ASCII string, not including the final null byte. The data will be copied.
d | null-terminated string to create the stream from |
|
inline |
Creates an instance from an existing memory block. The data will be copied.
|
inline |
Creates an instance from an existing stream view.
d | View to create the stream from |
|
inline |
Creates an instance from a series of static-sized blocks.
d | a vector of N -sized arrays to create the stream from |
|
inlinenoexcept |
Constructs a stream from another stream instance.
other | instance to create this stream from |
|
inlinenoexcept |
Constructs a stream from another stream instance.
other | instance to create this stream from |
|
inline |
Destructor.
void Stream::append | ( | const Bytes & | data | ) |
Appends the content of a bytes instance. This function does not invalidate iterators.
data | Bytes to append |
void Stream::append | ( | Bytes && | data | ) |
Appends the content of a bytes instance. This function does not invalidate iterators.
data | Bytes to append |
void hilti::rt::Stream::append | ( | std::unique_ptr< const Byte *> | data | ) |
Appends the content of a raw memory area, taking ownership. This function does not invalidate iterators.
data | pointer to Bytes to append |
void Stream::append | ( | const char * | data, |
size_t | len | ||
) |
Appends the content of a raw memory area, copying the data. This function does not invalidate iterators.
data | pointer to the data to append |
len | length of the data to append |
|
inline |
Returns an iterator representing a specific offset.
offset | offset to use for the created iterator |
|
inline |
Returns a safe iterator representing the first byte of the instance.
Bytes Stream::data | ( | ) | const |
Returns a copy of the data the stream refers to. Depending on size of the stream, this can be an expensive operation.
void Stream::debugPrint | ( | std::ostream & | out | ) | const |
Prints out a debug rendering to the stream's internal representation.
|
static |
Prints out a debug rendering to a stream's internal representation.
|
inline |
Returns a safe iterator representing the end of the instance.
|
inline |
Freezes the instance. When frozen, no further data can be appended.
|
inline |
Returns true if the instance's size is zero.
|
inline |
Returns true if the instance is currently frozen.
|
inline |
For internal debugging: Returns the number of dynamic chunks allocated.
Assigns from another stream instance. This invalidates all existing iterators.
other | the stream instance to assign from |
Assigns from another stream instance. This invalidates all existing iterators.
other | the stream instance to assign from |
|
inline |
Returns the number of stream characters the instance contains.
|
inline |
Cuts off the beginning of the data up to, but excluding, a given iterator. All existing iterators pointing beyond that point will remain valid and keep their offsets the same. Trimming is permitted even on frozen instances.
i | iterator one past the last data element to trim |
|
inline |
Unfreezes the instance so that more data can be appended again.
|
inline |
Returns an unsafe iterator representing the first byte of the instance.
|
inline |
Returns an unsafe iterator representing the end of the instance.
|
inline |
Returns a view representing the entire instance.
expanding | if true, the returned view will automatically grow along with the stream object if more data gets added. |