From 2c64bf03ebe7f5dbd4d45cb46f2c360d4cfad753 Mon Sep 17 00:00:00 2001 From: Determinant Date: Sun, 2 Sep 2018 23:58:29 -0400 Subject: improve DataStream API --- include/salticidae/stream.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/salticidae/stream.h b/include/salticidae/stream.h index e7e5640..5f54195 100644 --- a/include/salticidae/stream.h +++ b/include/salticidae/stream.h @@ -98,12 +98,14 @@ class DataStream { } template - typename std::enable_if::value, DataStream &>::type - operator<<(const T &d) { + typename std::enable_if::value>::type + put_data(const T &d) { buffer.insert(buffer.end(), d.begin(), d.end()); - return *this; } + DataStream &operator<<(const std::string &d) { put_data(d); return *this; } + DataStream &operator<<(const bytearray_t &d) { put_data(d); return *this; } + void put_data(const uint8_t *begin, const uint8_t *end) { size_t len = end - begin; buffer.resize(buffer.size() + len); @@ -121,8 +123,7 @@ class DataStream { } template - typename std::enable_if::value && - !std::is_integral::value, DataStream &>::type + typename std::enable_if::value, DataStream &>::type operator<<(const T &obj) { obj.serialize(*this); return *this; -- cgit v1.2.3-70-g09d2