23 #ifndef __ccxx_Stream_hxx 24 #define __ccxx_Stream_hxx 86 bool writable =
true);
137 size_t n = _readElem(reinterpret_cast<byte_t *>(buffer.
getPointer()),
155 virtual size_t read(
byte_t* buffer,
size_t buflen);
168 size_t read(
byte_t* buffer,
size_t buflen, int64_t offset,
195 size_t write(
const byte_t* buffer,
size_t buflen, int64_t offset,
223 virtual size_t readFully(
ByteBuffer& buffer,
size_t count = 0);
237 virtual size_t readFully(
CharBuffer& buffer,
size_t count = 0);
264 size_t n = _readElemFully(reinterpret_cast<byte_t *>(buffer.
getPointer()),
283 virtual size_t readFully(
byte_t* buffer,
size_t buflen);
339 size_t n = _writeElem(
340 reinterpret_cast<const byte_t *>(buffer.
getPointer()),
358 virtual size_t write(
const byte_t* buffer,
size_t buflen);
368 virtual size_t writeFully(
ByteBuffer& buffer);
378 virtual size_t writeFully(
CharBuffer& buffer);
404 size_t n = _writeElemFully(
405 reinterpret_cast<const byte_t *>(buffer.
getPointer()),
422 virtual size_t writeFully(
const byte_t* buffer,
size_t buflen);
454 virtual int64_t tell();
458 {
return(_canRead || _canWrite); }
462 {
return(_seekable); }
466 {
return(_canRead); }
470 {
return(_canWrite); }
477 {
return(_canRead && _canWrite); }
484 {
return(! _canRead || ! _canWrite); }
502 {
return(_timeout); }
514 void _init(
FileHandle handle,
bool seekable,
bool readable,
bool writable);
526 size_t _readAsync(
byte_t* buffer,
size_t buflen, int64_t offset,
528 size_t _writeAsync(
const byte_t* buffer,
size_t buflen, int64_t offset,
531 size_t _readElem(
byte_t* buffer,
size_t size,
size_t nelem,
size_t& partial);
532 size_t _readElemFully(
byte_t* buffer,
size_t size,
size_t nelem,
535 size_t _writeElem(
const byte_t* buffer,
size_t size,
size_t nelem,
537 size_t _writeElemFully(
const byte_t* buffer,
size_t size,
size_t nelem,
545 #endif // __ccxx_Stream_hxx Write-only mode.
Definition: Stream.h++:40
Seek from the current stream position.
Definition: Stream.h++:50
IOMode
Stream I/O modes.
Definition: Stream.h++:36
An encapsulation of a block of memory.
Definition: MemoryBlock.h++:37
T * getPointer()
Get a pointer to the element at the current position.
Definition: Buffer.h++:170
Seek from the beginning of the stream.
Definition: Stream.h++:48
An unbuffered I/O stream.
Definition: Stream.h++:60
bool isWritable() const
Test if the stream can be written to.
Definition: Stream.h++:469
static const uint_t MAX_IOBLOCK_COUNT
The maximum number of I/O buffers that can be passed to the vector I/O methods.
Definition: Stream.h++:70
bool isFullDuplex() const
Test if the stream is full-duplex (i.e., supports both reading and writing).
Definition: Stream.h++:476
size_t write(Buffer< T > &buffer, size_t &partial)
Write data to the stream from a Buffer of arbitrary type.
Definition: Stream.h++:337
unsigned int uint_t
An alias for unsigned int.
Definition: Integers.h++:74
int FileHandle
Definition: Common.h++:225
SeekMode
Stream seek modes.
Definition: Stream.h++:46
Read/write mode.
Definition: Stream.h++:42
Read-only mode.
Definition: Stream.h++:38
Seek backward from the end of the stream.
Definition: Stream.h++:52
uint_t getRemaining() const
Get the number of elements available to be read or written.
Definition: Buffer.h++:186
bool isReadable() const
Test if the stream can be read from.
Definition: Stream.h++:465
size_t writeFully(Buffer< T > &buffer, size_t &partial)
Write data to the stream from a Buffer of arbitrary type, until either the entire buffer is written o...
Definition: Stream.h++:402
bool isSeekable() const
Test if the stream supports seeking.
Definition: Stream.h++:461
uint_t bump(uint_t delta)
Bump (advance) the position by the given number of elements, or to the limit, whichever occurs first...
size_t readFully(Buffer< T > &buffer, size_t &partial)
Read data from the stream into a Buffer of arbitrary type, until either the buffer is full or an erro...
Definition: Stream.h++:262
#define COMMONCPP_API
Definition: Common.h++:126
A buffer for storing a contiguous sequence of elements.
Definition: Buffer.h++:44
A system process.
Definition: Process.h++:158
#define CCXX_COPY_DECLS(CLASS)
Inlines declarations of a copy constructor and assignment operator for the class CLASS.
Definition: Common.h++:295
int timespan_ms_t
A timespan expressed in milliseconds.
Definition: Integers.h++:104
bool isHalfDuplex() const
Test if the stream is half-duplex (i.e., supports either reading or writing, but not both)...
Definition: Stream.h++:483
size_t read(Buffer< T > &buffer, size_t &partial)
Read data from the stream into a Buffer of arbitrary type.
Definition: Stream.h++:135
Definition: AllocationMap.c++:25
timespan_ms_t getTimeout() const
Get the stream I/O timeout, in milliseconds.
Definition: Stream.h++:501
bool isOpen() const
Test if the stream is open.
Definition: Stream.h++:457
An object representing an asynchronous I/O operation.
Definition: AsyncIOTask.h++:43
unsigned char byte_t
An unsigned 8-bit value.
Definition: Integers.h++:68