28 #ifndef ARCHIVE_BASIC_TYPES_HPP
29 #define ARCHIVE_BASIC_TYPES_HPP
32 #include <graphlab/serialization/serializable_pod.hpp>
33 #include <graphlab/logger/assertions.hpp>
43 namespace archive_detail {
51 template <
typename OutArcType>
52 struct serialize_impl<OutArcType, const char*,
false> {
53 static void exec(OutArcType& oarc,
const char*
const& s) {
56 size_t length = strlen(s); length++;
58 oarc.write(reinterpret_cast<const char*>(s), length);
59 DASSERT_FALSE(oarc.fail());
65 template <
typename OutArcType,
size_t len>
66 struct serialize_impl<OutArcType, char [len], false> {
67 static void exec(OutArcType& oarc,
const char s[len] ) {
70 oarc.write(reinterpret_cast<const char*>(s), length);
71 DASSERT_FALSE(oarc.fail());
77 template <
typename OutArcType>
78 struct serialize_impl<OutArcType, char*,
false> {
79 static void exec(OutArcType& oarc,
char*
const& s) {
82 size_t length = strlen(s); length++;
84 oarc.write(reinterpret_cast<const char*>(s), length);
85 DASSERT_FALSE(oarc.fail());
90 template <
typename InArcType>
91 struct deserialize_impl<InArcType, char*,
false> {
92 static void exec(InArcType& iarc,
char*& s) {
98 iarc.read(reinterpret_cast<char*>(s), length);
99 DASSERT_FALSE(iarc.fail());
104 template <
typename InArcType,
size_t len>
105 struct deserialize_impl<InArcType, char [len], false> {
106 static void exec(InArcType& iarc,
char s[len]) {
109 ASSERT_LE(length, len);
110 iarc.read(reinterpret_cast<char*>(s), length);
111 DASSERT_FALSE(iarc.fail());
118 template <
typename OutArcType>
119 struct serialize_impl<OutArcType, std::string, false> {
120 static void exec(OutArcType& oarc,
const std::string& s) {
121 size_t length = s.length();
123 oarc.write(reinterpret_cast<const char*>(s.c_str()),
124 (std::streamsize)length);
125 DASSERT_FALSE(oarc.fail());
131 template <
typename InArcType>
132 struct deserialize_impl<InArcType, std::string, false> {
133 static void exec(InArcType& iarc, std::string& s) {
139 iarc.read(const_cast<char*>(s.c_str()), (std::streamsize)length);
140 DASSERT_FALSE(iarc.fail());
145 template <
typename OutArcType,
typename T,
typename U>
146 struct serialize_impl<OutArcType, std::pair<T, U>, false > {
147 static void exec(OutArcType& oarc,
const std::pair<T, U>& s) {
148 oarc << s.first << s.second;
154 template <
typename InArcType,
typename T,
typename U>
155 struct deserialize_impl<InArcType, std::pair<T, U>, false > {
156 static void exec(InArcType& iarc, std::pair<T, U>& s) {
157 iarc >> s.first >> s.second;