Aeon Engine c550894
AeonGames Open Source Game Engine
Loading...
Searching...
No Matches
AeonGames::Decoder< T > Class Template Reference

Template class that dispatches decoding of binary data to registered format-specific decoders. More...

#include <C:/Code/AeonEngine/engine/include/Decoder.h>

Collaboration diagram for AeonGames::Decoder< T >:
Collaboration graph

Static Public Member Functions

static bool Decode (T &aOutput, uint32_t aId)
 Decodes a resource identified by its CRC32 id.
static bool Decode (T &aOutput, const std::string &aPath)
 Decodes a resource identified by its path string.
static bool Decode (T &aOutput, const void *aBuffer, size_t aBufferSize)
 Decodes data from a raw memory buffer by matching its magic bytes to a registered decoder.
static bool RegisterDecoder (const std::string &aMagick, const std::function< bool(T &, size_t, const void *) > &aDecoder)
 Registers a decoder function for the given magic byte sequence.
static bool UnregisterDecoder (const std::string &aMagick)
 Unregisters the decoder for the given magic byte sequence.

Detailed Description

template<class T>
class AeonGames::Decoder< T >

Template class that dispatches decoding of binary data to registered format-specific decoders.

Template Parameters
TThe type of object to decode into.

Definition at line 32 of file Decoder.h.

Member Function Documentation

◆ Decode() [1/3]

template<class T>
bool AeonGames::Decoder< T >::Decode ( T & aOutput,
const std::string & aPath )
inlinestatic

Decodes a resource identified by its path string.

Parameters
aOutputObject to receive the decoded data.
aPathPath string whose CRC32 is used to locate the resource.
Returns
true on success, false on failure.

Definition at line 60 of file Decoder.h.

◆ Decode() [2/3]

template<class T>
bool AeonGames::Decoder< T >::Decode ( T & aOutput,
const void * aBuffer,
size_t aBufferSize )
inlinestatic

Decodes data from a raw memory buffer by matching its magic bytes to a registered decoder.

Parameters
aOutputObject to receive the decoded data.
aBufferPointer to the data buffer.
aBufferSizeSize of the data buffer in bytes.
Returns
true on success, false if no matching decoder is found.

Definition at line 70 of file Decoder.h.

◆ Decode() [3/3]

template<class T>
bool AeonGames::Decoder< T >::Decode ( T & aOutput,
uint32_t aId )
inlinestatic

Decodes a resource identified by its CRC32 id.

Parameters
aOutputObject to receive the decoded data.
aIdCRC32 identifier of the resource.
Returns
true on success, false on failure.

Definition at line 39 of file Decoder.h.

◆ RegisterDecoder()

template<class T>
bool AeonGames::Decoder< T >::RegisterDecoder ( const std::string & aMagick,
const std::function< bool(T &, size_t, const void *) > & aDecoder )
inlinestatic

Registers a decoder function for the given magic byte sequence.

Parameters
aMagickMagic byte string identifying the format.
aDecoderFunction that decodes data of this format.
Returns
true if registration succeeded, false if a decoder for this magic already exists.

Definition at line 88 of file Decoder.h.

◆ UnregisterDecoder()

template<class T>
bool AeonGames::Decoder< T >::UnregisterDecoder ( const std::string & aMagick)
inlinestatic

Unregisters the decoder for the given magic byte sequence.

Parameters
aMagickMagic byte string identifying the format to remove.
Returns
true if the decoder was found and removed, false otherwise.

Definition at line 105 of file Decoder.h.


The documentation for this class was generated from the following file: