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.
Classes | Public Types | Public Member Functions | List of all members
Concurrency::streams::basic_istream< CharType > Class Template Reference

Base interface for all asynchronous input streams. More...

#include <streams.h>

Inheritance diagram for Concurrency::streams::basic_istream< CharType >:
Concurrency::streams::stdio_istream< CharType >

Public Types

typedef char_traits< CharType > traits
 
typedef char_traits< CharType >::int_type int_type
 
typedef traits::pos_type pos_type
 
typedef traits::off_type off_type
 

Public Member Functions

 basic_istream ()
 Default constructor More...
 
 basic_istream (streams::streambuf< CharType > buffer)
 Constructor More...
 
 basic_istream (const basic_istream &other)
 Copy constructor More...
 
basic_istreamoperator= (const basic_istream &other)
 Assignment operator More...
 
pplx::task< void > close () const
 Close the stream, preventing further read operations. More...
 
pplx::task< void > close (std::exception_ptr eptr) const
 Close the stream with exception, preventing further read operations. More...
 
bool is_eof () const
 Tests whether last read cause the stream reach EOF. More...
 
pplx::task< int_type > read () const
 Get the next character and return it as an int_type. Advance the read position. More...
 
template<typename T >
pplx::task< T > read () const
 Read a single value of "blittable" type T from the stream. More...
 
pplx::task< size_t > read (streams::streambuf< CharType > target, size_t count) const
 Reads up to count characters and place into the provided buffer. More...
 
pplx::task< int_type > peek () const
 Get the next character and return it as an int_type. Do not advance the read position. More...
 
pplx::task< size_t > read_to_delim (streams::streambuf< CharType > target, int_type delim) const
 Read characters until a delimiter or EOF is found, and place them into the target. Proceed past the delimiter, but don't include it in the target buffer. More...
 
pplx::task< size_t > read_line (streams::streambuf< CharType > target) const
 Read until reaching a newline character. The newline is not included in the target. More...
 
pplx::task< size_t > read_to_end (streams::streambuf< CharType > target) const
 Read until reaching the end of the stream. More...
 
pos_type seek (pos_type pos) const
 Seeks to the specified write position. More...
 
pos_type seek (off_type off, std::ios_base::seekdir way) const
 Seeks to the specified write position. More...
 
pos_type tell () const
 Get the current write position, i.e. the offset from the beginning of the stream. More...
 
bool can_seek () const
 can_seek is used to determine whether the stream supports seeking. More...
 
bool is_valid () const
 Test whether the stream has been initialized with a valid stream buffer. More...
 
 operator bool () const
 Test whether the stream has been initialized or not. More...
 
bool is_open () const
 Test whether the stream is open for writing. More...
 
concurrency::streams::streambuf< CharType > streambuf () const
 Get the underlying stream buffer. More...
 
template<typename T >
pplx::task< T > extract () const
 Read a value of type T from the stream. More...
 

Detailed Description

template<typename CharType>
class Concurrency::streams::basic_istream< CharType >

Base interface for all asynchronous input streams.

Constructor & Destructor Documentation

template<typename CharType>
Concurrency::streams::basic_istream< CharType >::basic_istream ( )
inline

Default constructor

template<typename CharType>
Concurrency::streams::basic_istream< CharType >::basic_istream ( streams::streambuf< CharType >  buffer)
inline

Constructor

Template Parameters
CharTypeThe data type of the basic element of the stream.
Parameters
bufferA stream buffer.
template<typename CharType>
Concurrency::streams::basic_istream< CharType >::basic_istream ( const basic_istream< CharType > &  other)
inline

Copy constructor

Parameters
otherThe source object

Member Function Documentation

template<typename CharType>
bool Concurrency::streams::basic_istream< CharType >::can_seek ( ) const
inline

can_seek is used to determine whether the stream supports seeking.

Returns
true if the stream supports seeking, false otherwise.
template<typename CharType>
pplx::task<void> Concurrency::streams::basic_istream< CharType >::close ( ) const
inline

Close the stream, preventing further read operations.

template<typename CharType>
pplx::task<void> Concurrency::streams::basic_istream< CharType >::close ( std::exception_ptr  eptr) const
inline

Close the stream with exception, preventing further read operations.

Parameters
eptrPointer to the exception.
template<typename CharType>
template<typename T >
pplx::task<T> Concurrency::streams::basic_istream< CharType >::extract ( ) const
inline

Read a value of type T from the stream.

Supports the C++ primitive types. Can be expanded to additional types by adding template specializations for type_parser.

Template Parameters
TThe data type of the element to be read from the stream.
Returns
A task that holds the element read from the stream.
template<typename CharType>
bool Concurrency::streams::basic_istream< CharType >::is_eof ( ) const
inline

Tests whether last read cause the stream reach EOF.

Returns
True if the read head has reached the end of the stream, false otherwise.
template<typename CharType>
bool Concurrency::streams::basic_istream< CharType >::is_open ( ) const
inline

Test whether the stream is open for writing.

Returns
true if the stream is open for writing, false otherwise.
template<typename CharType>
bool Concurrency::streams::basic_istream< CharType >::is_valid ( ) const
inline

Test whether the stream has been initialized with a valid stream buffer.

template<typename CharType>
Concurrency::streams::basic_istream< CharType >::operator bool ( ) const
inline

Test whether the stream has been initialized or not.

template<typename CharType>
basic_istream& Concurrency::streams::basic_istream< CharType >::operator= ( const basic_istream< CharType > &  other)
inline

Assignment operator

Parameters
otherThe source object
Returns
A reference to the stream object that contains the result of the assignment.
template<typename CharType>
pplx::task<int_type> Concurrency::streams::basic_istream< CharType >::peek ( ) const
inline

Get the next character and return it as an int_type. Do not advance the read position.

Returns
A task that holds the character, widened to an integer. This character is EOF when the peek operation fails.
template<typename CharType>
pplx::task<int_type> Concurrency::streams::basic_istream< CharType >::read ( ) const
inline

Get the next character and return it as an int_type. Advance the read position.

Returns
A task that holds the next character as an int_type on successful completion.
template<typename CharType>
template<typename T >
pplx::task<T> Concurrency::streams::basic_istream< CharType >::read ( ) const
inline

Read a single value of "blittable" type T from the stream.

Returns
A value of type T.

This is not a replacement for a proper binary serialization solution, but it may form the foundation for one. Reading data bit-wise to a stream is a primitive operation of binary serialization. Currently, no attention is paid to byte order. All data is read in the platform's native byte order, which means little-endian on all platforms that have been tested. This function is only available for streams using a single-byte character size.

template<typename CharType>
pplx::task<size_t> Concurrency::streams::basic_istream< CharType >::read ( streams::streambuf< CharType >  target,
size_t  count 
) const
inline

Reads up to count characters and place into the provided buffer.

Parameters
targetAn async stream buffer supporting write operations.
countThe maximum number of characters to read
Returns
A task that holds the number of characters read. This number is 0 if the end of the stream is reached.
template<typename CharType>
pplx::task<size_t> Concurrency::streams::basic_istream< CharType >::read_line ( streams::streambuf< CharType >  target) const
inline

Read until reaching a newline character. The newline is not included in the target.

Parameters
targetAn asynchronous stream buffer supporting write operations.
Returns
A task that holds the number of characters read. This number is 0 if the end of the stream is reached.
template<typename CharType>
pplx::task<size_t> Concurrency::streams::basic_istream< CharType >::read_to_delim ( streams::streambuf< CharType >  target,
int_type  delim 
) const
inline

Read characters until a delimiter or EOF is found, and place them into the target. Proceed past the delimiter, but don't include it in the target buffer.

Parameters
targetAn async stream buffer supporting write operations.
delimThe delimiting character to stop the read at.
Returns
A task that holds the number of characters read.
template<typename CharType>
pplx::task<size_t> Concurrency::streams::basic_istream< CharType >::read_to_end ( streams::streambuf< CharType >  target) const
inline

Read until reaching the end of the stream.

Parameters
targetAn asynchronous stream buffer supporting write operations.
Returns
The number of characters read.
template<typename CharType>
pos_type Concurrency::streams::basic_istream< CharType >::seek ( pos_type  pos) const
inline

Seeks to the specified write position.

Parameters
posAn offset relative to the beginning of the stream.
Returns
The new position in the stream.
template<typename CharType>
pos_type Concurrency::streams::basic_istream< CharType >::seek ( off_type  off,
std::ios_base::seekdir  way 
) const
inline

Seeks to the specified write position.

Parameters
offAn offset relative to the beginning, current write position, or the end of the stream.
wayThe starting point (beginning, current, end) for the seek.
Returns
The new position in the stream.
template<typename CharType>
concurrency::streams::streambuf<CharType> Concurrency::streams::basic_istream< CharType >::streambuf ( ) const
inline

Get the underlying stream buffer.

template<typename CharType>
pos_type Concurrency::streams::basic_istream< CharType >::tell ( ) const
inline

Get the current write position, i.e. the offset from the beginning of the stream.

Returns
The current write position.

The documentation for this class was generated from the following files: