string.hpp 445 Bytes
Newer Older
Matthieu Dorier's avatar
Matthieu Dorier committed
1 2
#ifndef __THALLIUM_STRING_SERIALIZATION_HPP
#define __THALLIUM_STRING_SERIALIZATION_HPP
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

#include <string>
#include <iostream>

namespace thallium {

template<class A>
void save(A& ar, std::string& s) {
	size_t size = s.size();
	ar.write(&size);
	ar.write((const char*)(&s[0]), size);
}

template<class A>
void load(A& ar, std::string& s) {
	size_t size;
	s.clear();
	ar.read(&size);
	s.resize(size);
	ar.read((char*)(&s[0]),size);
}

}

#endif