tuningfork::ByteStream

#include <protobuf_nano_util.h>

vec 為單位檢視位元組。

摘要

如果需要更多位元組,Write 會呼叫 realloc,由呼叫端決定要釋出哪些分配到的資料。

設定 vec=nullptrsize=0 是有效的,在此情況下系統將使用 mallocvec 進行分配。

公開屬性

it
size_t
解碼或編碼時,串流中的目前位置。
size
size_t
vec 指向的位元組大小。
vec
uint8_t *
由串流所代表的位元組指標。

公開的靜態函式

Read(pb_istream_t *stream, uint8_t *buf, size_t count)
bool
讀取串流中的 count 個位元組到指定的緩衝區。
Write(pb_ostream_t *stream, const uint8_t *buf, size_t count)
bool
將指定緩衝區中的 count 個位元組寫入串流。

公開屬性

it

size_t tuningfork::ByteStream::it

解碼或編碼時,串流中的目前位置。

大小

size_t tuningfork::ByteStream::size

vec 指向的位元組大小。

vec

uint8_t * tuningfork::ByteStream::vec

由串流所代表的位元組指標。

公開的靜態函式

讀取

bool tuningfork::ByteStream::Read(
  pb_istream_t *stream,
  uint8_t *buf,
  size_t count
)

讀取串流中的 count 個位元組到指定的緩衝區。

詳細說明
參數
stream
要讀取的串流。
buf
要寫入的緩衝區。
count
要讀取的位元組數。
傳回
True 表示成功,False 表示讀取錯誤。

寫入

bool tuningfork::ByteStream::Write(
  pb_ostream_t *stream,
  const uint8_t *buf,
  size_t count
)

將指定緩衝區中的 count 個位元組寫入串流。

詳細說明
參數
stream
要寫入的串流。
buf
要從中讀取的緩衝區。
count
要寫入的位元組數。
傳回
True 表示成功,False 表示寫入錯誤。