mirror of
https://github.com/esphome/esphome.git
synced 2024-12-28 00:11:43 +01:00
extend the ByteBuffer with [] operator to set the position.
This commit is contained in:
parent
c237e1fcd7
commit
092d902620
1 changed files with 7 additions and 0 deletions
|
@ -30,6 +30,8 @@ enum Endian { LITTLE, BIG };
|
|||
* data from a buffer after it has been written.
|
||||
*
|
||||
*/
|
||||
|
||||
class ByteBuffer;
|
||||
class ByteBuffer {
|
||||
public:
|
||||
// Default constructor (compatibility with TEMPLATABLE_VALUE)
|
||||
|
@ -143,6 +145,11 @@ class ByteBuffer {
|
|||
return changed;
|
||||
}
|
||||
|
||||
ByteBuffer &operator[](size_t idx) {
|
||||
this->set_position(idx);
|
||||
return *this;
|
||||
}
|
||||
|
||||
protected:
|
||||
ByteBuffer(std::vector<uint8_t> const &data) : data_(data), limit_(data.size()) {}
|
||||
void update_() {
|
||||
|
|
Loading…
Reference in a new issue