| 7 | class ByteWriter; |
| 8 | |
| 9 | class Bytes |
| 10 | { |
| 11 | public: |
| 12 | Bytes(); |
| 13 | Bytes(unsigned size); |
| 14 | Bytes(const uint8_t* ptr, size_t len); |
| 15 | Bytes(const char* data); |
| 16 | Bytes(const std::string& data); |
| 17 | Bytes(std::initializer_list<uint8_t> data); |
| 18 | Bytes(std::shared_ptr<std::vector<uint8_t>> data); |
| 19 | Bytes(std::shared_ptr<std::vector<uint8_t>> data, |
| 20 | unsigned start, |
| 21 | unsigned end); |
| 22 | Bytes(std::istream& istream, size_t len = SIZE_MAX); |
| 23 | |
| 24 | Bytes* operator=(const Bytes& other); |
| 25 | |
| 26 | public: |
| 27 | static Bytes readFromFile(const std::string& filename); |
| 28 | |
| 29 | public: |
| 30 | /* General purpose methods */ |
| 31 | |
| 32 | unsigned size() const |
| 33 | { |
| 34 | return _high - _low; |
| 35 | } |
| 36 | bool empty() const |
| 37 | { |
| 38 | return _high == _low; |
| 39 | } |
| 40 | |
| 41 | bool operator==(const Bytes& other) const |
| 42 | { |
| 43 | return std::equal(cbegin(), cend(), other.cbegin(), other.cend()); |
| 44 | } |
| 45 | |
| 46 | bool operator!=(const Bytes& other) const |
| 47 | { |
| 48 | return !(*this == other); |
| 49 | } |
| 50 | |
| 51 | const uint8_t& operator[](unsigned offset) const; |
| 52 | const uint8_t* cbegin() const |
| 53 | { |
| 54 | return _data->data() + _low; |
| 55 | } |
| 56 | const uint8_t* cend() const |
| 57 | { |
| 58 | return _data->data() + _high; |
| 59 | } |
| 60 | const uint8_t* begin() const |
| 61 | { |
| 62 | return _data->data() + _low; |
| 63 | } |
| 64 | const uint8_t* end() const |
| 65 | { |
| 66 | return _data->data() + _high; |
no outgoing calls
no test coverage detected