28 m_restrictions(restrictions) {}
33 return m_restrictions;
37 virtual std::unique_ptr<Variant> unrestrict(
const InputRestrictions& rest)
const = 0;
41 class Memory:
public Variant {
42 std::vector<uint8_t>* m_buffer;
46 m_buffer(other.m_buffer) {}
48 Memory(std::vector<uint8_t>* buffer):
51 inline std::unique_ptr<Variant> unrestrict(
const InputRestrictions& rest)
const override {
52 return std::make_unique<Memory>(
53 Memory(*
this, restrictions() | rest));
57 class File:
public Variant {
60 mutable bool m_overwrite;
65 m_overwrite(other.m_overwrite) {}
67 File(
const std::string& path,
bool overwrite):
69 m_overwrite(overwrite) {}
71 inline std::unique_ptr<Variant> unrestrict(
const InputRestrictions& rest)
const override {
72 return std::make_unique<File>(
73 File(*
this, restrictions() | rest));
77 class Stream:
public Variant {
78 std::ostream* m_stream;
82 m_stream(other.m_stream) {}
84 Stream(std::ostream* stream):
87 inline std::unique_ptr<Variant> unrestrict(
const InputRestrictions& rest)
const override {
88 return std::make_unique<Stream>(
89 Stream(*
this, restrictions() | rest));
94 std::unique_ptr<Variant>
m_data;
103 m_data(
std::move(other.m_data)) {}
112 m_data(
std::make_unique<File>(
std::move(path.path), overwrite)) {}
117 inline Output(std::vector<uint8_t>& buf):
118 m_data(
std::make_unique<Memory>(&buf)) {}
124 m_data(
std::make_unique<Stream>(&stream)) {}
128 m_data = std::move(other.m_data);
140 return Output(path, overwrite);
165 m_data(other.m_data->unrestrict(restrictions)) {}
Contains the text compression and encoding framework.
Provides a character stream to the underlying output.
Output(std::ostream &stream)
Constructs an output that appends to the output stream.
Output & operator=(Output &&other)
Move assignment operator.
Output(std::vector< uint8_t > &buf)
Constructs an output that appends to the byte vector.
Output()
Constructs an output to stdout.
Output(const Path &path, bool overwrite=false)
Constructs an output that appends to the file at the given path.
OutputStream as_stream() const
Creates a stream that allows for character-wise output.
static Output from_memory(std::vector< uint8_t > &buf)
Constructs an output to a byte buffer.
An abstraction layer for algorithm output.
static Output from_stream(std::ostream &stream)
Constructs an output to a stream.
static Output from_path(const Path &path, bool overwrite=false)
Constructs a file output writing to the file at the given path.
Output(Output &&other)
Move constructor.