tudocomp
– The TU Dortmund Compression Framework
|
An abstraction layer for algorithm input. More...
#include <Input.hpp>
Public Member Functions | |
Input () | |
Constructs an empty input. More... | |
Input (const Input &other) | |
Constructs an input from another input, retaining its internal state ("cursor"). More... | |
Input (Input &&other) | |
Move constructor. More... | |
Input (Path &&path) | |
Constructs a file input reading from the file at the given path. More... | |
Input (const string_ref &buf) | |
Constructs an input reading from a string in memory. More... | |
Input (const std::vector< uint8_t > &buf) | |
Constructs an input reading from the specified byte buffer. More... | |
Input (std::istream &stream) | |
Constructs an input reading from a stream. More... | |
Input & | operator= (Input &&other) |
Move assignment operator. More... | |
Input & | operator= (const Input &other) |
Copy assignment operator. More... | |
InputView | as_view () const |
Provides a view on the input that allows for random access. More... | |
InputStream | as_stream () const |
Creates a stream that allows for character-wise reading of the input. More... | |
size_t | size () const |
Yields the total amount of characters in the input. More... | |
Static Public Member Functions | |
static Input | from_path (std::string path) |
Constructs a file input reading from the file at the given path. More... | |
static Input | from_memory (const std::vector< uint8_t > &buf) |
Constructs a file input reading from a byte buffer. More... | |
static Input | from_memory (const string_ref buf) |
Constructs a file input reading from a string in memory. More... | |
Friends | |
class | InputStream |
class | InputStreamInternal |
class | InputView |
An abstraction layer for algorithm input.
This class serves as a generic abstraction over different sources of input: memory buffers, files or streams. It provides two ways of handling the input: streams or views. While a view allows random access on all of the input, it requires the entire input to be stored in memory. Streaming, on the other hand, is used for character-wise reading without the ability to rewind (online).
Copying or otherwise manipulating instances of this class is cheap, since this class does not contain the input data itself, only information on how to access it.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Creates a stream that allows for character-wise reading of the input.
This might have to allocate a copy of the data into memory depending on its source or on data restrictions placed on it.
For example, if your source is a istream
it will generally have to create a copy to allow calling this method multiple times.
|
inline |
Provides a view on the input that allows for random access.
This might have to allocate a copy of the data into memory depending on its source or on data restrictions placed on it.
For example, if your source is a istream
it will generally have to create a copy.
|
inlinestatic |
Constructs a file input reading from a byte buffer.
buf | The input byte buffer. |
|
inlinestatic |
Constructs a file input reading from a string in memory.
buf | The input string. |
|
inlinestatic |
Constructs a file input reading from the file at the given path.
path | The path to the input file. |
|
inline |
Yields the total amount of characters in the input.
This might have to allocate a copy of the data into memory depending on its source or on data restrictions placed on it.
For example, if your source is a istream
it will generally have to create a copy to allow calling this method multiple times.
|
friend |