Changeset View
Changeset View
Standalone View
Standalone View
src/streams.h
Show First 20 Lines • Show All 419 Lines • ▼ Show 20 Lines | public: | ||||
void write(const char *pch, size_t nSize) { | void write(const char *pch, size_t nSize) { | ||||
// Write to the end of the buffer | // Write to the end of the buffer | ||||
vch.insert(vch.end(), pch, pch + nSize); | vch.insert(vch.end(), pch, pch + nSize); | ||||
} | } | ||||
template <typename Stream> void Serialize(Stream &s) const { | template <typename Stream> void Serialize(Stream &s) const { | ||||
// Special case: stream << stream concatenates like stream += stream | // Special case: stream << stream concatenates like stream += stream | ||||
if (!vch.empty()) s.write((char *)&vch[0], vch.size() * sizeof(vch[0])); | if (!vch.empty()) { | ||||
s.write((char *)vch.data(), vch.size() * sizeof(value_type)); | |||||
} | |||||
} | } | ||||
template <typename T> CDataStream &operator<<(const T &obj) { | template <typename T> CDataStream &operator<<(const T &obj) { | ||||
// Serialize to this stream | // Serialize to this stream | ||||
::Serialize(*this, obj); | ::Serialize(*this, obj); | ||||
return (*this); | return (*this); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 384 Lines • Show Last 20 Lines |