mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-11-04 12:59:07 +01:00
Add bootloader extension
This commit is contained in:
committed by
Kyle Schwarz
parent
4db27aa187
commit
6ac041cadc
@@ -0,0 +1,48 @@
|
||||
#ifndef __BOOTLOADER_BYTESVIEW_H_
|
||||
#define __BOOTLOADER_BYTESVIEW_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
namespace Bootloader {
|
||||
|
||||
class BytesView {
|
||||
private:
|
||||
const uint8_t* ptr = nullptr;
|
||||
size_t length = 0;
|
||||
public:
|
||||
BytesView() = default;
|
||||
BytesView(const uint8_t* buf, size_t size) : ptr(buf), length(size) {}
|
||||
|
||||
const uint8_t* begin() const {
|
||||
return ptr;
|
||||
}
|
||||
|
||||
const uint8_t* end() const {
|
||||
return ptr + length;
|
||||
}
|
||||
|
||||
const uint8_t* data() const {
|
||||
return ptr;
|
||||
}
|
||||
|
||||
size_t size() const {
|
||||
return length;
|
||||
}
|
||||
|
||||
const uint8_t& operator[](size_t index) const {
|
||||
return ptr[index];
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Bootloader
|
||||
|
||||
} // namespace icsneo
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __BOOTLOADER_BYTESVIEW_H_
|
||||
Reference in New Issue
Block a user