33 #include "pplx/pplxtasks.h"
34 #include "cpprest/details/basic_types.h"
35 #include "cpprest/asyncrt_utils.h"
49 template<
typename _CharType>
57 static typename std::char_traits<_CharType>::int_type
requires_async() {
return std::char_traits<_CharType>::eof()-1; }
61 struct char_traits<unsigned char> :
private std::char_traits<char>
64 typedef unsigned char char_type;
66 using std::char_traits<char>::eof;
67 using std::char_traits<char>::int_type;
68 using std::char_traits<char>::off_type;
69 using std::char_traits<char>::pos_type;
71 static size_t length(
const unsigned char* str)
73 return std::char_traits<char>::length(reinterpret_cast<const char*>(str));
76 static void assign(
unsigned char& left,
const unsigned char& right) { left = right; }
77 static unsigned char* assign(
unsigned char* left,
size_t n,
unsigned char value)
79 return reinterpret_cast<unsigned char*
>(std::char_traits<char>::assign(reinterpret_cast<char*>(left), n, static_cast<char>(value)));
82 static unsigned char* copy(
unsigned char* left,
const unsigned char* right,
size_t n)
84 return reinterpret_cast<unsigned char*
>(std::char_traits<char>::copy(reinterpret_cast<char*>(left), reinterpret_cast<const char*>(right), n));
87 static unsigned char* move(
unsigned char* left,
const unsigned char* right,
size_t n)
89 return reinterpret_cast<unsigned char*
>(std::char_traits<char>::move(reinterpret_cast<char*>(left), reinterpret_cast<const char*>(right), n));
101 template<
typename _CharType>
105 typedef _CharType char_type;
106 typedef ::concurrency::streams::char_traits<_CharType> traits;
108 typedef typename traits::int_type int_type;
109 typedef typename traits::pos_type pos_type;
110 typedef typename traits::off_type off_type;
141 virtual bool is_eof()
const = 0;
149 virtual size_t buffer_size(std::ios_base::openmode direction = std::ios_base::in)
const = 0;
157 virtual void set_buffer_size(
size_t size, std::ios_base::openmode direction = std::ios_base::in) = 0;
164 virtual size_t in_avail()
const = 0;
170 virtual bool is_open()
const = 0;
176 virtual pplx::task<void> close(std::ios_base::openmode mode = (std::ios_base::in | std::ios_base::out)) = 0;
220 virtual int_type
sbumpc() = 0;
233 virtual int_type
sgetc() = 0;
262 virtual size_t scopy(_Out_writes_(count) _CharType *ptr, _In_
size_t count) = 0;
271 virtual pos_type
getpos(std::ios_base::openmode direction)
const = 0;
277 virtual utility::size64_t
size()
const = 0;
286 virtual pos_type
seekpos(pos_type pos, std::ios_base::openmode direction) = 0;
297 virtual pos_type
seekoff(off_type offset, std::ios_base::seekdir way, std::ios_base::openmode mode) = 0;
322 virtual _CharType*
alloc(_In_
size_t count) = 0;
328 virtual void commit(_In_
size_t count) = 0;
343 virtual bool acquire(_Out_ _CharType*& ptr, _Out_
size_t& count) = 0;
351 virtual void release(_Out_writes_(count) _CharType *ptr, _In_
size_t count) = 0;
357 virtual std::exception_ptr
exception()
const = 0;
361 template<
typename _CharType>
365 typedef typename details::basic_streambuf<_CharType>::traits traits;
366 typedef typename details::basic_streambuf<_CharType>::int_type int_type;
367 typedef typename details::basic_streambuf<_CharType>::pos_type pos_type;
368 typedef typename details::basic_streambuf<_CharType>::off_type off_type;
375 return m_stream_can_read;
383 return m_stream_can_write;
403 if (mode & std::ios_base::in &&
can_read()) {
411 if (mode & std::ios_base::out &&
can_write()) {
415 closeOp = closeOp.then([this_ptr] {
return this_ptr->_close_write().then([this_ptr]{}); });
428 if (m_currentException ==
nullptr)
429 m_currentException = eptr;
438 return m_stream_read_eof;
449 return create_exception_checked_value_task<int_type>(traits::eof());
451 return create_exception_checked_task<int_type>(_putc(ch), [](int_type) {
462 CASABLANCA_DEPRECATED(
"This API in some cases performs a copy. It is deprecated and will be removed in a future release. Use putn_nocopy instead.")
463 virtual
pplx::task<
size_t>
putn(const _CharType *ptr,
size_t count)
466 return create_exception_checked_value_task<size_t>(0);
468 return pplx::task_from_result<size_t>(0);
470 return create_exception_checked_task<size_t>(_putn(ptr, count,
true), [](size_t) {
485 return create_exception_checked_value_task<size_t>(0);
487 return pplx::task_from_result<size_t>(0);
489 return create_exception_checked_task<size_t>(_putn(ptr, count), [](size_t) {
503 return create_exception_checked_task<int_type>(_bumpc(), [](int_type val) {
515 if ( !(m_currentException ==
nullptr) )
516 std::rethrow_exception(m_currentException);
518 return traits::eof();
519 return check_sync_read_eof(_sbumpc());
529 return create_exception_checked_value_task<int_type>(traits::eof());
531 return create_exception_checked_task<int_type>(_getc(), [](int_type val) {
543 if ( !(m_currentException ==
nullptr) )
544 std::rethrow_exception(m_currentException);
546 return traits::eof();
547 return check_sync_read_eof(_sgetc());
557 return create_exception_checked_value_task<int_type>(traits::eof());
559 return create_exception_checked_task<int_type>(_nextc(), [](int_type val) {
571 return create_exception_checked_value_task<int_type>(traits::eof());
573 return create_exception_checked_task<int_type>(_ungetc(), [](int_type) {
587 return create_exception_checked_value_task<size_t>(0);
589 return pplx::task_from_result<size_t>(0);
591 return create_exception_checked_task<size_t>(_getn(ptr, count), [](
size_t val) {
603 virtual size_t scopy(_Out_writes_(count) _CharType *ptr, _In_
size_t count)
605 if ( !(m_currentException ==
nullptr) )
606 std::rethrow_exception(m_currentException);
610 return _scopy(ptr, count);
621 if (m_currentException ==
nullptr)
622 return pplx::task_from_result();
624 return pplx::task_from_exception<void>(m_currentException);
626 return create_exception_checked_task<bool>(_sync(), [](bool) {
637 return m_currentException;
649 throw std::logic_error(
"The buffer is already allocated, this maybe caused by overlap of stream read or write");
651 _CharType* alloc_result = _alloc(count);
667 throw std::logic_error(
"The buffer needs to allocate first");
676 virtual utility::size64_t
size()
const {
return 0; }
677 virtual size_t buffer_size(std::ios_base::openmode direction = std::ios_base::in)
const = 0;
678 virtual void set_buffer_size(
size_t size, std::ios_base::openmode direction = std::ios_base::in) = 0;
679 virtual size_t in_avail()
const = 0;
680 virtual pos_type
getpos(std::ios_base::openmode direction)
const = 0;
681 virtual pos_type
seekpos(pos_type pos, std::ios_base::openmode direction) = 0;
682 virtual pos_type
seekoff(off_type offset, std::ios_base::seekdir way, std::ios_base::openmode mode) = 0;
683 virtual bool acquire(_Out_writes_(count) _CharType*& ptr, _In_
size_t& count) = 0;
684 virtual void release(_Out_writes_(count) _CharType *ptr, _In_
size_t count) = 0;
692 return _putn(ptr, count);
697 virtual int_type _sbumpc() = 0;
699 virtual int_type _sgetc() = 0;
702 virtual pplx::task<size_t> _getn(_Out_writes_(count) _CharType *ptr, _In_
size_t count) = 0;
703 virtual size_t _scopy(_Out_writes_(count) _CharType *ptr, _In_
size_t count) = 0;
705 virtual _CharType* _alloc(
size_t count) = 0;
706 virtual void _commit(
size_t count) = 0;
713 m_stream_can_read =
false;
714 return pplx::task_from_result();
722 m_stream_can_write =
false;
723 return pplx::task_from_result();
729 m_stream_can_read = (mode & std::ios_base::in) != 0;
730 m_stream_can_write = (mode & std::ios_base::out) != 0;
731 m_stream_read_eof =
false;
735 std::exception_ptr m_currentException;
737 bool m_stream_can_read, m_stream_can_write, m_stream_read_eof, m_alloced;
741 template<
typename _CharType1>
745 return pplx::task_from_result<_CharType1>(
static_cast<_CharType1
>(val));
747 return pplx::task_from_exception<_CharType1>(this->
exception());
751 template<
typename _CharType1>
754 auto thisPointer = this->shared_from_this();
758 thisPointer->m_stream_read_eof = eof_test(t1.get());
760 thisPointer->close(mode, std::current_exception()).
get();
761 return pplx::task_from_exception<_CharType1>(thisPointer->exception(),
pplx::task_options());
763 if (thisPointer->m_stream_read_eof && !(thisPointer->exception() ==
nullptr))
764 return pplx::task_from_exception<_CharType1>(thisPointer->exception(),
pplx::task_options());
771 return func1(result);
775 return result.then(func1);
780 int_type check_sync_read_eof(int_type ch)
782 m_stream_read_eof = ch == traits::eof();
803 template<
typename _CharType>
807 typedef typename details::basic_streambuf<_CharType>::traits traits;
808 typedef typename details::basic_streambuf<_CharType>::int_type int_type;
809 typedef typename details::basic_streambuf<_CharType>::pos_type pos_type;
810 typedef typename details::basic_streambuf<_CharType>::off_type off_type;
811 typedef typename details::basic_streambuf<_CharType>::char_type char_type;
813 template <
typename _CharType2>
friend class streambuf;
833 template <
typename AlterCharType>
835 m_buffer(std::static_pointer_cast<details::basic_streambuf<_CharType>>(std::static_pointer_cast<void>(other.m_buffer)))
837 static_assert(std::is_same<pos_type,
typename details::basic_streambuf<AlterCharType>::pos_type>::value
838 && std::is_same<off_type,
typename details::basic_streambuf<AlterCharType>::off_type>::value
839 && std::is_integral<_CharType>::value && std::is_integral<AlterCharType>::value
840 && std::is_integral<int_type>::value && std::is_integral<
typename details::basic_streambuf<AlterCharType>::int_type>::value
841 &&
sizeof(_CharType) ==
sizeof(AlterCharType)
842 &&
sizeof(int_type) ==
sizeof(
typename details::basic_streambuf<AlterCharType>::int_type),
843 "incompatible stream character types");
852 if (!
can_read())
throw std::runtime_error(
"stream buffer not set up for input of data");
853 return concurrency::streams::basic_istream<_CharType>(*this);
862 if (!
can_write())
throw std::runtime_error(
"stream buffer not set up for output of data");
863 return concurrency::streams::basic_ostream<_CharType>(*this);
869 operator bool()
const {
return (
bool)m_buffer; }
876 const std::shared_ptr<details::basic_streambuf<_CharType>> & get_base()
const
880 throw std::invalid_argument(
"Invalid streambuf object");
889 virtual bool can_read()
const {
return get_base()->can_read(); }
894 virtual bool can_write()
const {
return get_base()->can_write(); }
900 virtual bool can_seek()
const {
return get_base()->can_seek(); }
906 virtual bool has_size()
const {
return get_base()->has_size(); }
913 virtual utility::size64_t
size()
const {
return get_base()->size(); }
921 virtual size_t buffer_size(std::ios_base::openmode direction = std::ios_base::in)
const {
return get_base()->buffer_size(direction); }
929 virtual void set_buffer_size(
size_t size, std::ios_base::openmode direction = std::ios_base::in) { get_base()->set_buffer_size(size,direction); }
937 virtual size_t in_avail()
const {
return get_base()->in_avail(); }
944 virtual bool is_open()
const {
return get_base()->is_open(); }
950 virtual bool is_eof()
const {
return get_base()->is_eof(); }
959 auto buffer = get_base();
960 return buffer ? buffer->close(mode) : pplx::task_from_result();
971 auto buffer = get_base();
972 return buffer ? buffer->close(mode, eptr) : pplx::task_from_result();
982 return get_base()->putc(ch);
990 virtual _CharType*
alloc(
size_t count)
992 return get_base()->alloc(count);
1001 get_base()->commit(count);
1017 virtual bool acquire(_Out_ _CharType*& ptr, _Out_
size_t& count)
1021 return get_base()->acquire(ptr, count);
1030 virtual void release(_Out_writes_(count) _CharType *ptr, _In_
size_t count)
1032 get_base()->release(ptr, count);
1041 CASABLANCA_DEPRECATED(
"This API in some cases performs a copy. It is deprecated and will be removed in a future release. Use putn_nocopy instead.")
1042 virtual
pplx::task<
size_t>
putn(const _CharType *ptr,
size_t count)
1044 return get_base()->putn(ptr, count);
1056 return get_base()->putn_nocopy(ptr, count);
1065 return get_base()->bumpc();
1073 virtual typename details::basic_streambuf<_CharType>::int_type
sbumpc()
1075 return get_base()->sbumpc();
1084 return get_base()->getc();
1092 virtual typename details::basic_streambuf<_CharType>::int_type
sgetc()
1094 return get_base()->sgetc();
1103 return get_base()->nextc();
1112 return get_base()->ungetc();
1123 return get_base()->getn(ptr, count);
1133 virtual size_t scopy(_Out_writes_(count) _CharType *ptr, _In_
size_t count)
1135 return get_base()->scopy(ptr, count);
1145 virtual typename details::basic_streambuf<_CharType>::pos_type
getpos(std::ios_base::openmode direction)
const
1147 return get_base()->getpos(direction);
1157 virtual typename details::basic_streambuf<_CharType>::pos_type
seekpos(
typename details::basic_streambuf<_CharType>::pos_type pos, std::ios_base::openmode direction)
1159 return get_base()->seekpos(pos, direction);
1171 virtual typename 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)
1173 return get_base()->seekoff(offset, way, mode);
1182 return get_base()->sync();
1191 return get_base()->exception();
1195 std::shared_ptr<details::basic_streambuf<_CharType>> m_buffer;
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.
Definition: astreambuf.h:603
streambuf(const streambuf< AlterCharType > &other)
Converter Constructor.
Definition: astreambuf.h:834
virtual bool can_seek() const =0
can_seek is used to determine whether a stream buffer supports seeking.
virtual bool can_seek() const
can_seek is used to determine whether a stream buffer supports seeking.
Definition: astreambuf.h:900
Stream buffer base class.
Definition: astreambuf.h:102
concurrency::streams::basic_ostream< _CharType > create_ostream() const
Constructs an output stream for this stream buffer.
Definition: astreambuf.h:860
virtual pplx::task< int_type > bumpc()
Reads a single character from the stream and advances the read position.
Definition: astreambuf.h:498
virtual ~streambuf()
Destructor
Definition: astreambuf.h:874
virtual pplx::task< int_type > getc()=0
Reads a single character from the stream without advancing the read position.
virtual pplx::task< int_type > getc()
Reads a single character from the stream without advancing the read position.
Definition: astreambuf.h:526
virtual int_type sbumpc()
Reads a single character from the stream and advances the read position.
Definition: astreambuf.h:513
virtual pplx::task< size_t > putn(const _CharType *ptr, size_t count)
Writes a number of characters to the stream.
Definition: astreambuf.h:463
virtual pos_type seekpos(pos_type pos, std::ios_base::openmode direction)=0
Seeks to the given position.
virtual pplx::task< int_type > ungetc()=0
Retreats the read position, then returns the current character without advancing. ...
virtual pplx::task< int_type > nextc()=0
Advances the read position, then returns the next character without advancing again.
virtual bool acquire(_Out_ _CharType *&ptr, _Out_ size_t &count)=0
Gets a pointer to the next already allocated contiguous block of data.
virtual int_type sgetc()=0
Reads a single character from the stream without advancing the read position.
virtual bool is_open() const
Checks if the stream buffer is open.
Definition: astreambuf.h:944
The pplx namespace provides classes and functions that give you access to the Concurrency Runtime...
Definition: pplx.h:81
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.
Definition: astreambuf.h:956
virtual bool is_open() const
Checks if the stream buffer is open.
Definition: astreambuf.h:390
virtual details::basic_streambuf< _CharType >::int_type sbumpc()
Reads a single character from the stream and advances the read position.
Definition: astreambuf.h:1073
virtual pplx::task< int_type > putc(_CharType ch)
Writes a single character to the stream.
Definition: astreambuf.h:446
Reference-counted stream buffer.
Definition: astreambuf.h:804
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...
Definition: astreambuf.h:1030
virtual bool has_size() const =0
has_size is used to determine whether a stream buffer supports size().
virtual std::exception_ptr exception() const
Retrieves the stream buffer exception_ptr if it has been set.
Definition: astreambuf.h:1189
virtual bool is_eof() const
is_eof is used to determine whether a read head has reached the end of the buffer.
Definition: astreambuf.h:950
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 v...
Definition: astreambuf.h:482
virtual int_type sbumpc()=0
Reads a single character from the stream and advances the read position.
virtual bool can_seek() const =0
can_seek is used to determine whether a stream buffer supports seeking.
virtual bool can_write() const =0
can_write is used to determine whether a stream buffer will support write operations (put)...
Base interface for all asynchronous output streams.
Definition: astreambuf.h:792
virtual pos_type getpos(std::ios_base::openmode direction) const =0
Gets the current read or write position in the stream.
void commit(size_t count)
Submits a block already allocated by the stream buffer.
Definition: astreambuf.h:664
virtual bool is_open() const =0
Checks if the stream buffer is open.
virtual utility::size64_t size() const
Gets the size of the stream, if known. Calls to has_size will determine whether the result of size ca...
Definition: astreambuf.h:676
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.
static std::char_traits< _CharType >::int_type requires_async()
Some synchronous functions will return this value if the operation requires an asynchronous call in a...
Definition: astreambuf.h:57
virtual pplx::task< void > close(std::ios_base::openmode mode, std::exception_ptr eptr)
Closes the stream buffer with an exception.
Definition: astreambuf.h:968
virtual pplx::task< int_type > getc()
Reads a single character from the stream without advancing the read position.
Definition: astreambuf.h:1082
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.
Definition: astreambuf.h:1157
virtual bool can_read() const
can_read is used to determine whether a stream buffer will support read operations (get)...
Definition: astreambuf.h:373
virtual details::basic_streambuf< _CharType >::int_type sgetc()
Reads a single character from the stream without advancing the read position.
Definition: astreambuf.h:1092
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.
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.
Definition: astreambuf.h:584
bool is_done() const
Determines if the task is completed.
Definition: pplxtasks.h:3558
virtual pplx::task< void > _close_read()
The real read head close operation, implementation should override it if there is any resource to be ...
Definition: astreambuf.h:711
virtual pplx::task< int_type > bumpc()=0
Reads a single character from the stream and advances the read position.
virtual pplx::task< int_type > putc(_CharType ch)=0
Writes a single character to the stream.
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...
virtual std::exception_ptr exception() const
Retrieves the stream buffer exception_ptr if it has been set.
Definition: astreambuf.h:635
virtual void commit(_In_ size_t count)=0
Submits a block already allocated by the stream buffer.
virtual bool is_eof() const =0
is_eof is used to determine whether a read head has reached the end of the buffer.
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.
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.
Definition: astreambuf.h:1121
virtual pplx::task< void > _close_write()
The real write head close operation, implementation should override it if there is any resource to be...
Definition: astreambuf.h:720
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.
Definition: astreambuf.h:921
virtual pplx::task< int_type > bumpc()
Reads a single character from the stream and advances the read position.
Definition: astreambuf.h:1063
virtual bool can_write() const
can_write is used to determine whether a stream buffer will support write operations (put)...
Definition: astreambuf.h:381
Definition: astreambuf.h:362
virtual pplx::task< void > sync()=0
For output streams, flush any internally buffered data to the underlying medium.
virtual pplx::task< void > sync()
For output streams, flush any internally buffered data to the underlying medium.
Definition: astreambuf.h:617
virtual bool is_eof() const
is_eof is used to determine whether a read head has reached the end of the buffer.
Definition: astreambuf.h:436
pplx::task< int_type > nextc()
Advances the read position, then returns the next character without advancing again.
Definition: astreambuf.h:1101
The Parallel Patterns Library (PPL) task class. A task object represents work that can be executed as...
Definition: pplxtasks.h:176
virtual pplx::task< void > close(std::ios_base::openmode mode, std::exception_ptr eptr)
Closes the stream buffer with an exception.
Definition: astreambuf.h:426
virtual details::basic_streambuf< _CharType >::pos_type getpos(std::ios_base::openmode direction) const
Gets the current read or write position in the stream.
Definition: astreambuf.h:1145
virtual utility::size64_t size() const
Gets the total number of characters in the stream buffer, if known. Calls to has_size will determine ...
Definition: astreambuf.h:913
Represents the allowed options for creating a task
Definition: pplxtasks.h:1238
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.
Definition: astreambuf.h:399
streambuf()
Default constructor.
Definition: astreambuf.h:824
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 ca...
_ReturnType get() const
Returns the result this task produced. If the task is not in a terminal state, a call to get will wai...
Definition: pplxtasks.h:3534
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...
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.
Base interface for all asynchronous input streams.
Definition: astreambuf.h:791
concurrency::streams::basic_istream< _CharType > create_istream() const
Constructs an input stream head for this stream buffer.
Definition: astreambuf.h:850
The Parallel Patterns Library (PPL) task class. A task object represents work that can be executed as...
Definition: pplxtasks.h:4173
virtual pplx::task< size_t > putn(const _CharType *ptr, size_t count)=0
Writes a number of characters to the stream.
virtual pplx::task< size_t > putn(const _CharType *ptr, size_t count)
Writes a number of characters to the stream.
Definition: astreambuf.h:1042
virtual void commit(size_t count)
Submits a block already allocated by the stream buffer.
Definition: astreambuf.h:999
virtual size_t in_avail() const
For any input stream, in_avail returns the number of characters that are immediately available to be ...
Definition: astreambuf.h:937
virtual pplx::task< int_type > ungetc()
Retreats the read position, then returns the current character without advancing. ...
Definition: astreambuf.h:568
_CharType * alloc(size_t count)
Allocates a contiguous memory block and returns it.
Definition: astreambuf.h:646
virtual pplx::task< int_type > putc(_CharType ch)
Writes a single character to the stream.
Definition: astreambuf.h:980
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.
Definition: astreambuf.h:1171
Definition: astreambuf.h:37
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.
virtual ~basic_streambuf()
Virtual constructor for stream buffers.
Definition: astreambuf.h:116
virtual bool can_read() const =0
can_read is used to determine whether a stream buffer will support read operations (get)...
virtual size_t in_avail() const =0
For any input stream, in_avail returns the number of characters that are immediately available to be ...
virtual pplx::task< int_type > nextc()
Advances the read position, then returns the next character without advancing again.
Definition: astreambuf.h:554
virtual pos_type seekpos(pos_type pos, std::ios_base::openmode direction)=0
Seeks to the given position.
pplx::task< int_type > ungetc()
Retreats the read position, then returns the current character without advancing. ...
Definition: astreambuf.h:1110
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.
Definition: astreambuf.h:929
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.
Definition: astreambuf.h:1133
virtual pos_type getpos(std::ios_base::openmode direction) const =0
Gets the current read or write position in the stream.
virtual pplx::task< void > sync()
For output streams, flush any internally buffered data to the underlying medium.
Definition: astreambuf.h:1180
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.
virtual bool has_size() const
has_size is used to determine whether a stream buffer supports size().
Definition: astreambuf.h:906
virtual size_t in_avail() const =0
For any input stream, in_avail returns the number of characters that are immediately available to be ...
virtual _CharType * alloc(size_t count)
Allocates a contiguous memory block and returns it.
Definition: astreambuf.h:990
virtual bool has_size() const =0
has_size is used to determine whether a stream buffer supports size().
virtual int_type sgetc()
Reads a single character from the stream without advancing the read position.
Definition: astreambuf.h:541
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 v...
Definition: astreambuf.h:1054
virtual bool acquire(_Out_ _CharType *&ptr, _Out_ size_t &count)
Gets a pointer to the next already allocated contiguous block of data.
Definition: astreambuf.h:1017
virtual _CharType * alloc(_In_ size_t count)=0
Allocates a contiguous memory block and returns it.
streambuf(_In_ const std::shared_ptr< details::basic_streambuf< _CharType >> &ptr)
Constructor.
Definition: astreambuf.h:819
Extending the standard char_traits type with one that adds values and types that are unique to "C++ R...
Definition: astreambuf.h:50
virtual std::exception_ptr exception() const =0
Retrieves the stream buffer exception_ptr if it has been set.
virtual bool can_read() const
can_read is used to determine whether a stream buffer will support read operations (get)...
Definition: astreambuf.h:889
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.
virtual bool can_write() const
can_write is used to determine whether a stream buffer will support write operations (put)...
Definition: astreambuf.h:894
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.
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.
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 v...
bool is_done() const
Determines if the task is completed.
Definition: pplxtasks.h:4454