9 #ifndef STK_UTIL_UTIL_MARSHAL_HPP
10 #define STK_UTIL_UTIL_MARSHAL_HPP
56 TYPE_CHECK_NONE = 0x00000000,
57 TYPE_CHECK_POD = 0x00000001,
58 TYPE_CHECK_LIST = 0x00000002,
59 TYPE_CHECK_VECTOR = 0x00000004,
60 TYPE_CHECK_ALL = 0xFFFFFFFF
67 Marshal(
unsigned type_check = TYPE_CHECK_NONE);
75 explicit Marshal(
const std::string &s);
83 std::string
str()
const;
101 void write(
const char *address,
size_t byte_count);
111 void read(
char *address,
size_t byte_count);
119 operator void * ()
const;
142 template <
typename T>
155 template <
typename T>
253 size_t size = v.
size();
255 for (
typename std::vector<T>::const_iterator it = v.begin(); it != v.end(); ++it)
262 Marshal &operator>>(Marshal &min, std::vector<T> &v) {
263 if (min.m_typeCheck & Marshal::TYPE_CHECK_VECTOR)
269 for (
size_t i = 0; i < size; ++i) {
279 Marshal &
operator<<(Marshal &mout,
const std::list<T> &l) {
280 if (mout.m_typeCheck & Marshal::TYPE_CHECK_LIST)
283 size_t size = l.size();
285 for (
typename std::list<T>::const_iterator it = l.begin(); it != l.end(); ++it)
292 Marshal &operator>>(Marshal &min, std::list<T> &l) {
293 if (min.m_typeCheck & Marshal::TYPE_CHECK_LIST)
298 for (
size_t i = 0; i < size; ++i) {
308 Marshal &write(Marshal &mout,
const T &t) {
309 mout.
write((
const char *) &t,
sizeof(T));
314 template <
typename T>
315 Marshal &read(Marshal &min, T &t) {
318 min.read((
char *) &t,
sizeof(T));
324 #endif // STK_UTIL_UTIL_MARSHAL_HPP