11 #ifndef __SERIALIZER_HEADER
12 #define __SERIALIZER_HEADER
18 #include "../ustd/type_traits.hpp"
19 #include "../ustd/ard_assert.hpp"
20 #include "../util/byte_operation.hpp"
21 #include "../util/has_serialize.hpp"
25 template<
typename T,
typename Archive>
28 template<
typename T,
typename Archive, archive_enum type,
bool is_an_array>
30 static void get(T &
t, Archive & ar) {
31 for(uint16_t
i = 0;
i <
sizeof(
t)/
sizeof(
t[0]); ++
i) {
36 template<
typename T,
typename Archive>
38 static void get(T
const &
t, Archive & ar) {
39 #ifdef __TYPE_SIZE_CHECK
41 #endif //__TYPE_SIZE_CHECK
43 uint8_t idx =
sizeof(
t);
51 for(uint8_t
i = 0;
i < idx; ++
i)
54 for(uint8_t
i = 0;
i <
sizeof(
t); ++
i)
59 template<
typename T,
typename Archive>
61 static void get(T &
t, Archive & ar) {
62 #ifdef __TYPE_SIZE_CHECK
63 uint8_t exp_size = ar.read();
65 #endif //__TYPE_SIZE_CHECK
67 uint8_t idx = ar.read();
68 for(uint8_t
i = 0;
i < idx; ++
i)
70 for(uint8_t
i = idx;
i <
sizeof(
t); ++
i) {
74 for(uint8_t
i = 0;
i <
sizeof(
t); ++
i)
80 template<
typename T,
bool has_serialize_tpl,
typename Archive>
82 static void get(Archive & ar, T &
t) {
87 template<
typename T,
typename Archive>
89 static void get(Archive & ar, T &
t) {
94 template<
typename T,
typename Archive>
103 for(uint8_t
i = 0;
i <
sizeof(t); ++
i) {
104 res |= ((t >> ((
sizeof(t) -
i - 1))*8 & 0xFF) << (8 *
i));
110 template<
typename D, u
int16_t max_buf>
125 #ifdef __TYPE_SIZE_CHECK
127 #endif //__TYPE_SIZE_CHECK
131 #ifdef __TYPE_SIZE_CHECK
133 uint8_t size = data.read(
i);
138 os << data.read(
i) <<
F(
" ");
139 #else //__TYPE_SIZE_CHECK
140 os << data.read(
i) <<
F(
" ");
141 #endif //__TYPE_SIZE_CHECK
145 ASSERT_MSG(pos_ < max_buf,
"buffer_size to small in oss_class::operator<<")
146 data.write(pos_, in);
157 template<
typename D, u
int16_t max_buf,
typename S>
158 S & operator<<(S & os, oss_class<D, max_buf>
const & arg) {
164 template<
typename D, u
int16_t max_buf>
179 #ifdef __TYPE_SIZE_CHECK
181 #endif //__TYPE_SIZE_CHECK
185 #ifdef __TYPE_SIZE_CHECK
187 uint8_t size = data.read(
i);
192 os << data.read(
i) <<
F(
" ");
194 #else //__TYPE_SIZE_CHECK
195 os << data.read(
i) <<
F(
" ");
196 #endif //__TYPE_SIZE_CHECK
200 ASSERT_MSG(pos_ < max_buf,
"buffer_size to small in iss_class::operator<<")
201 return data.read(pos_++);
211 template<
typename D, u
int16_t max_buf,
typename S>
212 S & operator<<(S & os, iss_class<D, max_buf>
const & arg) {
217 #endif //__SERIALIZER_HEADER
static archive_enum const type
Definition: serializer.hpp:168
size_type & pos()
Definition: serializer.hpp:203
void serialize(Archive &ar, T &t)
Definition: serializer.hpp:95
Definition: serializer.hpp:111
static archive_enum const type
Definition: serializer.hpp:114
oss_class(D &data)
Definition: serializer.hpp:116
Definition: serializer.hpp:29
size_type & pos()
Definition: serializer.hpp:149
#define GREENB
Definition: color.hpp:16
#define ASSERT_MSG(exp, msg)
Definition: ard_assert.hpp:34
oss_class & operator&(T &t)
Definition: serializer.hpp:119
T little_endian(T const &t)
Definition: serializer.hpp:100
iss_class(D &data)
Definition: serializer.hpp:170
uint8_t read_byte(T const &t, detail::byte_op_size_type const &pos)
Definition: byte_operation.hpp:25
void print(S &os) const
Definition: serializer.hpp:178
uint16_t size_type
Definition: serializer.hpp:113
uint16_t size_type
Definition: serializer.hpp:167
archive_enum
Definition: archive_enum.hpp:14
#define NONE
Definition: color.hpp:37
void write_byte(T &t, detail::byte_op_size_type const &pos, uint8_t const &in)
Definition: byte_operation.hpp:30
#define REDB
Definition: color.hpp:14
Definition: serializer.hpp:81
#define F(x)
Definition: ustd_generic.hpp:15
void write(uint8_t const &in)
Definition: serializer.hpp:144
iss_class & operator&(T &t)
Definition: serializer.hpp:173
void print(S &os) const
Definition: serializer.hpp:124
Definition: serializer.hpp:165
#define ASSERT(exp)
Definition: ard_assert.hpp:33
uint8_t read()
Definition: serializer.hpp:199