| 7 | namespace hps { |
| 8 | |
| 9 | class CharArrayInputBuffer { |
| 10 | public: |
| 11 | CharArrayInputBuffer(const char* arr) : arr(arr) { pos = 0; } |
| 12 | |
| 13 | void read(char* content, size_t length) { |
| 14 | strncpy(content, &arr[pos], length); |
| 15 | pos += length; |
| 16 | } |
| 17 | |
| 18 | char read_char() { |
| 19 | const char ch = arr[pos]; |
| 20 | pos++; |
| 21 | return ch; |
| 22 | } |
| 23 | |
| 24 | template <class T> |
| 25 | CharArrayInputBuffer& operator>>(T& t) { |
| 26 | Serializer<T, CharArrayInputBuffer>::parse(t, *this); |
| 27 | return *this; |
| 28 | } |
| 29 | |
| 30 | private: |
| 31 | const char* const arr; |
| 32 | |
| 33 | size_t pos; |
| 34 | }; |
| 35 | |
| 36 | } // namespace hps |
| 37 | #endif |