diff options
author | Determinant <[email protected]> | 2018-09-02 23:58:29 -0400 |
---|---|---|
committer | Determinant <[email protected]> | 2018-09-02 23:58:29 -0400 |
commit | 2c64bf03ebe7f5dbd4d45cb46f2c360d4cfad753 (patch) | |
tree | 995e2045e2a894304f85d71f1b26ab82962524fd | |
parent | 72f72c4404a49a1fb2191e6d6405296461b40a32 (diff) |
improve DataStream API
-rw-r--r-- | include/salticidae/stream.h | 11 |
1 files changed, 6 insertions, 5 deletions
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 T> - typename std::enable_if<is_ranged<T>::value, DataStream &>::type - operator<<(const T &d) { + typename std::enable_if<is_ranged<T>::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 T> - typename std::enable_if<!is_ranged<T>::value && - !std::is_integral<T>::value, DataStream &>::type + typename std::enable_if<!std::is_integral<T>::value, DataStream &>::type operator<<(const T &obj) { obj.serialize(*this); return *this; |