boost::buffers::any_source

A type erased source.

Synopsis

class any_source;

Description

An object of this type represents shared ownership of a type‐erased read source or data source. It provides a uniform interface for reading the source data regardless of how the source is implemented. Accessing the bytes is achieved by calling read which reads data into a caller‐provided buffer. Alternatively, when has_buffers returns true the source consists of buffers in memory, and they can be accessed directly by calling get_buffers.

Example sources include: ‐ in‐memory buffers ‐ streaming file data ‐ generated data

any_source is copyable, and the copies share ownership of the underlying source. Changes to the state of one copy, such as reading or rewinding, will be visible in all copies.

Type‐erased sources can always be rewound to the beginning by calling rewind. Therefore, a source can be read multiple times.

Thread Safety

Unsafe.

Member Functions

Name

Description

any_source [constructor]

Constructors

operator=

Assignment

data

Return the buffers representing the source, if available.

has_buffers

Return true if the source consists of buffers in memory. When the source consists of buffers in memory, they can also be accessed directly using get_buffers.

has_size

Return true if the size of the source is known.

read

Read from the source into a caller‐provided buffer.

rewind

Rewind the source to the beginning. This allows the source to be accessed from the start when calling .

size

Return the size of the source, if available.

Created with MrDocs