#include <iostreams.h>
Interface is the base interface for all stream interfaces. It contains the general functions to work with streams (e.g. error handling).
公共成员函数 |
|
MAXON_METHOD Result < Int64 > | GetStreamLength () const |
MAXON_METHOD Result < Int64 > | GetPosition () const |
MAXON_METHOD Result < void > | 关闭 () |
MAXON_ADD_TO_REFERENCE_CLASS ( Result < void > ResetMaybeClose() { Result < void > res= OK ;if(this->GetPointer()) { if( System::GetReferenceCounter (this->GetPointer())==1) res=this-> 关闭 ();this->ResetReference();} return res;}) | |
MAXON_METHOD Bool | SeekSupported () const |
MAXON_METHOD Result < void > | Seek ( Int64 position) |
MAXON_METHOD void | DisableBuffering () |
私有成员函数 |
|
MAXON_INTERFACE ( BaseStreamInterface , MAXON_REFERENCE_NORMAL , "net.maxon.interface.basestream") |
|
private |
MAXON_METHOD Result < Int64 > GetStreamLength | ( | ) | const |
Returns the length of the stream/file. Be aware that some streams cannot return the file size (e.g. http streams with gzip+chunked transfer encoding). With this example code you can handle both cases correctly. In most cases it's better to not use GetStreamLength() and better use ReadEOS() to read as much as available.
iferr ( Int size = stream.GetStreamLength()) { if (!err.IsInstanceOf<UnknownFileSizeError>()) return err; ... handle unknown size case ... } else { ... handle known size case ... }MAXON_METHOD Result < Int64 > GetPosition | ( | ) | const |
Returns the current stream position. This is the position where the next bytes will be read to or written from.
MAXON_METHOD Result <void> Close | ( | ) |
Closes the stream.
MAXON_ADD_TO_REFERENCE_CLASS | ( | Result < void > ResetMaybeClose() { Result < void > res= OK ;if(this->GetPointer()) { if( System::GetReferenceCounter (this->GetPointer())==1) res=this-> 关闭 ();this->ResetReference();} return res;} | ) |
MAXON_METHOD Bool SeekSupported | ( | ) | const |
Returns if the stream supports Seek() . Please note that seeking in stream may effect performance because the caches will be flushed.
MAXON_METHOD Result <void> Seek | ( | Int64 | position | ) |
Sets the read/write position to this absolute position from the beginning of the stream. For InputStreamInterface : If you want to Seek() forward Skip() is the preferred method to call from the performance perspective.
[in] | position | Position to jump to within the stream. |
MAXON_METHOD void DisableBuffering | ( | ) |
The stream may disable buffering when this routine is called (if it supports it). This method is typically used when the buffering is done from the outside.