C++ Rest SDK
The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
|
Stream buffer base class. More...
#include <astreambuf.h>
Public Member Functions | |
virtual | ~basic_streambuf () |
Virtual constructor for stream buffers. More... | |
virtual bool | can_read () const =0 |
can_read is used to determine whether a stream buffer will support read operations (get). More... | |
virtual bool | can_write () const =0 |
can_write is used to determine whether a stream buffer will support write operations (put). More... | |
virtual bool | can_seek () const =0 |
can_seek More... | |
virtual bool | has_size () const =0 |
has_size More... | |
virtual bool | is_eof () const =0 |
is_eof is used to determine whether a read head has reached the end of the buffer. More... | |
virtual size_t | buffer_size (std::ios_base::openmode direction=std::ios_base::in) const =0 |
Gets the stream buffer size, if one has been set. More... | |
virtual void | set_buffer_size (size_t size, std::ios_base::openmode direction=std::ios_base::in)=0 |
Sets the stream buffer implementation to buffer or not buffer. More... | |
virtual size_t | in_avail () const =0 |
For any input stream, in_avail returns the number of characters that are immediately available to be consumed without blocking. May be used in conjunction with <cref="::sbumpc method"/> to read data without incurring the overhead of using tasks. More... | |
virtual bool | is_open () const =0 |
Checks if the stream buffer is open. More... | |
virtual pplx::task< void > | close (std::ios_base::openmode mode=(std::ios_base::in|std::ios_base::out))=0 |
Closes the stream buffer, preventing further read or write operations. More... | |
virtual pplx::task< void > | close (std::ios_base::openmode mode, std::exception_ptr eptr)=0 |
Closes the stream buffer with an exception. More... | |
virtual pplx::task< int_type > | putc (_CharType ch)=0 |
Writes a single character to the stream. More... | |
virtual pplx::task< size_t > | putn (const _CharType *ptr, size_t count)=0 |
Writes a number of characters to the stream. More... | |
virtual pplx::task< size_t > | putn_nocopy (const _CharType *ptr, size_t count)=0 |
Writes a number of characters to the stream. Note: callers must make sure the data to be written is valid until the returned task completes. More... | |
virtual pplx::task< int_type > | bumpc ()=0 |
Reads a single character from the stream and advances the read position. More... | |
virtual int_type | sbumpc ()=0 |
Reads a single character from the stream and advances the read position. More... | |
virtual pplx::task< int_type > | getc ()=0 |
Reads a single character from the stream without advancing the read position. More... | |
virtual int_type | sgetc ()=0 |
Reads a single character from the stream without advancing the read position. More... | |
virtual pplx::task< int_type > | nextc ()=0 |
Advances the read position, then returns the next character without advancing again. More... | |
virtual pplx::task< int_type > | ungetc ()=0 |
Retreats the read position, then returns the current character without advancing. More... | |
virtual pplx::task< size_t > | getn (_Out_writes_(count) _CharType *ptr, _In_ size_t count)=0 |
Reads up to a given number of characters from the stream. More... | |
virtual size_t | scopy (_Out_writes_(count) _CharType *ptr, _In_ size_t count)=0 |
Copies up to a given number of characters from the stream, synchronously. More... | |
virtual pos_type | getpos (std::ios_base::openmode direction) const =0 |
Gets the current read or write position in the stream. More... | |
virtual utility::size64_t | size () const =0 |
Gets the size of the stream, if known. Calls to has_size will determine whether the result of size can be relied on. More... | |
virtual pos_type | seekpos (pos_type pos, std::ios_base::openmode direction)=0 |
Seeks to the given position. More... | |
virtual pos_type | seekoff (off_type offset, std::ios_base::seekdir way, std::ios_base::openmode mode)=0 |
Seeks to a position given by a relative offset. More... | |
virtual pplx::task< void > | sync ()=0 |
For output streams, flush any internally buffered data to the underlying medium. More... | |
virtual _CharType * | alloc (_In_ size_t count)=0 |
Allocates a contiguous memory block and returns it. More... | |
virtual void | commit (_In_ size_t count)=0 |
Submits a block already allocated by the stream buffer. More... | |
virtual bool | acquire (_Out_ _CharType *&ptr, _Out_ size_t &count)=0 |
Gets a pointer to the next already allocated contiguous block of data. More... | |
virtual void | release (_Out_writes_(count) _CharType *ptr, _In_ size_t count)=0 |
Releases a block of data acquired using ::acquire method. This frees the stream buffer to de-allocate the memory, if it so desires. Move the read position ahead by the count. More... | |
virtual std::exception_ptr | exception () const =0 |
Retrieves the stream buffer exception_ptr if it has been set. More... | |
Stream buffer base class.
|
inlinevirtual |
Virtual constructor for stream buffers.
|
pure virtual |
Gets a pointer to the next already allocated contiguous block of data.
ptr | A reference to a pointer variable that will hold the address of the block on success. |
count | The number of contiguous characters available at the address in 'ptr.' |
true
if the operation succeeded, false
otherwise.A return of false does not necessarily indicate that a subsequent read operation would fail, only that there is no block to return immediately or that the stream buffer does not support the operation. The stream buffer may not de-allocate the block until ::release method is called. If the end of the stream is reached, the function will return true
, a null pointer, and a count of zero; a subsequent read will not succeed.
Implemented in Concurrency::streams::streambuf< _CharType >, Concurrency::streams::streambuf< _CollectionType::value_type >, Concurrency::streams::details::basic_file_buffer< _CharType >, Concurrency::streams::details::basic_rawptr_buffer< _CharType >, Concurrency::streams::details::basic_producer_consumer_buffer< _CharType >, and Concurrency::streams::details::basic_container_buffer< _CollectionType >.
|
pure virtual |
Allocates a contiguous memory block and returns it.
count | The number of characters to allocate. |
|
pure virtual |
Gets the stream buffer size, if one has been set.
direction | The direction of buffering (in or out) |
An implementation that does not support buffering will always return 0.
Implemented in Concurrency::streams::streambuf< _CharType >, Concurrency::streams::streambuf< _CollectionType::value_type >, Concurrency::streams::details::streambuf_state_manager< _CharType >, Concurrency::streams::details::streambuf_state_manager< _CollectionType::value_type >, Concurrency::streams::details::basic_file_buffer< _CharType >, Concurrency::streams::details::basic_rawptr_buffer< _CharType >, Concurrency::streams::details::basic_container_buffer< _CollectionType >, and Concurrency::streams::details::basic_producer_consumer_buffer< _CharType >.
|
pure virtual |
Reads a single character from the stream and advances the read position.
task
that holds the value of the character. This value is EOF if the read fails.Implemented in Concurrency::streams::streambuf< _CharType >, Concurrency::streams::streambuf< _CollectionType::value_type >, Concurrency::streams::details::streambuf_state_manager< _CharType >, and Concurrency::streams::details::streambuf_state_manager< _CollectionType::value_type >.
|
pure virtual |
can_read
is used to determine whether a stream buffer will support read operations (get).
Implemented in Concurrency::streams::streambuf< _CharType >, Concurrency::streams::streambuf< _CollectionType::value_type >, Concurrency::streams::details::streambuf_state_manager< _CharType >, and Concurrency::streams::details::streambuf_state_manager< _CollectionType::value_type >.
|
pure virtual |
can_seek
is used to determine whether a stream buffer supports seeking.
Implemented in Concurrency::streams::streambuf< _CharType >, Concurrency::streams::streambuf< _CollectionType::value_type >, Concurrency::streams::details::streambuf_state_manager< _CharType >, Concurrency::streams::details::streambuf_state_manager< _CollectionType::value_type >, Concurrency::streams::details::basic_file_buffer< _CharType >, Concurrency::streams::details::basic_producer_consumer_buffer< _CharType >, Concurrency::streams::details::basic_rawptr_buffer< _CharType >, and Concurrency::streams::details::basic_container_buffer< _CollectionType >.
|
pure virtual |
can_write
is used to determine whether a stream buffer will support write operations (put).
Implemented in Concurrency::streams::streambuf< _CharType >, Concurrency::streams::streambuf< _CollectionType::value_type >, Concurrency::streams::details::streambuf_state_manager< _CharType >, and Concurrency::streams::details::streambuf_state_manager< _CollectionType::value_type >.
|
pure virtual |
Closes the stream buffer, preventing further read or write operations.
mode | The I/O mode (in or out) to close for. |
Implemented in Concurrency::streams::streambuf< _CharType >, Concurrency::streams::streambuf< _CollectionType::value_type >, Concurrency::streams::details::streambuf_state_manager< _CharType >, Concurrency::streams::details::streambuf_state_manager< _CollectionType::value_type >, and Concurrency::streams::details::basic_rawptr_buffer< _CharType >.
|
pure virtual |
Closes the stream buffer with an exception.
mode | The I/O mode (in or out) to close for. |
eptr | Pointer to the exception. |
Implemented in Concurrency::streams::streambuf< _CharType >, Concurrency::streams::streambuf< _CollectionType::value_type >, Concurrency::streams::details::streambuf_state_manager< _CharType >, and Concurrency::streams::details::streambuf_state_manager< _CollectionType::value_type >.
|
pure virtual |
Submits a block already allocated by the stream buffer.
count | The number of characters to be committed. |
|
pure virtual |
Retrieves the stream buffer exception_ptr if it has been set.
nullptr
will be returnedImplemented in Concurrency::streams::streambuf< _CharType >, Concurrency::streams::streambuf< _CollectionType::value_type >, Concurrency::streams::details::streambuf_state_manager< _CharType >, and Concurrency::streams::details::streambuf_state_manager< _CollectionType::value_type >.
|
pure virtual |
Reads a single character from the stream without advancing the read position.
task
that holds the value of the byte. This value is EOF if the read fails.Implemented in Concurrency::streams::streambuf< _CharType >, Concurrency::streams::streambuf< _CollectionType::value_type >, Concurrency::streams::details::streambuf_state_manager< _CharType >, and Concurrency::streams::details::streambuf_state_manager< _CollectionType::value_type >.
|
pure virtual |
Reads up to a given number of characters from the stream.
ptr | The address of the target memory area. |
count | The maximum number of characters to read. |
task
that holds the number of characters read. This value is O if the end of the stream is reached.Implemented in Concurrency::streams::streambuf< _CharType >, Concurrency::streams::streambuf< _CollectionType::value_type >, Concurrency::streams::details::streambuf_state_manager< _CharType >, and Concurrency::streams::details::streambuf_state_manager< _CollectionType::value_type >.
|
pure virtual |
Gets the current read or write position in the stream.
direction | The I/O direction to seek (see remarks) |
Some streams may have separate write and read cursors. For such streams, the direction parameter defines whether to move the read or the write cursor.
Implemented in Concurrency::streams::streambuf< _CharType >, Concurrency::streams::streambuf< _CollectionType::value_type >, Concurrency::streams::details::streambuf_state_manager< _CharType >, Concurrency::streams::details::streambuf_state_manager< _CollectionType::value_type >, Concurrency::streams::details::basic_file_buffer< _CharType >, Concurrency::streams::details::basic_rawptr_buffer< _CharType >, Concurrency::streams::details::basic_container_buffer< _CollectionType >, and Concurrency::streams::details::basic_producer_consumer_buffer< _CharType >.
|
pure virtual |
has_size
is used to determine whether a stream buffer supports size().
Implemented in Concurrency::streams::streambuf< _CharType >, Concurrency::streams::streambuf< _CollectionType::value_type >, Concurrency::streams::details::streambuf_state_manager< _CharType >, Concurrency::streams::details::streambuf_state_manager< _CollectionType::value_type >, Concurrency::streams::details::basic_file_buffer< _CharType >, Concurrency::streams::details::basic_producer_consumer_buffer< _CharType >, Concurrency::streams::details::basic_rawptr_buffer< _CharType >, and Concurrency::streams::details::basic_container_buffer< _CollectionType >.
|
pure virtual |
For any input stream, in_avail
returns the number of characters that are immediately available to be consumed without blocking. May be used in conjunction with <cref="::sbumpc method"/> to read data without incurring the overhead of using tasks.
Implemented in Concurrency::streams::streambuf< _CharType >, Concurrency::streams::streambuf< _CollectionType::value_type >, Concurrency::streams::details::streambuf_state_manager< _CharType >, Concurrency::streams::details::streambuf_state_manager< _CollectionType::value_type >, Concurrency::streams::details::basic_file_buffer< _CharType >, Concurrency::streams::details::basic_rawptr_buffer< _CharType >, Concurrency::streams::details::basic_container_buffer< _CollectionType >, and Concurrency::streams::details::basic_producer_consumer_buffer< _CharType >.
|
pure virtual |
is_eof
is used to determine whether a read head has reached the end of the buffer.
Implemented in Concurrency::streams::streambuf< _CharType >, Concurrency::streams::streambuf< _CollectionType::value_type >, Concurrency::streams::details::streambuf_state_manager< _CharType >, and Concurrency::streams::details::streambuf_state_manager< _CollectionType::value_type >.
|
pure virtual |
Checks if the stream buffer is open.
No separation is made between open for reading and open for writing.
Implemented in Concurrency::streams::streambuf< _CharType >, Concurrency::streams::streambuf< _CollectionType::value_type >, Concurrency::streams::details::streambuf_state_manager< _CharType >, and Concurrency::streams::details::streambuf_state_manager< _CollectionType::value_type >.
|
pure virtual |
Advances the read position, then returns the next character without advancing again.
task
that holds the value of the character. This value is EOF if the read fails.Implemented in Concurrency::streams::streambuf< _CharType >, Concurrency::streams::streambuf< _CollectionType::value_type >, Concurrency::streams::details::streambuf_state_manager< _CharType >, and Concurrency::streams::details::streambuf_state_manager< _CollectionType::value_type >.
|
pure virtual |
Writes a single character to the stream.
ch | The character to write |
task
that holds the value of the character. This value is EOF if the write operation fails.Implemented in Concurrency::streams::streambuf< _CharType >, Concurrency::streams::streambuf< _CollectionType::value_type >, Concurrency::streams::details::streambuf_state_manager< _CharType >, and Concurrency::streams::details::streambuf_state_manager< _CollectionType::value_type >.
|
pure virtual |
Writes a number of characters to the stream.
ptr | A pointer to the block of data to be written. |
count | The number of characters to write. |
task
that holds the number of characters actually written, either 'count' or 0.Implemented in Concurrency::streams::streambuf< _CharType >, Concurrency::streams::streambuf< _CollectionType::value_type >, Concurrency::streams::details::streambuf_state_manager< _CharType >, and Concurrency::streams::details::streambuf_state_manager< _CollectionType::value_type >.
|
pure virtual |
Writes a number of characters to the stream. Note: callers must make sure the data to be written is valid until the returned task completes.
ptr | A pointer to the block of data to be written. |
count | The number of characters to write. |
task
that holds the number of characters actually written, either 'count' or 0.Implemented in Concurrency::streams::streambuf< _CharType >, Concurrency::streams::streambuf< _CollectionType::value_type >, Concurrency::streams::details::streambuf_state_manager< _CharType >, and Concurrency::streams::details::streambuf_state_manager< _CollectionType::value_type >.
|
pure virtual |
Releases a block of data acquired using ::acquire method. This frees the stream buffer to de-allocate the memory, if it so desires. Move the read position ahead by the count.
ptr | A pointer to the block of data to be released. |
count | The number of characters that were read. |
Implemented in Concurrency::streams::streambuf< _CharType >, Concurrency::streams::streambuf< _CollectionType::value_type >, Concurrency::streams::details::streambuf_state_manager< _CharType >, Concurrency::streams::details::streambuf_state_manager< _CollectionType::value_type >, and Concurrency::streams::details::basic_file_buffer< _CharType >.
|
pure virtual |
Reads a single character from the stream and advances the read position.
-1
if the read fails. -2
if an asynchronous read is requiredThis is a synchronous operation, but is guaranteed to never block.
Implemented in Concurrency::streams::streambuf< _CharType >, Concurrency::streams::streambuf< _CollectionType::value_type >, Concurrency::streams::details::streambuf_state_manager< _CharType >, and Concurrency::streams::details::streambuf_state_manager< _CollectionType::value_type >.
|
pure virtual |
Copies up to a given number of characters from the stream, synchronously.
ptr | The address of the target memory area. |
count | The maximum number of characters to read. |
This is a synchronous operation, but is guaranteed to never block.
Implemented in Concurrency::streams::streambuf< _CharType >, Concurrency::streams::streambuf< _CollectionType::value_type >, Concurrency::streams::details::streambuf_state_manager< _CharType >, and Concurrency::streams::details::streambuf_state_manager< _CollectionType::value_type >.
|
pure virtual |
Seeks to a position given by a relative offset.
offset | The relative position to seek to |
way | The starting point (beginning, end, current) for the seek. |
mode | The I/O direction to seek (see remarks) |
Some streams may have separate write and read cursors. For such streams, the mode parameter defines whether to move the read or the write cursor.
Implemented in Concurrency::streams::details::streambuf_state_manager< _CharType >, Concurrency::streams::details::streambuf_state_manager< _CollectionType::value_type >, Concurrency::streams::details::basic_file_buffer< _CharType >, Concurrency::streams::details::basic_rawptr_buffer< _CharType >, Concurrency::streams::details::basic_container_buffer< _CollectionType >, and Concurrency::streams::details::basic_producer_consumer_buffer< _CharType >.
|
pure virtual |
Seeks to the given position.
pos | The offset from the beginning of the stream. |
direction | The I/O direction to seek (see remarks). |
Some streams may have separate write and read cursors. For such streams, the direction parameter defines whether to move the read or the write cursor.
Implemented in Concurrency::streams::details::streambuf_state_manager< _CharType >, Concurrency::streams::details::streambuf_state_manager< _CollectionType::value_type >, Concurrency::streams::details::basic_file_buffer< _CharType >, Concurrency::streams::details::basic_rawptr_buffer< _CharType >, Concurrency::streams::details::basic_container_buffer< _CollectionType >, and Concurrency::streams::details::basic_producer_consumer_buffer< _CharType >.
|
pure virtual |
Sets the stream buffer implementation to buffer or not buffer.
size | The size to use for internal buffering, 0 if no buffering should be done. |
direction | The direction of buffering (in or out) |
An implementation that does not support buffering will silently ignore calls to this function and it will not have any effect on what is returned by subsequent calls to ::buffer_size method.
Implemented in Concurrency::streams::streambuf< _CharType >, Concurrency::streams::streambuf< _CollectionType::value_type >, Concurrency::streams::details::streambuf_state_manager< _CharType >, Concurrency::streams::details::streambuf_state_manager< _CollectionType::value_type >, Concurrency::streams::details::basic_file_buffer< _CharType >, Concurrency::streams::details::basic_rawptr_buffer< _CharType >, Concurrency::streams::details::basic_container_buffer< _CollectionType >, and Concurrency::streams::details::basic_producer_consumer_buffer< _CharType >.
|
pure virtual |
Reads a single character from the stream without advancing the read position.
This is a synchronous operation, but is guaranteed to never block.
Implemented in Concurrency::streams::streambuf< _CharType >, Concurrency::streams::streambuf< _CollectionType::value_type >, Concurrency::streams::details::streambuf_state_manager< _CharType >, and Concurrency::streams::details::streambuf_state_manager< _CollectionType::value_type >.
|
pure virtual |
Gets the size of the stream, if known. Calls to has_size
will determine whether the result of size
can be relied on.
Implemented in Concurrency::streams::streambuf< _CharType >, Concurrency::streams::streambuf< _CollectionType::value_type >, Concurrency::streams::details::streambuf_state_manager< _CharType >, Concurrency::streams::details::streambuf_state_manager< _CollectionType::value_type >, Concurrency::streams::details::basic_file_buffer< _CharType >, Concurrency::streams::details::basic_rawptr_buffer< _CharType >, and Concurrency::streams::details::basic_container_buffer< _CollectionType >.
|
pure virtual |
For output streams, flush any internally buffered data to the underlying medium.
task
that returns true
if the sync succeeds, false
if not.Implemented in Concurrency::streams::streambuf< _CharType >, Concurrency::streams::streambuf< _CollectionType::value_type >, Concurrency::streams::details::streambuf_state_manager< _CharType >, and Concurrency::streams::details::streambuf_state_manager< _CollectionType::value_type >.
|
pure virtual |
Retreats the read position, then returns the current character without advancing.
task
that holds the value of the character. This value is EOF if the read fails, requires_async
if an asynchronous read is requiredImplemented in Concurrency::streams::streambuf< _CharType >, Concurrency::streams::streambuf< _CollectionType::value_type >, Concurrency::streams::details::streambuf_state_manager< _CharType >, and Concurrency::streams::details::streambuf_state_manager< _CollectionType::value_type >.