IOLink  IOL_v1.1.0_release
iolink::StreamAccessFactory Class Reference

A factory to create StreamAccess instances from various ressources. More...

#include <iolink/storage/StreamAccessFactory.h>

Public Member Functions

 StreamAccessFactory (const StreamAccessFactory &other)=delete
 
 StreamAccessFactory (StreamAccessFactory &&other)=delete
 
StreamAccessFactoryoperator= (const StreamAccessFactory &other)=delete
 
StreamAccessFactoryoperator= (StreamAccessFactory &&other)=delete
 

Static Public Member Functions

static std::shared_ptr< StreamAccessallocate (size_t size=0)
 Create a stream in local memory. More...
 
static std::shared_ptr< StreamAccesscopyInMemory (std::shared_ptr< StreamAccess > streamAccess)
 Load a stream into local memory. More...
 
static std::shared_ptr< StreamAccessfromStdStream (std::shared_ptr< std::istream > stream)
 Create a stream storage from a standard input stream. More...
 
static std::shared_ptr< StreamAccessfromStdStream (std::shared_ptr< std::ostream > stream)
 Create a stream storage from a standard output stream. More...
 
static std::shared_ptr< StreamAccessfromStdStream (std::shared_ptr< std::iostream > stream)
 Create a stream storage from a standard I/O stream. More...
 
static std::shared_ptr< std::istream > toStdIStream (std::shared_ptr< StreamAccess > streamAccess)
 Create a standard Input stream from a StreamAccess. More...
 
static std::shared_ptr< std::ostream > toStdOStream (std::shared_ptr< StreamAccess > streamAccess)
 Create a standard Output stream from a StreamAccess. More...
 
static std::shared_ptr< std::iostream > toStdStream (std::shared_ptr< StreamAccess > streamAccess)
 Create a standard Input/Output stream from a StreamAccess. More...
 
static std::shared_ptr< StreamAccessopenFileRead (const std::string &filePath)
 Create a stream that can read data from a file. More...
 
static std::shared_ptr< StreamAccessopenFileWrite (const std::string &filePath)
 Create a stream that can write data to a file. More...
 
static std::shared_ptr< StreamAccessopenFile (const std::string &filePath)
 Create a stream that can read and write data from/to a file. More...
 
static std::shared_ptr< StreamAccessopenURIWrite (const Uri &uri)
 Create a stream that can write data to an URI. More...
 
static std::shared_ptr< StreamAccessopenHTTPWrite (const Uri &uri, const std::string &method, const HTTPHeaders &headers)
 Create a stream that can post data to an HTTP URI. More...
 
static std::shared_ptr< StreamAccessfromRandomAccess (std::shared_ptr< RandomAccess > randomAccess)
 Create a StreamAccess that will delegate to a RandomAccess. More...
 

Detailed Description

A factory to create StreamAccess instances from various ressources.

Member Function Documentation

◆ allocate()

static std::shared_ptr<StreamAccess> iolink::StreamAccessFactory::allocate ( size_t  size = 0)
static

Create a stream in local memory.

Parameters
sizememory size (in byte) to allocate for the stream.
Returns
a MemoryStreamAccess with all capabilities (read, write and seek)

◆ copyInMemory()

static std::shared_ptr<StreamAccess> iolink::StreamAccessFactory::copyInMemory ( std::shared_ptr< StreamAccess streamAccess)
static

Load a stream into local memory.

Parameters
streamAccessstream with at least read capability to load in memory
Returns
a MemoryStreamAccess with all capabilities (read, write and seek)
Exceptions
Errorif the input streamAccess has no read or seek capability

◆ fromRandomAccess()

static std::shared_ptr<StreamAccess> iolink::StreamAccessFactory::fromRandomAccess ( std::shared_ptr< RandomAccess randomAccess)
static

Create a StreamAccess that will delegate to a RandomAccess.

Parameters
randomAccessRandomAccess from which a StreamAccess is created
Returns
a StreamAccess object which can provide read, write and seek capability (see StreamAccessCapability)
Exceptions
Errorif the input randomAccess has nor read and write capability

◆ fromStdStream() [1/3]

static std::shared_ptr<StreamAccess> iolink::StreamAccessFactory::fromStdStream ( std::shared_ptr< std::iostream >  stream)
static

Create a stream storage from a standard I/O stream.

Parameters
streamStandard I/O stream from which a StreamAccess is bridge is created
Returns
a StreamAccess with read, write and seek capabilities (see StreamAccessCapability)

◆ fromStdStream() [2/3]

static std::shared_ptr<StreamAccess> iolink::StreamAccessFactory::fromStdStream ( std::shared_ptr< std::istream >  stream)
static

Create a stream storage from a standard input stream.

Parameters
streamStandard Input Stream on which a bridge is created
Returns
a StreamAccess object which can eventually provide seek capability (see StreamAccessCapability)

◆ fromStdStream() [3/3]

static std::shared_ptr<StreamAccess> iolink::StreamAccessFactory::fromStdStream ( std::shared_ptr< std::ostream >  stream)
static

Create a stream storage from a standard output stream.

Parameters
streamStandard Output Stream on which a bridge is created
Returns
a StreamAccess object which can eventually provide seek capability (see StreamAccessCapability)

◆ openFile()

static std::shared_ptr<StreamAccess> iolink::StreamAccessFactory::openFile ( const std::string &  filePath)
static

Create a stream that can read and write data from/to a file.

Parameters
filePathpath toward the file which it's tried to access for reading and writing
Returns
a StreamAccess object which can provide read, write and eventually seek capability (see StreamAccessCapability)

◆ openFileRead()

static std::shared_ptr<StreamAccess> iolink::StreamAccessFactory::openFileRead ( const std::string &  filePath)
static

Create a stream that can read data from a file.

Parameters
filePathpath toward the file which it's tried to access for reading
Returns
a StreamAccess object which can eventually provide seek capability (see StreamAccessCapability)

◆ openFileWrite()

static std::shared_ptr<StreamAccess> iolink::StreamAccessFactory::openFileWrite ( const std::string &  filePath)
static

Create a stream that can write data to a file.

Parameters
filePathpath toward the file which it's tried to access for writing
Returns
a StreamAccess object which can eventually provide seek capability (see StreamAccessCapability)

◆ openHTTPWrite()

static std::shared_ptr<StreamAccess> iolink::StreamAccessFactory::openHTTPWrite ( const Uri uri,
const std::string &  method,
const HTTPHeaders headers 
)
static

Create a stream that can post data to an HTTP URI.

HTTP server must support chunked transfer encoding.

Parameters
uriThe HTTP(S) URI to post to.
methodThe HTTP request method.
headersThe HTTP request headers.
Returns
a StreamAccess object which can eventually provide seek capability (see StreamAccessCapability)

◆ openURIWrite()

static std::shared_ptr<StreamAccess> iolink::StreamAccessFactory::openURIWrite ( const Uri uri)
static

Create a stream that can write data to an URI.

If the URI scheme is 'file': calls openFileWrite. If the URI scheme is 'http(s)': calls openHTTPWrite, using the POST method and no headers.

Parameters
uriURI to open for writing
Returns
a StreamAccess object which can eventually provide seek capability (see StreamAccessCapability)

◆ toStdIStream()

static std::shared_ptr<std::istream> iolink::StreamAccessFactory::toStdIStream ( std::shared_ptr< StreamAccess streamAccess)
static

Create a standard Input stream from a StreamAccess.

Parameters
streamAccessstream with read capability from which a bridge is created
Returns
a standard Input Stream

◆ toStdOStream()

static std::shared_ptr<std::ostream> iolink::StreamAccessFactory::toStdOStream ( std::shared_ptr< StreamAccess streamAccess)
static

Create a standard Output stream from a StreamAccess.

Parameters
streamAccessStreamAccess with write capability from which a bridge is created
Returns
a standard Output Stream

◆ toStdStream()

static std::shared_ptr<std::iostream> iolink::StreamAccessFactory::toStdStream ( std::shared_ptr< StreamAccess streamAccess)
static

Create a standard Input/Output stream from a StreamAccess.

Parameters
streamAccessstream with read and write and seek capability from which a bridge is created
Exceptions
InvalidArgumentif read, write, or seek capabilities is missing
Returns
a standard I/O Stream

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