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.
|
Reference-counted stream buffer. More...
#include <astreambuf.h>
Public Types | |
typedef details::basic_streambuf< _CharType >::traits | traits |
typedef details::basic_streambuf< _CharType >::int_type | int_type |
typedef details::basic_streambuf< _CharType >::pos_type | pos_type |
typedef details::basic_streambuf< _CharType >::off_type | off_type |
typedef details::basic_streambuf< _CharType >::char_type | char_type |
Public Types inherited from Concurrency::streams::details::basic_streambuf< _CharType > | |
typedef _CharType | char_type |
typedef ::concurrency::streams::char_traits< _CharType > | traits |
typedef traits::int_type | int_type |
typedef traits::pos_type | pos_type |
typedef traits::off_type | off_type |
Public Member Functions | |
streambuf (_In_ const std::shared_ptr< details::basic_streambuf< _CharType >> &ptr) | |
Constructor. More... | |
streambuf () | |
Default constructor. More... | |
template<typename AlterCharType > | |
streambuf (const streambuf< AlterCharType > &other) | |
Converter Constructor. More... | |
concurrency::streams::basic_istream< _CharType > | create_istream () const |
Constructs an input stream head for this stream buffer. More... | |
concurrency::streams::basic_ostream< _CharType > | create_ostream () const |
Constructs an output stream for this stream buffer. More... | |
operator bool () const | |
Checks if the stream buffer has been initialized or not. More... | |
virtual | ~streambuf () |
Destructor More... | |
const std::shared_ptr< details::basic_streambuf< _CharType > > & | get_base () const |
virtual bool | can_read () const |
can_read is used to determine whether a stream buffer will support read operations (get). More... | |
virtual bool | can_write () const |
can_write is used to determine whether a stream buffer will support write operations (put). More... | |
virtual bool | can_seek () const |
can_seek is used to determine whether a stream buffer supports seeking. More... | |
virtual bool | has_size () const |
has_size is used to determine whether a stream buffer supports size(). More... | |
virtual utility::size64_t | size () const |
Gets the total number of characters in the stream buffer, if known. Calls to has_size will determine whether the result of size can be relied on. More... | |
virtual size_t | buffer_size (std::ios_base::openmode direction=std::ios_base::in) const |
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) |
Sets the stream buffer implementation to buffer or not buffer. More... | |
virtual size_t | in_avail () const |
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 |
Checks if the stream buffer is open. More... | |
virtual bool | is_eof () const |
is_eof is used to determine whether a read head has reached the end of the buffer. More... | |
virtual pplx::task< void > | close (std::ios_base::openmode mode=(std::ios_base::in|std::ios_base::out)) |
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) |
Closes the stream buffer with an exception. More... | |
virtual pplx::task< int_type > | putc (_CharType ch) |
Writes a single character to the stream. More... | |
virtual _CharType * | alloc (size_t count) |
Allocates a contiguous memory block and returns it. More... | |
virtual void | commit (size_t count) |
Submits a block already allocated by the stream buffer. More... | |
virtual bool | acquire (_Out_ _CharType *&ptr, _Out_ size_t &count) |
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) |
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 pplx::task< size_t > | putn (const _CharType *ptr, size_t count) |
Writes a number of characters to the stream. More... | |
virtual pplx::task< size_t > | putn_nocopy (const _CharType *ptr, size_t count) |
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 () |
Reads a single character from the stream and advances the read position. More... | |
virtual details::basic_streambuf< _CharType >::int_type | sbumpc () |
Reads a single character from the stream and advances the read position. More... | |
virtual pplx::task< int_type > | getc () |
Reads a single character from the stream without advancing the read position. More... | |
virtual details::basic_streambuf< _CharType >::int_type | sgetc () |
Reads a single character from the stream without advancing the read position. More... | |
pplx::task< int_type > | nextc () |
Advances the read position, then returns the next character without advancing again. More... | |
pplx::task< int_type > | ungetc () |
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) |
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) |
Copies up to a given number of characters from the stream, synchronously. More... | |
virtual details::basic_streambuf< _CharType >::pos_type | getpos (std::ios_base::openmode direction) const |
Gets the current read or write position in the stream. More... | |
virtual details::basic_streambuf< _CharType >::pos_type | seekpos (typename details::basic_streambuf< _CharType >::pos_type pos, std::ios_base::openmode direction) |
Seeks to the given position. More... | |
virtual details::basic_streambuf< _CharType >::pos_type | seekoff (typename details::basic_streambuf< _CharType >::off_type offset, std::ios_base::seekdir way, std::ios_base::openmode mode) |
Seeks to a position given by a relative offset. More... | |
virtual pplx::task< void > | sync () |
For output streams, flush any internally buffered data to the underlying medium. More... | |
virtual std::exception_ptr | exception () const |
Retrieves the stream buffer exception_ptr if it has been set. More... | |
Public Member Functions inherited from Concurrency::streams::details::basic_streambuf< _CharType > | |
virtual | ~basic_streambuf () |
Virtual constructor for stream buffers. 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 _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... | |
Friends | |
template<typename _CharType2 > | |
class | streambuf |
Reference-counted stream buffer.
_CharType | The data type of the basic element of the streambuf. |
_CharType2 | The data type of the basic element of the streambuf. |
|
inline |
Constructor.
ptr | A pointer to the concrete stream buffer implementation. |
|
inline |
Default constructor.
|
inline |
Converter Constructor.
AlterCharType | The data type of the basic element of the source streambuf . |
other | The source buffer to be converted. |
|
inlinevirtual |
Destructor
|
inlinevirtual |
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.
Implements Concurrency::streams::details::basic_streambuf< _CharType >.
|
inlinevirtual |
Allocates a contiguous memory block and returns it.
count | The number of characters to allocate. |
|
inlinevirtual |
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.
Implements Concurrency::streams::details::basic_streambuf< _CharType >.
|
inlinevirtual |
Reads a single character from the stream and advances the read position.
Implements Concurrency::streams::details::basic_streambuf< _CharType >.
|
inlinevirtual |
can_read
is used to determine whether a stream buffer will support read operations (get).
Implements Concurrency::streams::details::basic_streambuf< _CharType >.
|
inlinevirtual |
can_seek
is used to determine whether a stream buffer supports seeking.
Implements Concurrency::streams::details::basic_streambuf< _CharType >.
|
inlinevirtual |
can_write
is used to determine whether a stream buffer will support write operations (put).
Implements Concurrency::streams::details::basic_streambuf< _CharType >.
|
inlinevirtual |
Closes the stream buffer, preventing further read or write operations.
mode | The I/O mode (in or out) to close for. |
Implements Concurrency::streams::details::basic_streambuf< _CharType >.
|
inlinevirtual |
Closes the stream buffer with an exception.
mode | The I/O mode (in or out) to close for. |
eptr | Pointer to the exception. |
Implements Concurrency::streams::details::basic_streambuf< _CharType >.
|
inlinevirtual |
Submits a block already allocated by the stream buffer.
count | The number of characters to be committed. |
|
inline |
Constructs an input stream head for this stream buffer.
basic_istream
.
|
inline |
Constructs an output stream for this stream buffer.
|
inlinevirtual |
Retrieves the stream buffer exception_ptr if it has been set.
nullptr
will be returnedImplements Concurrency::streams::details::basic_streambuf< _CharType >.
|
inlinevirtual |
Reads a single character from the stream without advancing the read position.
Implements Concurrency::streams::details::basic_streambuf< _CharType >.
|
inlinevirtual |
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. |
Implements Concurrency::streams::details::basic_streambuf< _CharType >.
|
inlinevirtual |
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.
Implements Concurrency::streams::details::basic_streambuf< _CharType >.
|
inlinevirtual |
has_size
is used to determine whether a stream buffer supports size().
size
API is supported, false otherwise.Implements Concurrency::streams::details::basic_streambuf< _CharType >.
|
inlinevirtual |
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.
Implements Concurrency::streams::details::basic_streambuf< _CharType >.
|
inlinevirtual |
is_eof
is used to determine whether a read head has reached the end of the buffer.
Implements Concurrency::streams::details::basic_streambuf< _CharType >.
|
inlinevirtual |
Checks if the stream buffer is open.
No separation is made between open for reading and open for writing.
Implements Concurrency::streams::details::basic_streambuf< _CharType >.
|
inlinevirtual |
Advances the read position, then returns the next character without advancing again.
Implements Concurrency::streams::details::basic_streambuf< _CharType >.
|
inline |
Checks if the stream buffer has been initialized or not.
|
inlinevirtual |
Writes a single character to the stream.
ch | The character to write |
Implements Concurrency::streams::details::basic_streambuf< _CharType >.
|
inlinevirtual |
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. |
Implements Concurrency::streams::details::basic_streambuf< _CharType >.
|
inlinevirtual |
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. |
Implements Concurrency::streams::details::basic_streambuf< _CharType >.
|
inlinevirtual |
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. |
Implements Concurrency::streams::details::basic_streambuf< _CharType >.
|
inlinevirtual |
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.
Implements Concurrency::streams::details::basic_streambuf< _CharType >.
|
inlinevirtual |
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.
Implements Concurrency::streams::details::basic_streambuf< _CharType >.
|
inlinevirtual |
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.
|
inlinevirtual |
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.
|
inlinevirtual |
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.
Implements Concurrency::streams::details::basic_streambuf< _CharType >.
|
inlinevirtual |
Reads a single character from the stream without advancing the read position.
This is a synchronous operation, but is guaranteed to never block.
Implements Concurrency::streams::details::basic_streambuf< _CharType >.
|
inlinevirtual |
Gets the total number of characters in the stream buffer, if known. Calls to has_size
will determine whether the result of size
can be relied on.
Implements Concurrency::streams::details::basic_streambuf< _CharType >.
|
inlinevirtual |
For output streams, flush any internally buffered data to the underlying medium.
true
if the flush succeeds, false
if notImplements Concurrency::streams::details::basic_streambuf< _CharType >.
|
inlinevirtual |
Retreats the read position, then returns the current character without advancing.
Implements Concurrency::streams::details::basic_streambuf< _CharType >.