NexusForce 1.0.0
A rigorously engineered full-stack C++ backend library.
载入中...
搜索中...
未找到
neforce::http::byte_cursor类 参考

带边界检查的字节游标,用于协议解析 更多...

#include <byte_cursor.hpp>

Public 成员函数

 byte_cursor () noexcept=default
 构造空游标
 byte_cursor (const byte_t *data, size_t size) noexcept
 从原始指针和长度构造
 byte_cursor (cbyte_view view) noexcept
 cbyte_view 构造
size_t remaining () const noexcept
 剩余可读字节数
size_t consumed_bytes () const noexcept
 已消费的字节数
bool exhausted () const noexcept
 是否已读完所有数据
const byte_tdata () const noexcept
 获取底层数据指针
size_t size () const noexcept
 获取底层缓冲区总大小
optional< byte_ttry_read_byte () noexcept
 尝试读取一个字节
optional< byte_tpeek_byte () const noexcept
 查看当前字节而不消费
optional< uint16_ttry_read_be16 () noexcept
 尝试读取大端序 16 位无符号整数
optional< uint32_ttry_read_be24 () noexcept
 尝试读取大端序 24 位无符号整数
optional< uint32_ttry_read_be32 () noexcept
 尝试读取大端序 32 位无符号整数
optional< uint64_ttry_read_be64 () noexcept
 尝试读取大端序 64 位无符号整数
optional< uint16_ttry_read_le16 () noexcept
 尝试读取小端序 16 位无符号整数
optional< uint32_ttry_read_le32 () noexcept
 尝试读取小端序 32 位无符号整数
optional< uint64_ttry_read_le64 () noexcept
 尝试读取小端序 64 位无符号整数
optional< cbyte_viewtry_read_bytes (size_t count) noexcept
 尝试读取指定长度的字节块
bool skip (size_t count) noexcept
 跳过指定数量的字节
void reset (const byte_t *data, size_t size) noexcept
 重置游标到新的缓冲区
optional< uint64_ttry_read_bits (uint8_t n) noexcept
 尝试读取指定位数(用于 HPACK Huffman 解码)
optional< uint64_ttry_peek_bits (uint8_t n) const noexcept
 预读指定位数而不消费
void skip_bits (uint8_t n) noexcept
 跳过指定位数
size_t bits_remaining () const noexcept
 位缓冲区中剩余的可读位数
bool refill_bits () noexcept
 从字节缓冲区中补充位缓冲区

详细描述

带边界检查的字节游标,用于协议解析

封装缓冲区及读取位置,提供安全的逐字节/多位读取操作,

在文件 byte_cursor.hpp29 行定义.

成员函数说明

◆ peek_byte()

optional< byte_t > neforce::http::byte_cursor::peek_byte ( ) const
inlinenodiscardnoexcept

查看当前字节而不消费

返回
当前字节,数据不足返回 none

在文件 byte_cursor.hpp82 行定义.

引用了 neforce::none.

◆ refill_bits()

bool neforce::http::byte_cursor::refill_bits ( )
inlinenoexcept

从字节缓冲区中补充位缓冲区

返回
补充成功返回 true,无剩余字节返回 false

在文件 byte_cursor.hpp274 行定义.

引用了 exhausted().

◆ reset()

void neforce::http::byte_cursor::reset ( const byte_t * data,
size_t size )
inlinenoexcept

重置游标到新的缓冲区

参数
data新的缓冲区指针
size新的缓冲区大小

在文件 byte_cursor.hpp212 行定义.

引用了 data() , 以及 size().

◆ skip()

bool neforce::http::byte_cursor::skip ( size_t count)
inlinenoexcept

跳过指定数量的字节

参数
count要跳过的字节数
返回
跳过成功返回 true,数据不足返回 false

在文件 byte_cursor.hpp199 行定义.

引用了 neforce::count().

◆ skip_bits()

void neforce::http::byte_cursor::skip_bits ( uint8_t n)
inlinenoexcept

跳过指定位数

参数
n要跳过的位数

在文件 byte_cursor.hpp259 行定义.

◆ try_peek_bits()

optional< uint64_t > neforce::http::byte_cursor::try_peek_bits ( uint8_t n) const
inlinenodiscardnoexcept

预读指定位数而不消费

参数
n要预读的位数(最多 64)
返回
成功返回该值,数据不足返回 none

在文件 byte_cursor.hpp247 行定义.

引用了 neforce::numeric_traits< T, Dummy >::max() , 以及 neforce::none.

◆ try_read_be16()

optional< uint16_t > neforce::http::byte_cursor::try_read_be16 ( )
inlinenodiscardnoexcept

尝试读取大端序 16 位无符号整数

返回
成功返回该值,数据不足返回 none

在文件 byte_cursor.hpp93 行定义.

引用了 neforce::none , 以及 neforce::endian::read_be16().

◆ try_read_be24()

optional< uint32_t > neforce::http::byte_cursor::try_read_be24 ( )
inlinenodiscardnoexcept

尝试读取大端序 24 位无符号整数

返回
成功返回该值,数据不足返回 none

在文件 byte_cursor.hpp106 行定义.

引用了 neforce::none , 以及 neforce::endian::read_be24().

◆ try_read_be32()

optional< uint32_t > neforce::http::byte_cursor::try_read_be32 ( )
inlinenodiscardnoexcept

尝试读取大端序 32 位无符号整数

返回
成功返回该值,数据不足返回 none

在文件 byte_cursor.hpp119 行定义.

引用了 neforce::none , 以及 neforce::endian::read_be32().

◆ try_read_be64()

optional< uint64_t > neforce::http::byte_cursor::try_read_be64 ( )
inlinenodiscardnoexcept

尝试读取大端序 64 位无符号整数

返回
成功返回该值,数据不足返回 none

在文件 byte_cursor.hpp132 行定义.

引用了 neforce::none , 以及 neforce::endian::read_be64().

◆ try_read_bits()

optional< uint64_t > neforce::http::byte_cursor::try_read_bits ( uint8_t n)
inlinenodiscardnoexcept

尝试读取指定位数(用于 HPACK Huffman 解码)

参数
n要读取的位数(最多 64)
返回
成功返回该值,数据不足返回 none

在文件 byte_cursor.hpp225 行定义.

引用了 neforce::numeric_traits< T, Dummy >::max(), neforce::none , 以及 try_read_byte().

◆ try_read_byte()

optional< byte_t > neforce::http::byte_cursor::try_read_byte ( )
inlinenodiscardnoexcept

尝试读取一个字节

返回
成功返回该字节,数据不足返回 none

在文件 byte_cursor.hpp71 行定义.

引用了 neforce::none.

被这些函数引用 try_read_bits().

◆ try_read_bytes()

optional< cbyte_view > neforce::http::byte_cursor::try_read_bytes ( size_t count)
inlinenodiscardnoexcept

尝试读取指定长度的字节块

参数
count要读取的字节数
返回
成功返回字节视图,数据不足返回 none

在文件 byte_cursor.hpp185 行定义.

引用了 neforce::count() , 以及 neforce::none.

◆ try_read_le16()

optional< uint16_t > neforce::http::byte_cursor::try_read_le16 ( )
inlinenodiscardnoexcept

尝试读取小端序 16 位无符号整数

返回
成功返回该值,数据不足返回 none

在文件 byte_cursor.hpp145 行定义.

引用了 neforce::none , 以及 neforce::endian::read_le16().

◆ try_read_le32()

optional< uint32_t > neforce::http::byte_cursor::try_read_le32 ( )
inlinenodiscardnoexcept

尝试读取小端序 32 位无符号整数

返回
成功返回该值,数据不足返回 none

在文件 byte_cursor.hpp158 行定义.

引用了 neforce::none , 以及 neforce::endian::read_le32().

◆ try_read_le64()

optional< uint64_t > neforce::http::byte_cursor::try_read_le64 ( )
inlinenodiscardnoexcept

尝试读取小端序 64 位无符号整数

返回
成功返回该值,数据不足返回 none

在文件 byte_cursor.hpp171 行定义.

引用了 neforce::none , 以及 neforce::endian::read_le64().


该类的文档由以下文件生成: