#include <url.h>
This helper class template can be used for function parameters where the function needs to get a stream, but for convenience also passing a Url as argument to the parameter shall be allowed. In other words, a function
can be invoked by passing either a Url or an InputStreamRef to the parameter. It even allows to pass Result<Url> or Result<InputStreamRef>, then the error, if any, will be stored within UrlOrStream and returned by the call to GetStream.
In the implementation of a function with a UrlOrStream parameter, GetStream has to be called to obtain the stream, and finally Close to close the stream (but this will only be done if the stream was obtained from a Url):
Public Member Functions | |
UrlOrStream ()=default | |
MAXON_IMPLICIT | UrlOrStream (const Url &url, OPENSTREAMFLAGS flags=OPENSTREAMFLAGS::NONE) |
MAXON_IMPLICIT | UrlOrStream (const STREAM &stream) |
MAXON_IMPLICIT | UrlOrStream (const Result< Url > &url, OPENSTREAMFLAGS flags=OPENSTREAMFLAGS::NONE) |
MAXON_IMPLICIT | UrlOrStream (const Result< STREAM > &stream) |
Result< STREAM & > | GetStream () |
const Url & | GetUrl () const |
Result< void > | Close () |
Private Attributes | |
Url | _url |
ObjectRef | _stream |
Result< void > | _error |
OPENSTREAMFLAGS | _flags |
|
default |
MAXON_IMPLICIT UrlOrStream | ( | const Url & | url, |
OPENSTREAMFLAGS | flags = OPENSTREAMFLAGS::NONE |
||
) |
MAXON_IMPLICIT UrlOrStream | ( | const STREAM & | stream | ) |
MAXON_IMPLICIT UrlOrStream | ( | const Result< Url > & | url, |
OPENSTREAMFLAGS | flags = OPENSTREAMFLAGS::NONE |
||
) |
MAXON_IMPLICIT UrlOrStream | ( | const Result< STREAM > & | stream | ) |
Result<STREAM&> GetStream | ( | ) |
Returns the stream to use. If this UrlOrStream was constructed with a Url and a stream hasn't yet been opened, a new stream is opened.
const Url& GetUrl | ( | ) | const |
Result<void> Close | ( | ) |
Close the underlying stream if is has been opened by this UrlOrStream. You have to call this function at the end of the code which has obtained the stream by GetStream(). The stream is closed only if this UrlOrStream was constructed by a Url, but not if is was constructed by a stream.
|
private |
|
private |
|
private |
|
private |