jjSTREAM class
A binary data stream for serialization and file I/O.
Reference-counted growable byte buffer that scripts use to serialize values. Typed push/pop and get helpers append and consume primitives and strings from either end, and the whole stream can be saved to or loaded from a file. Also used as the payload of networking packets sent via jjSendPacket.
Public static functions
- static auto Create() -> jjSTREAM*
- Returns a new empty instance.
- static auto CreateFromFile(const String& filename) -> jjSTREAM*
- Returns a new instance populated from a file.
Constructors, destructors, conversion operators
Public functions
- void AddRef()
- Increments the reference count.
- void Release()
- Decrements the reference count.
- auto operator=(const jjSTREAM& o) -> jjSTREAM&
-
auto getSize() const -> std::
uint32_t - Returns the size of the stream in bytes.
- auto isEmpty() const -> bool
- Returns whether the stream contains no data.
- auto save(const String& tilename) const -> bool
- Saves the stream contents to a file.
- void clear()
- Removes all data from the stream.
-
auto discard(std::
uint32_t count) -> bool - Discards the given number of bytes from the front of the stream.
- auto write(const String& value) -> bool
- Appends the raw bytes of a string to the stream.
- auto write(const jjSTREAM& value) -> bool
- Appends the contents of another stream.
-
auto get(String& value,
std::
uint32_t count) -> bool - Reads the given number of bytes from the front into a string.
-
auto get(jjSTREAM& value,
std::
uint32_t count) -> bool - Reads the given number of bytes from the front into another stream.
- auto getLine(String& value, const String& delim) -> bool
- Reads bytes from the front up to a delimiter into a string.
- auto push(bool value) -> bool
- Appends a boolean value to the stream.
-
auto push(std::
uint8_t value) -> bool - Appends an unsigned 8-bit value to the stream.
-
auto push(std::
int8_t value) -> bool - Appends a signed 8-bit value to the stream.
-
auto push(std::
uint16_t value) -> bool - Appends an unsigned 16-bit value to the stream.
-
auto push(std::
int16_t value) -> bool - Appends a signed 16-bit value to the stream.
-
auto push(std::
uint32_t value) -> bool - Appends an unsigned 32-bit value to the stream.
-
auto push(std::
int32_t value) -> bool - Appends a signed 32-bit value to the stream.
-
auto push(std::
uint64_t value) -> bool - Appends an unsigned 64-bit value to the stream.
-
auto push(std::
int64_t value) -> bool - Appends a signed 64-bit value to the stream.
- auto push(float value) -> bool
- Appends a single-precision float to the stream.
- auto push(double value) -> bool
- Appends a double-precision float to the stream.
- auto push(const String& value) -> bool
- Appends a length-prefixed string to the stream.
- auto push(const jjSTREAM& value) -> bool
- Appends the contents of another stream.
- auto pop(bool& value) -> bool
- Reads a boolean value from the front of the stream.
-
auto pop(std::
uint8_t& value) -> bool - Reads an unsigned 8-bit value from the front of the stream.
-
auto pop(std::
int8_t& value) -> bool - Reads a signed 8-bit value from the front of the stream.
-
auto pop(std::
uint16_t& value) -> bool - Reads an unsigned 16-bit value from the front of the stream.
-
auto pop(std::
int16_t& value) -> bool - Reads a signed 16-bit value from the front of the stream.
-
auto pop(std::
uint32_t& value) -> bool - Reads an unsigned 32-bit value from the front of the stream.
-
auto pop(std::
int32_t& value) -> bool - Reads a signed 32-bit value from the front of the stream.
-
auto pop(std::
uint64_t& value) -> bool - Reads an unsigned 64-bit value from the front of the stream.
-
auto pop(std::
int64_t& value) -> bool - Reads a signed 64-bit value from the front of the stream.
- auto pop(float& value) -> bool
- Reads a single-precision float from the front of the stream.
- auto pop(double& value) -> bool
- Reads a double-precision float from the front of the stream.
- auto pop(String& value) -> bool
- Reads a length-prefixed string from the front of the stream.
- auto pop(jjSTREAM& value) -> bool
- Reads stream contents from the front into another stream.