mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-11-04 12:59:07 +01:00
49 lines
741 B
C++
49 lines
741 B
C++
#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_
|