Kodi Development  20.0
for Binary and Script based Add-Ons
5. Serialization operations

Detailed Description

Serialization operations


Serialization operation parts in interface:
Copy this to your project and extend with your parts or leave functions complete away where not used or supported.

Header parts:

size_t SerializeSize() override;
GAME_ERROR Serialize(uint8_t* data, size_t size) override;
GAME_ERROR Deserialize(const uint8_t* data, size_t size) override;
GAME_ERROR
Game add-on error codes
Definition: game.h:34
virtual GAME_ERROR Deserialize(const uint8_t *data, size_t size)
Deserialize the game from the given state.
Definition: Game.h:884
virtual GAME_ERROR Serialize(uint8_t *data, size_t size)
Serialize the state of the game.
Definition: Game.h:870
virtual size_t SerializeSize()
Get the number of bytes required to serialize the game.
Definition: Game.h:856

Source parts:

size_t CMyInstance::SerializeSize()
{
return 0;
}
GAME_ERROR CMyInstance::Serialize(uint8_t* data, size_t size)
{
}
GAME_ERROR CMyInstance::Deserialize(const uint8_t* data, size_t size)
{
}
@ GAME_ERROR_NOT_IMPLEMENTED
the method that the frontend called is not implemented
Definition: game.h:42

Modules

 Group header include
 
 Group source include
 

Function Documentation

◆ SerializeSize()

virtual size_t SerializeSize ( )
inlinevirtual

Get the number of bytes required to serialize the game.

Returns
the number of bytes, or 0 if serialization is not supported

◆ Serialize()

virtual GAME_ERROR Serialize ( uint8_t *  data,
size_t  size 
)
inlinevirtual

Serialize the state of the game.

Parameters
[in]dataThe buffer receiving the serialized game data
[in]sizeThe size of the buffer
Returns
the error, or GAME_ERROR_NO_ERROR if the game was serialized into the buffer

◆ Deserialize()

virtual GAME_ERROR Deserialize ( const uint8_t *  data,
size_t  size 
)
inlinevirtual

Deserialize the game from the given state.

Parameters
[in]dataA buffer containing the game's new state
[in]sizeThe size of the buffer
Returns
the error, or GAME_ERROR_NO_ERROR if the game deserialized