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

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

#include <libxr_type.hpp>

Public Member Functions

 RawData (void *addr, size_t size)
 使用指定地址和大小构造 RawData 对象。 Constructs a RawData object with the specified address and size.
 
 RawData ()
 默认构造函数,初始化为空数据。 Default constructor initializing to empty data.
 
template<typename DataType >
 RawData (const DataType &data)
 使用任意数据类型构造 RawData,数据地址指向该对象,大小为该类型的字节大小。 Constructs RawData using any data type, pointing to the object and setting the size to the type's byte size.
 
 RawData (const RawData &data)=default
 拷贝构造函数。 Copy constructor.
 
 RawData (char *data)
 char * 指针构造 RawData,数据大小为字符串长度(不含 \0)。 Constructs RawData from a char * pointer, with size set to the string length (excluding \0).
 
template<size_t N>
 RawData (const char(&data)[N])
 从字符数组构造 RawData,数据大小为数组长度减 1(不含 \0)。 Constructs RawData from a character array, with size set to array length minus 1 (excluding \0).
 
 RawData (const std::string &data)
 std::string 构造 RawData,数据地址指向字符串内容,大小为字符串长度。 Constructs RawData from std::string, with data pointing to the string content and size set to its length.
 
RawDataoperator= (const RawData &data)=default
 赋值运算符重载。 Overloaded assignment operator.
 

Data Fields

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

Detailed Description

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

该类提供了一种通用的数据存储方式,可以存储指针和数据大小, 以支持各种数据类型的传输和存储。 This class provides a generic way to store pointers and data sizes to support the transmission and storage of various data types.

Definition at line 20 of file libxr_type.hpp.

Constructor & Destructor Documentation

◆ RawData() [1/7]

LibXR::RawData::RawData ( void addr,
size_t  size 
)
inline

使用指定地址和大小构造 RawData 对象。 Constructs a RawData 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 32 of file libxr_type.hpp.

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

◆ RawData() [2/7]

LibXR::RawData::RawData ( )
inline

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

Definition at line 38 of file libxr_type.hpp.

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

◆ RawData() [3/7]

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

使用任意数据类型构造 RawData,数据地址指向该对象,大小为该类型的字节大小。 Constructs RawData 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 51 of file libxr_type.hpp.

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

◆ RawData() [4/7]

LibXR::RawData::RawData ( const RawData data)
default

拷贝构造函数。 Copy constructor.

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

◆ RawData() [5/7]

LibXR::RawData::RawData ( char data)
inline

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

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

Definition at line 73 of file libxr_type.hpp.

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

◆ RawData() [6/7]

template<size_t N>
LibXR::RawData::RawData ( const char(&)  data[N])
inline

从字符数组构造 RawData,数据大小为数组长度减 1(不含 \0)。 Constructs RawData from a character array, with size set to array length minus 1 (excluding \0).

Template Parameters
N数组大小。 The array size.
Parameters
data需要存储的字符数组。 The character array to be stored.

Definition at line 86 of file libxr_type.hpp.

86 : addr_(&data), size_(N - 1)
87 {
88 }

◆ RawData() [7/7]

LibXR::RawData::RawData ( const std::string &  data)
inline

std::string 构造 RawData,数据地址指向字符串内容,大小为字符串长度。 Constructs RawData from std::string, with data pointing to the string content and size set to its length.

Parameters
datastd::string 类型数据。 A std::string object.

Definition at line 98 of file libxr_type.hpp.

99 : addr_(const_cast<char *>(data.data())), size_(data.size())
100 {
101 }

Member Function Documentation

◆ operator=()

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

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

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

Field Documentation

◆ addr_

void* LibXR::RawData::addr_

数据存储地址。 The storage address of the data.

Definition at line 114 of file libxr_type.hpp.

◆ size_

size_t LibXR::RawData::size_

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

Definition at line 115 of file libxr_type.hpp.


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