Provides helpers for serialization/deserialization of basic types.
More...
#include <Codable.hpp>
Provides helpers for serialization/deserialization of basic types.
◆ Prefix
Prefix type/.
Enumerator |
---|
ROOT | "*" prefix.
|
LIST | "-" prefix.
|
NONE | No prefix.
|
◆ decode()
std::vector< KeyValues > Codable::decode |
( |
const std::string & |
codableFile | ) |
|
|
static |
Split a Codable-compatible text file in a hierarchical list of (key,values) tuples, getting rid of extraneous spaces and punctuations. The following rules are applied:
- elements beginning with a '*' denote root-level objects.
- elements beginning with a '-' belong to an array, defined by the element just before those.
- elements can be nested on the same line: 'elem1: elem2: values'
- Parameters
-
codableFile | the text content to parse |
- Returns
- a hierarchical list of (key, value) tokens
◆ decodeBool()
bool Codable::decodeBool |
( |
const KeyValues & |
param, |
|
|
unsigned int |
position = 0 |
|
) |
| |
|
static |
Decode a boolean from a parameters tuple, at a specified position. A boolean is set to true if its value is 'true', 'True', 'yes', 'Yes' or '1'.
- Parameters
-
param | the parameters tuple |
position | index of the boolean in the values array |
- Returns
- a boolean
◆ decodeTexture()
std::pair< std::string, Layout > Codable::decodeTexture |
( |
const KeyValues & |
param | ) |
|
|
static |
Decode a texture from a parameters tuple and load it. A texture is described as follows:
texturetype: texturename
(where texturetype can be one of 'rgb', 'srgb', 'rgb32', 'rgbcube', 'srgbcube', 'rgb32cube' depending on the desired format).
- Parameters
-
param | the parameters tuple |
- Returns
- the name of the texture and its format.
◆ decodeTransformation()
glm::mat4 Codable::decodeTransformation |
( |
const std::vector< KeyValues > & |
params | ) |
|
|
static |
Decode a transformation from a series of parameters tuple. For now this function look for three keywords in the whole params vector: translation, orientation, scaling. A transformation is described as follows:
translation: X,Y,Z
orientation: axisX,axisY,axisZ angle
scaling: scale
- Parameters
-
params | a list of parameters tuples |
- Returns
- the 4x4 matrix representation of the transformation
◆ decodeVec2()
glm::vec2 Codable::decodeVec2 |
( |
const KeyValues & |
param, |
|
|
unsigned int |
position = 0 |
|
) |
| |
|
static |
Decode a 2D vector from a parameters tuple, starting at a specified position. A 2D vector is described as a set of 2 floats separated by spaces or commas: X,Y.
- Parameters
-
param | the parameters tuple |
position | index of the first vector component in the values array |
- Returns
- a 2D vector
◆ decodeVec3()
glm::vec3 Codable::decodeVec3 |
( |
const KeyValues & |
param, |
|
|
unsigned int |
position = 0 |
|
) |
| |
|
static |
Decode a 3D vector from a parameters tuple, starting at a specified position. A 3D vector is described as a set of 3 floats separated by spaces or commas: X,Y,Z.
- Parameters
-
param | the parameters tuple |
position | index of the first vector component in the values array |
- Returns
- a 3D vector
◆ decodeVec4()
glm::vec4 Codable::decodeVec4 |
( |
const KeyValues & |
param, |
|
|
unsigned int |
position = 0 |
|
) |
| |
|
static |
Decode a 4D vector from a parameters tuple, starting at a specified position. A 4D vector is described as a set of 4 floats separated by spaces or commas: X,Y,Z,W.
- Parameters
-
param | the parameters tuple |
position | index of the first vector component in the values array |
- Returns
- a 4D vector
◆ encode() [1/9]
std::string Codable::encode |
( |
bool |
b | ) |
|
|
static |
Encode a boolean into a string ("true" or "false")
- Parameters
-
b | the boolean value to encode |
- Returns
- the string representation
◆ encode() [2/9]
std::vector< KeyValues > Codable::encode |
( |
const glm::mat4 & |
transfo | ) |
|
|
static |
Encode a rotation/scaling/orientation transformation matrix into a set of parameters.
- Parameters
-
transfo | the transformation to encode |
- Returns
- a list of 3 Codable-comaptible parameters
◆ encode() [3/9]
std::vector< std::string > Codable::encode |
( |
const glm::vec2 & |
v | ) |
|
|
static |
Encode a 2D vector into a vector of strings {"X","Y"}
- Parameters
-
- Returns
- the vector of strings representation
◆ encode() [4/9]
std::vector< std::string > Codable::encode |
( |
const glm::vec3 & |
v | ) |
|
|
static |
Encode a 3D vector into a vector of strings {"X","Y","Z"}
- Parameters
-
- Returns
- the vector of strings representation
◆ encode() [5/9]
std::vector< std::string > Codable::encode |
( |
const glm::vec4 & |
v | ) |
|
|
static |
Encode a 4D vector into a vector of strings {"X","Y","Z","W"}
- Parameters
-
- Returns
- the vector of strings representation
◆ encode() [6/9]
std::string Codable::encode |
( |
const KeyValues & |
params | ) |
|
|
static |
Generate a Codable-compatible text representation from a (key,values) tuple.
- Parameters
-
params | a (key, value) token |
- Returns
- a string containing the text representation
◆ encode() [7/9]
std::string Codable::encode |
( |
const std::vector< KeyValues > & |
params | ) |
|
|
static |
Generate a Codable-compatible text representation from a hierarchical list of (key,values) tuples. The following rules are applied:
- elements beginning with a '*' denote root-level objects.
- elements beginning with a '-' belong to an array, defined by the element just before those.
- Parameters
-
params | a hierarchical list of (key, value) tokens |
- Returns
- a string containing the text representation
◆ encode() [8/9]
std::string Codable::encode |
( |
const std::vector< KeyValues > & |
params, |
|
|
Prefix |
prefix, |
|
|
uint |
level |
|
) |
| |
|
staticprivate |
Generate a Codable-compatible text representation from a hierarchical list of (key,values) tuples.
- Parameters
-
params | a hierarchical list of (key, value) tokens |
prefix | the type of prefix character to use ( |
- See also
- Prefix)
- Parameters
-
level | the indentation level (using tabulations) |
- Returns
- a string containing the text represenation
◆ encode() [9/9]
Encode a texture into a Codable-compliant tuple.
- Parameters
-
texture | the texture to encode |
- Returns
- the tuple representation
◆ unknown()
void Codable::unknown |
( |
const KeyValues & |
params | ) |
|
|
static |
Log an unknown parameter set
- Parameters
-
The documentation for this class was generated from the following files:
- src/engine/system/Codable.hpp
- src/engine/system/Codable.cpp