| IOLink 1.11.0

Loading...
Searching...
No Matches
StreamAccessFactory.h
1#pragma once
2
3#include <iolink/IOLinkAPI.h>
4#include <iolink/Uri.h>
5#include <iolink/storage/HTTPHeaders.h>
6#include <iolink/storage/RandomAccess.h>
7#include <iolink/storage/StreamAccess.h>
8
9#include <iostream>
10#include <map>
11#include <memory>
12
13 namespace iolink
14{
15
19 class IOLINK_API StreamAccessFactory
20{
21 public:
22 StreamAccessFactory() = delete;
23 StreamAccessFactory(const StreamAccessFactory& other) = delete; // copy constructor
24 StreamAccessFactory(StreamAccessFactory&& other) = delete; // move constructor
25 StreamAccessFactory& operator=(const StreamAccessFactory& other) = delete; // copy assignment
26 StreamAccessFactory& operator=(StreamAccessFactory&& other) = delete; // move assignment
27
33 static std::shared_ptr<StreamAccess> allocate(size_t size = 0);
34
42 static std::shared_ptr<StreamAccess> copyInMemory(std::shared_ptr<StreamAccess> streamAccess);
43
49 static std::shared_ptr<StreamAccess> fromStdStream(std::shared_ptr<std::istream> stream);
50
56 static std::shared_ptr<StreamAccess> fromStdStream(std::shared_ptr<std::ostream> stream);
57
63 static std::shared_ptr<StreamAccess> fromStdStream(std::shared_ptr<std::iostream> stream);
64
71 static std::shared_ptr<std::istream> toStdIStream(std::shared_ptr<StreamAccess> streamAccess);
72
79 static std::shared_ptr<std::ostream> toStdOStream(std::shared_ptr<StreamAccess> streamAccess);
80
88 static std::shared_ptr<std::iostream> toStdStream(std::shared_ptr<StreamAccess> streamAccess);
89
95 static std::shared_ptr<StreamAccess> openFileRead(const std::string& filePath);
96
102 static std::shared_ptr<StreamAccess> openFileWrite(const std::string& filePath);
103
110 static std::shared_ptr<StreamAccess> openFile(const std::string& filePath);
111
120 static std::shared_ptr<StreamAccess> openURIWrite(const Uri& uri);
121
131 static std::shared_ptr<StreamAccess> openHTTPWrite(const Uri& uri,
132 const std::string& method,
133 const HTTPHeaders& headers);
134
142 static std::shared_ptr<StreamAccess> fromRandomAccess(std::shared_ptr<RandomAccess> randomAccess);
143};
144
145} // end namespace iolink
iolink::HTTPHeaders
A class used to pass HTTP headers as input of factories methods.
Definition HTTPHeaders.h:16
iolink::StreamAccessFactory
A factory to create StreamAccess instances from various ressources.
Definition StreamAccessFactory.h:20
iolink::StreamAccessFactory::openFileWrite
static std::shared_ptr< StreamAccess > openFileWrite(const std::string &filePath)
Create a stream that can write data to a file.
iolink::StreamAccessFactory::openFileRead
static std::shared_ptr< StreamAccess > openFileRead(const std::string &filePath)
Create a stream that can read data from a file.
iolink::StreamAccessFactory::allocate
static std::shared_ptr< StreamAccess > allocate(size_t size=0)
Create a stream in local memory.
iolink::StreamAccessFactory::fromStdStream
static std::shared_ptr< StreamAccess > fromStdStream(std::shared_ptr< std::iostream > stream)
Create a stream storage from a standard I/O stream.
iolink::StreamAccessFactory::toStdIStream
static std::shared_ptr< std::istream > toStdIStream(std::shared_ptr< StreamAccess > streamAccess)
Create a standard Input stream from a StreamAccess.
iolink::StreamAccessFactory::openURIWrite
static std::shared_ptr< StreamAccess > openURIWrite(const Uri &uri)
Create a stream that can write data to an URI.
iolink::StreamAccessFactory::toStdOStream
static std::shared_ptr< std::ostream > toStdOStream(std::shared_ptr< StreamAccess > streamAccess)
Create a standard Output stream from a StreamAccess.
iolink::StreamAccessFactory::fromStdStream
static std::shared_ptr< StreamAccess > fromStdStream(std::shared_ptr< std::istream > stream)
Create a stream storage from a standard input stream.
iolink::StreamAccessFactory::openHTTPWrite
static std::shared_ptr< StreamAccess > openHTTPWrite(const Uri &uri, const std::string &method, const HTTPHeaders &headers)
Create a stream that can post data to an HTTP URI.
iolink::StreamAccessFactory::copyInMemory
static std::shared_ptr< StreamAccess > copyInMemory(std::shared_ptr< StreamAccess > streamAccess)
Load a stream into local memory.
iolink::StreamAccessFactory::toStdStream
static std::shared_ptr< std::iostream > toStdStream(std::shared_ptr< StreamAccess > streamAccess)
Create a standard Input/Output stream from a StreamAccess.
iolink::StreamAccessFactory::fromRandomAccess
static std::shared_ptr< StreamAccess > fromRandomAccess(std::shared_ptr< RandomAccess > randomAccess)
Create a StreamAccess that will delegate to a RandomAccess.
iolink::StreamAccessFactory::fromStdStream
static std::shared_ptr< StreamAccess > fromStdStream(std::shared_ptr< std::ostream > stream)
Create a stream storage from a standard output stream.
iolink::StreamAccessFactory::openFile
static std::shared_ptr< StreamAccess > openFile(const std::string &filePath)
Create a stream that can read and write data from/to a file.
iolink::Uri
Class modeling universal resource identifier.
Definition Uri.h:15
iolink
All IOLink symbols are enclosed in this namespace.
Definition ArrayX.h:8