Raw Data and Type Identification
This module provides the RawData and ConstRawData classes for encapsulating raw data, along with the TypeID utility for type identification without relying on RTTI. These tools are useful for data description and cross-module data transfer in embedded environments.
RawData
class RawData;
A generic data wrapper that stores a pointer and size in bytes.
Constructors
RawData(void* addr, size_t size)– Specify address and size directly.RawData()– Default constructor for empty data.RawData(T&)– Construct from a writable object, referencing its address.RawData(char*)– Construct from a C-style string (excluding the trailing\0).RawData(char (&str)[N])– Construct from a writable char array, trimming at most one trailing\0.RawData(std::string&)– Construct from a writablestd::string.
Fields
void* addr_– Data pointersize_t size_– Size in bytes
ConstRawData
class ConstRawData;
Read-only data wrapper, similar to RawData but with an immutable address:
Constructors
- Supports construction from arbitrary objects,
RawData,char* / const char*,std::string,std::string_view, and char arrays. - Ensures
addr_is of typeconst void*, suitable for read-only views.
Additional notes:
- Char-array construction currently trims at most one trailing
\0, not every zero byte in the array. char* / const char*construction usesstd::strlen(...), so it expects a NUL-terminated string.
Fields
const void* addr_– Read-only data pointersize_t size_– Size in bytes
TypeID
class TypeID;
A lightweight type identification tool to avoid RTTI and typeid.