mirror of
https://github.com/esphome/esphome.git
synced 2024-11-24 16:08:10 +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.
|
* data from a buffer after it has been written.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
class ByteBuffer;
|
||||||
class ByteBuffer {
|
class ByteBuffer {
|
||||||
public:
|
public:
|
||||||
// Default constructor (compatibility with TEMPLATABLE_VALUE)
|
// Default constructor (compatibility with TEMPLATABLE_VALUE)
|
||||||
|
@ -143,6 +145,11 @@ class ByteBuffer {
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ByteBuffer &operator[](size_t idx) {
|
||||||
|
this->set_position(idx);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ByteBuffer(std::vector<uint8_t> const &data) : data_(data), limit_(data.size()) {}
|
ByteBuffer(std::vector<uint8_t> const &data) : data_(data), limit_(data.size()) {}
|
||||||
void update_() {
|
void update_() {
|
||||||
|
|
Loading…
Reference in a new issue