IOLink IOL_v1.8.0_release
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
13namespace iolink
14{
15
19class IOLINK_API StreamAccessFactory
20{
21public:
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