|
@ -1,8 +1,12 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
|
#ifdef ULE_CONFIG_OPTION_SERIALIZATION
|
|
|
#ifdef ULE_CONFIG_OPTION_SERIALIZATION
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <fast_float/fast_float.h>
|
|
|
#include <fast_float/fast_float.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "types.h"
|
|
|
#include "types.h"
|
|
|
#include "serialize.h"
|
|
|
#include "serialize.h"
|
|
|
#include "string.h"
|
|
|
#include "string.h"
|
|
@ -29,7 +33,7 @@ static inline const char* getFormatStringOut(double v) { ULE_TYPES_H_FTAG; retur |
|
|
static inline const char* getFormatStringOut(char* v) { ULE_TYPES_H_FTAG; return "\"%s\"\n"; } |
|
|
static inline const char* getFormatStringOut(char* v) { ULE_TYPES_H_FTAG; return "\"%s\"\n"; } |
|
|
static inline const char* getFormatStringOut(const char* v) { ULE_TYPES_H_FTAG; return "\"%s\"\n"; } |
|
|
static inline const char* getFormatStringOut(const char* v) { ULE_TYPES_H_FTAG; return "\"%s\"\n"; } |
|
|
|
|
|
|
|
|
#ifdef _USING_GLM_TYPES__
|
|
|
|
|
|
|
|
|
#ifdef ULE_CONFIG_OPTION_USE_GLM
|
|
|
static inline const char* getFormatStringOut(glm::vec<2, float, (glm::qualifier) 3> v) { ULE_TYPES_H_FTAG; return "%f %f\n"; } |
|
|
static inline const char* getFormatStringOut(glm::vec<2, float, (glm::qualifier) 3> v) { ULE_TYPES_H_FTAG; return "%f %f\n"; } |
|
|
static inline const char* getFormatStringOut(glm::vec<3, float, (glm::qualifier) 3> v) { ULE_TYPES_H_FTAG; return "%f %f %f\n"; } |
|
|
static inline const char* getFormatStringOut(glm::vec<3, float, (glm::qualifier) 3> v) { ULE_TYPES_H_FTAG; return "%f %f %f\n"; } |
|
|
static inline const char* getFormatStringOut(glm::vec<4, float, (glm::qualifier) 3> v) { ULE_TYPES_H_FTAG; return "%f %f %f %f\n"; } |
|
|
static inline const char* getFormatStringOut(glm::vec<4, float, (glm::qualifier) 3> v) { ULE_TYPES_H_FTAG; return "%f %f %f %f\n"; } |
|
@ -37,7 +41,6 @@ static inline const char* getFormatStringOut(glm::vec<4, float, (glm::qualifier) |
|
|
static inline const char* getFormatStringOut(glm::mat<2, 2, float, (glm::qualifier) 3> v) { ULE_TYPES_H_FTAG; return "%f %f %f %f\n"; } |
|
|
static inline const char* getFormatStringOut(glm::mat<2, 2, float, (glm::qualifier) 3> v) { ULE_TYPES_H_FTAG; return "%f %f %f %f\n"; } |
|
|
static inline const char* getFormatStringOut(glm::mat<3, 3, float, (glm::qualifier) 3> v) { ULE_TYPES_H_FTAG; return "%f %f %f %f %f %f %f %f %f\n"; } |
|
|
static inline const char* getFormatStringOut(glm::mat<3, 3, float, (glm::qualifier) 3> v) { ULE_TYPES_H_FTAG; return "%f %f %f %f %f %f %f %f %f\n"; } |
|
|
static inline const char* getFormatStringOut(glm::mat<4, 4, float, (glm::qualifier) 3> v) { ULE_TYPES_H_FTAG; return "%f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f\n"; } |
|
|
static inline const char* getFormatStringOut(glm::mat<4, 4, float, (glm::qualifier) 3> v) { ULE_TYPES_H_FTAG; return "%f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f\n"; } |
|
|
|
|
|
|
|
|
#endif
|
|
|
#endif
|
|
|
|
|
|
|
|
|
#define SERIALIZE_H_FUNC_BODY str->appendf(getFormatStringOut(v), v);
|
|
|
#define SERIALIZE_H_FUNC_BODY str->appendf(getFormatStringOut(v), v);
|
|
@ -52,7 +55,7 @@ void serialize(String* str, s64 v) { ULE_TYPES_H_FTAG; SERIALIZE_H_FUNC_BODY |
|
|
void serialize(String* str, float v) { ULE_TYPES_H_FTAG; SERIALIZE_H_FUNC_BODY } |
|
|
void serialize(String* str, float v) { ULE_TYPES_H_FTAG; SERIALIZE_H_FUNC_BODY } |
|
|
void serialize(String* str, double v) { ULE_TYPES_H_FTAG; SERIALIZE_H_FUNC_BODY } |
|
|
void serialize(String* str, double v) { ULE_TYPES_H_FTAG; SERIALIZE_H_FUNC_BODY } |
|
|
|
|
|
|
|
|
extern template<typename T> // @TODO do not use a template for this.
|
|
|
|
|
|
|
|
|
template<typename T> // @TODO do not use a template for this.
|
|
|
static inline void deserializeInteger(char** buffer, T* v) { |
|
|
static inline void deserializeInteger(char** buffer, T* v) { |
|
|
ULE_TYPES_H_FTAG; |
|
|
ULE_TYPES_H_FTAG; |
|
|
char* _buffer = *buffer; |
|
|
char* _buffer = *buffer; |
|
@ -227,7 +230,7 @@ void deserialize(char** buffer, const char** v) { |
|
|
*v = String::cpy(SERIALIZE_SCRATCH_BUFFER, (u32) i); |
|
|
*v = String::cpy(SERIALIZE_SCRATCH_BUFFER, (u32) i); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#ifdef _USING_GLM_TYPES__
|
|
|
|
|
|
|
|
|
#ifdef ULE_CONFIG_OPTION_USE_GLM
|
|
|
// I have no fucking idea why, but the declarations of glm types here resolve to a type,
|
|
|
// I have no fucking idea why, but the declarations of glm types here resolve to a type,
|
|
|
// that has a template parameter == 0, but all other instances of those types in my program
|
|
|
// that has a template parameter == 0, but all other instances of those types in my program
|
|
|
// have that template parameter == 3, so everything below becomes unresolved symbols if
|
|
|
// have that template parameter == 3, so everything below becomes unresolved symbols if
|
|
@ -310,10 +313,11 @@ void deserialize(char** buffer, glm::mat<4, 4, float, (glm::qualifier) 3>* v) { |
|
|
deserialize(buffer, m + i); |
|
|
deserialize(buffer, m + i); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
#endif // ULE_CONFIG_OPTION_USE_GLM
|
|
|
|
|
|
|
|
|
#undef SERIALIZE_H_FUNC_BODY
|
|
|
#undef SERIALIZE_H_FUNC_BODY
|
|
|
#undef SERIALIZE_H_DESERIALIZE_FUNC_BODY
|
|
|
#undef SERIALIZE_H_DESERIALIZE_FUNC_BODY
|
|
|
|
|
|
|
|
|
#endif
|
|
|
#endif
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|