libxr 1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
LibXR::ConstRawData Class Reference

常量原始数据封装类。 A class for encapsulating constant raw data. More...

#include <libxr_type.hpp>

Public Member Functions

 ConstRawData (const void *addr, size_t size)
 使用指定地址和大小构造 ConstRawData 对象。 Constructs a ConstRawData object with the specified address and size.
 
 ConstRawData ()
 默认构造函数,初始化为空数据。 Default constructor initializing to empty data.
 
template<typename DataType >
 ConstRawData (const DataType &data)
 使用任意数据类型构造 ConstRawData,数据地址指向该对象,大小为该类型的字节大小。 Constructs ConstRawData using any data type, pointing to the object and setting the size to the type's byte size.
 
 ConstRawData (const ConstRawData &data)=default
 拷贝构造函数。 Copy constructor.
 
 ConstRawData (const RawData &data)
 RawData 构造 ConstRawData,数据地址和大小保持不变。 Constructs ConstRawData from RawData, keeping the same data address and size.
 
 ConstRawData (char *data)
 char * 指针构造 ConstRawData,数据大小为字符串长度(不含 \0)。 Constructs ConstRawData from a char * pointer, with size set to the string length (excluding \0).
 
 ConstRawData (const char *data)
 char * 指针构造 ConstRawData(常量版本)。 Constructs ConstRawData from a const char * pointer.
 
ConstRawDataoperator= (const ConstRawData &data)=default
 赋值运算符重载。 Overloaded assignment operator.
 

Data Fields

const voidaddr_
 数据存储地址(常量)。 The storage address of the data (constant).
 
size_t size_
 数据大小(字节)。 The size of the data (in bytes).
 

Detailed Description

常量原始数据封装类。 A class for encapsulating constant raw data.

该类与 RawData 类似,但存储的数据地址是 const 类型, 以确保数据不可修改。 This class is similar to RawData, but the stored data address is const, ensuring the data remains immutable.

Definition at line 127 of file libxr_type.hpp.

Constructor & Destructor Documentation

◆ ConstRawData() [1/7]

LibXR::ConstRawData::ConstRawData ( const void addr,
size_t  size 
)
inline

使用指定地址和大小构造 ConstRawData 对象。 Constructs a ConstRawData object with the specified address and size.

Parameters
addr数据的起始地址。 The starting address of the data.
size数据的大小(字节)。 The size of the data (in bytes).

Definition at line 139 of file libxr_type.hpp.

139: addr_(addr), size_(size) {}
size_t size_
数据大小(字节)。 The size of the data (in bytes).
const void * addr_
数据存储地址(常量)。 The storage address of the data (constant).

◆ ConstRawData() [2/7]

LibXR::ConstRawData::ConstRawData ( )
inline

默认构造函数,初始化为空数据。 Default constructor initializing to empty data.

Definition at line 145 of file libxr_type.hpp.

145: addr_(nullptr), size_(0) {}

◆ ConstRawData() [3/7]

template<typename DataType >
LibXR::ConstRawData::ConstRawData ( const DataType data)
inline

使用任意数据类型构造 ConstRawData,数据地址指向该对象,大小为该类型的字节大小。 Constructs ConstRawData using any data type, pointing to the object and setting the size to the type's byte size.

Template Parameters
DataType数据类型。 The data type.
Parameters
data需要存储的具体数据。 The actual data to be stored.

Definition at line 159 of file libxr_type.hpp.

160 : addr_(const_cast<DataType *>(&data)), size_(sizeof(DataType))
161 {
162 }
constexpr auto min(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最小值

◆ ConstRawData() [4/7]

LibXR::ConstRawData::ConstRawData ( const ConstRawData data)
default

拷贝构造函数。 Copy constructor.

Parameters
data另一个 ConstRawData 对象。 Another ConstRawData object.

◆ ConstRawData() [5/7]

LibXR::ConstRawData::ConstRawData ( const RawData data)
inline

RawData 构造 ConstRawData,数据地址和大小保持不变。 Constructs ConstRawData from RawData, keeping the same data address and size.

Parameters
dataRawData 对象。 A RawData object.

Definition at line 181 of file libxr_type.hpp.

181: addr_(data.addr_), size_(data.size_) {}

◆ ConstRawData() [6/7]

LibXR::ConstRawData::ConstRawData ( char data)
inline

char * 指针构造 ConstRawData,数据大小为字符串长度(不含 \0)。 Constructs ConstRawData from a char * pointer, with size set to the string length (excluding \0).

Parameters
dataC 风格字符串指针。 A C-style string pointer.

Definition at line 191 of file libxr_type.hpp.

191: addr_(data), size_(data ? strlen(data) : 0) {}

◆ ConstRawData() [7/7]

LibXR::ConstRawData::ConstRawData ( const char data)
inline

char * 指针构造 ConstRawData(常量版本)。 Constructs ConstRawData from a const char * pointer.

Parameters
dataC 风格字符串指针。 A C-style string pointer.

Definition at line 200 of file libxr_type.hpp.

200: addr_(data), size_(data ? strlen(data) : 0) {}

Member Function Documentation

◆ operator=()

ConstRawData & LibXR::ConstRawData::operator= ( const ConstRawData data)
default

赋值运算符重载。 Overloaded assignment operator.

Parameters
data另一个 ConstRawData 对象。 Another ConstRawData object.
Returns
返回赋值后的 ConstRawData 对象引用。 Returns a reference to the assigned ConstRawData object.

Field Documentation

◆ addr_

const void* LibXR::ConstRawData::addr_

数据存储地址(常量)。 The storage address of the data (constant).

Definition at line 214 of file libxr_type.hpp.

◆ size_

size_t LibXR::ConstRawData::size_

数据大小(字节)。 The size of the data (in bytes).

Definition at line 215 of file libxr_type.hpp.


The documentation for this class was generated from the following file: