Class PackedContainer

Class Documentation

class PackedContainer

Loaded structure of a generic packed file format.

Note

You generally shouldn’t use the direct constructor. For most use cases, a PackedEncoder should work instead.

Public Functions

PackedContainer(PackedFormat format, uint16_t ver, std::vector<unsigned char> &&data)

Create a PackedContainer by manually specifying attributes.

Parameters:
  • format – The format code of the container

  • ver – The version of the format

  • data – The uncompressed data to be stored

Throws:

std::runtime_error – If there is no data

PackedContainer(PackedFormat format, uint16_t ver, std::vector<char> &&data)

Create a PackedContainer by manually specifying attributes, allowing a signed char.

Parameters:
  • format – The format code of the container

  • ver – The version of the format

  • data – The uncompressed data to be stored, autoconverted to unsigned char

Throws:

std::runtime_error – If there is no data

inline PackedContainer()

Create an empty PackedContainer, only useful for default constructing if needed.

Warning

This will produce a PackedContainer with no data, the version set to 0 and the type set to Shader. DO NOT USE THIS CONTAINER!

inline PackedContainer(const PackedContainer &o)
inline PackedContainer(PackedContainer &&o)
PackedContainer &operator=(const PackedContainer&) = delete
PackedContainer &operator=(PackedContainer&&) = delete
void ExportToStream(std::ostream &stream)

Export a PackedContainer to a buffer.

Parameters:

stream – A stream to output data to

Throws:

std::runtime_error – If the container has no data or data compression fails

Public Members

const PackedFormat format

Type of contents.

const uint16_t version

File type version.

const std::vector<unsigned char> payload

Decompressed payload data.

Public Static Functions

static PackedContainer FromStream(std::istream &stream)

Create a PackedContainer from a stream.

Parameters:

stream – A stream referencing the contents of a packed file format

Throws:

std::runtime_error – If the stream is not valid, does not represent a valid packed file

Returns:

PackedContainer object

static PackedContainer FromAsset(const PackedAsset &asset)

Create a PackedContainer from a PackedAsset.

Parameters:

asset – A packed asset from an asset pack

Throws:

std::runtime_error – If the asset is of an unsupported type or the buffer is an invalid

Returns:

PackedContainer object