Changeset View
Changeset View
Standalone View
Standalone View
src/serialize.h
Show First 20 Lines • Show All 777 Lines • ▼ Show 20 Lines | template <typename Stream, typename I> void Unser(Stream &s, I &v) { | ||||
m_shift > std::numeric_limits<I>::max()) { | m_shift > std::numeric_limits<I>::max()) { | ||||
throw std::ios_base::failure("differential value overflow"); | throw std::ios_base::failure("differential value overflow"); | ||||
} | } | ||||
v = I(m_shift++); | v = I(m_shift++); | ||||
} | } | ||||
}; | }; | ||||
/** | /** | ||||
* Helper for a list of items containing a differentially encoded index as their | |||||
* first member. See DifferenceFormatter for info about the index encoding. | |||||
* | |||||
* The index should be a public member of the object. | |||||
* SerData()/UnserData() methods must be implemented to serialize/deserialize | |||||
* the remaining item data. | |||||
* | |||||
* To be used with a VectorFormatter. | |||||
*/ | |||||
struct DifferentialIndexedItemFormatter : public DifferenceFormatter { | |||||
template <typename Stream, typename T> void Ser(Stream &s, T v) { | |||||
DifferenceFormatter::Ser(s, v.index); | |||||
v.SerData(s); | |||||
} | |||||
template <typename Stream, typename T> void Unser(Stream &s, T &v) { | |||||
DifferenceFormatter::Unser(s, v.index); | |||||
v.UnserData(s); | |||||
} | |||||
}; | |||||
/** | |||||
* Forward declarations | * Forward declarations | ||||
*/ | */ | ||||
/** | /** | ||||
* string | * string | ||||
*/ | */ | ||||
template <typename Stream, typename C> | template <typename Stream, typename C> | ||||
void Serialize(Stream &os, const std::basic_string<C> &str); | void Serialize(Stream &os, const std::basic_string<C> &str); | ||||
▲ Show 20 Lines • Show All 455 Lines • Show Last 20 Lines |