# tuningfork::VectorStream

`#include <protobuf_nano_util.h>`

A view on the vector provided in `vec`.

## Summary

No ownership is taken.
Details Parameters `vec` Example usage:

```
std::vector<uint8_t> v;
VectorStream str {&v, 0};
pb_ostream_t stream = {VectorStream::Write, &str, SIZE_MAX, 0};
pb_encode(&stream, ...);
```

| ### Public attributes ||
|---|---|
| `https://developer.android.com/games/sdk/reference/performance-tuner/custom-engine/struct/tuningfork/vector-stream#structtuningfork_1_1_vector_stream_1a15e8cd3ec11280c7e7060563a197d195` | `size_t` The current position in the vector while decoding or encoding. |
| `https://developer.android.com/games/sdk/reference/performance-tuner/custom-engine/struct/tuningfork/vector-stream#structtuningfork_1_1_vector_stream_1a3fc88833828997802f63f25ecfc9596e` | `std::vector< uint8_t > *` A vector of bytes that must be valid while `Read` or `Write` are called. |

| ### Public static functions ||
|---|---|
| `https://developer.android.com/games/sdk/reference/performance-tuner/custom-engine/struct/tuningfork/vector-stream#structtuningfork_1_1_vector_stream_1add5291b48820efba50df20aed1acf095(pb_istream_t *stream, uint8_t *buf, size_t count)` | `bool` Read `count` bytes from the stream to the given buffer. |
| `https://developer.android.com/games/sdk/reference/performance-tuner/custom-engine/struct/tuningfork/vector-stream#structtuningfork_1_1_vector_stream_1a9a25c5eebeb2335dfcb069e247784cf8(pb_ostream_t *stream, const uint8_t *buf, size_t count)` | `bool` Write `count` bytes from the given buffer to the stream. |

## Public attributes

### it

```
size_t tuningfork::VectorStream::it
```
The current position in the vector while decoding or encoding.

### vec

```
std::vector< uint8_t > * tuningfork::VectorStream::vec
```
A vector of bytes that must be valid while `Read` or `Write` are called.

The vector will be resized as needed by `Write`.

## Public static functions

### Read

```
bool tuningfork::VectorStream::Read(
  pb_istream_t *stream,
  uint8_t *buf,
  size_t count
)
```
Read `count` bytes from the stream to the given buffer.

<br />

Details Parameters `stream` The stream to read from. `buf` The buffer to write to. `count` The number of bytes to read. **Returns** true if successful, false on a read error.

### Write

```
bool tuningfork::VectorStream::Write(
  pb_ostream_t *stream,
  const uint8_t *buf,
  size_t count
)
```
Write `count` bytes from the given buffer to the stream.

<br />

Details Parameters `stream` The stream to write to. `buf` The buffer to read from. `count` The number of bytes to write. **Returns** true if successful, false on a write error.