23 #ifndef _SWE_SERIALIZE_ 24 #define _SWE_SERIALIZE_ 30 #include <unordered_map> 32 #include "swe_types.h" 33 #include "swe_binarybuf.h" 47 void setconstbuf(
bool);
48 void setfail(
bool)
const;
54 void setbigendian(
bool);
56 bool isconstbuf(
void)
const;
57 bool fail(
void)
const;
58 bool bigendian(
void)
const;
60 virtual int getBE16(
void)
const = 0;
61 virtual int getLE16(
void)
const = 0;
62 virtual int getBE32(
void)
const = 0;
63 virtual int getLE32(
void)
const = 0;
64 virtual s64 getBE64(
void)
const = 0;
65 virtual s64 getLE64(
void)
const = 0;
67 virtual void putBE64(u64) = 0;
68 virtual void putLE64(u64) = 0;
69 virtual void putBE32(u32) = 0;
70 virtual void putLE32(u32) = 0;
71 virtual void putBE16(u16) = 0;
72 virtual void putLE16(u16) = 0;
74 virtual BinaryBuf get(
size_t = 0 )
const = 0;
75 virtual void put(
const char*,
size_t) = 0;
77 bool wait(
const std::string &);
79 virtual int get8(
void)
const = 0;
80 int get16(
void)
const;
81 int get32(
void)
const;
82 s64 get64(
void)
const;
84 virtual void put8(
char) = 0;
89 virtual size_t tell(
void)
const {
return 0; }
90 virtual bool skip(
size_t)
const {
return false; }
91 virtual bool seek(
int offset,
int whence = RW_SEEK_SET)
const {
return false; }
103 const StreamBase & operator>> (
float &)
const;
104 const StreamBase & operator>> (std::string &)
const;
122 StreamBase & operator<< (
const std::string &);
129 template<
class Type1,
class Type2>
130 const StreamBase & operator>> (std::pair<Type1, Type2> & p)
const 132 return *
this >> p.first >> p.second;
136 const StreamBase & operator>> (std::vector<Type> & v)
const 138 size_t size = get32();
139 v.clear(); v.reserve(size);
140 for(
size_t it = 0; it < size; ++it)
142 Type t; *
this >> t; v.emplace_back(t);
148 const StreamBase & operator>> (std::list<Type> & v)
const 150 size_t size = get32(); v.clear();
151 for(
size_t it = 0; it < size; ++it)
153 Type t; *
this >> t; v.emplace_back(t);
158 template<
class Type1,
class Type2>
159 const StreamBase & operator>> (std::map<Type1, Type2> & v)
const 161 size_t size = get32(); v.clear();
162 for(
size_t ii = 0; ii < size; ++ii)
164 Type1 t; *
this >> t; *
this >> v[t];
169 template<
class Type1,
class Type2,
class... Args>
170 const StreamBase & operator>> (std::unordered_map<Type1, Type2, Args...> & v)
const 172 size_t size = get32(); v.clear();
173 for(
size_t ii = 0; ii < size; ++ii)
175 Type1 t; *
this >> t; *
this >> v[t];
180 template<
class Type1,
class Type2>
181 StreamBase & operator<< (const std::pair<Type1, Type2> & p)
183 return *
this << p.first << p.second;
186 template<
typename InputIterator>
187 StreamBase & push(InputIterator first, InputIterator last)
189 for(
auto it = first; it != last; ++it)
196 StreamBase & operator<< (const std::vector<Type> & v)
199 return push(std::begin(v), std::end(v));
203 StreamBase & operator<< (const std::list<Type> & v)
206 return push(std::begin(v), std::end(v));
209 template<
class Type1,
class Type2>
210 StreamBase & operator<< (const std::map<Type1, Type2> & v)
213 return push(std::begin(v), std::end(v));
216 template<
class Type1,
class Type2,
class... Args>
217 StreamBase & operator<< (
const std::unordered_map<Type1, Type2, Args...> & v)
220 return push(std::begin(v), std::end(v));
242 size_t size(
void)
const;
243 size_t last(
void)
const;
244 size_t tell(
void)
const;
245 bool skip(
size_t)
const;
246 bool seek(
int offset,
int whence)
const;
248 bool isValid(
void)
const {
return rw; }
250 int get8(
void)
const;
251 int getBE16(
void)
const;
252 int getLE16(
void)
const;
253 int getBE32(
void)
const;
254 int getLE32(
void)
const;
255 s64 getBE64(
void)
const;
256 s64 getLE64(
void)
const;
266 bool put(
const char*,
size_t);
Definition: swe_types.h:216
пространство SWE.
Definition: swe_binarybuf.cpp:30
класс прямоугольника
Definition: swe_rect.h:144
класс точки с двумя координатами
Definition: swe_rect.h:72
Definition: swe_serialize.h:225
класс бинарного массива
Definition: swe_binarybuf.h:35
класс двухмерной размерности
Definition: swe_rect.h:36
Definition: swe_serialize.h:44