tuningfork::VectorStream

#include <protobuf_nano_util.h>

vec 為單位檢視向量。

摘要

未佔用擁有權。

詳細資料
參數
vec
使用範例:
std::vector v;
VectorStream str {&v, 0};
pb_ostream_t stream = {VectorStream::Write, &str, SIZE_MAX, 0};
pb_encode(&stream, ...);

公開屬性

it
size_t
在解碼或編碼時,向量中目前的位置。
vec
std::vector< uint8_t > *
在呼叫 ReadWrite 時,必須有效的位元組向量。

公開靜態函式

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::VectorStream::it

在解碼或編碼時,向量中目前的位置。

vec

std::vector< uint8_t > * tuningfork::VectorStream::vec

在呼叫 ReadWrite 時,必須有效的位元組向量。

Write 會根據需求調整向量大小。

公開靜態函式

讀取

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

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

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

寫入

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

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

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