selection.hpp file

Toolkit for selecting file readers by format and codec.

Namespaces

namespace arcsdec
Main namespace for libarcsdec.
namespace arcsdec::v_1_0_0 inline
API version 1.0.0.

Classes

template<class ReaderType>
struct arcsdec::v_1_0_0::details::CreateReader
Functor to safely create a unique_ptr to a downcasted FileReader.
class arcsdec::v_1_0_0::DefaultPreference
DescriptorPreference for the most specific descriptor (with least supported Formats and Codecs).
class arcsdec::v_1_0_0::DefaultSelector
FileReaderSelector for first descriptor (in order of occurrence) with highest preference.
class arcsdec::v_1_0_0::DescriptorPreference
Interface for a descriptor preference.
template<typename P, typename S>
class arcsdec::v_1_0_0::FileReaderPreferenceSelection
FileReaderSelection of FileReaderDescriptors.
class arcsdec::v_1_0_0::FileReaderRegistry
Registry holding all available FileReaderDescriptors and all supported Formats.
class arcsdec::v_1_0_0::FileReaderSelection
Interface to select a FileReaderDescriptor by Format and Codec.
class arcsdec::v_1_0_0::FileReaderSelector
Interface for a selector on a set of FileReaderDescriptor instances.
class arcsdec::v_1_0_0::FormatPreference
DescriptorPreference for the most specific descriptor that accepts the Format.
class arcsdec::v_1_0_0::IdSelector
FileReaderSelector for a specific descriptor id.
class arcsdec::v_1_0_0::MinPreference
DescriptorPreference that is always DescriptorPreference::MIN_PREFERENCE.
template<class D>
struct arcsdec::v_1_0_0::RegisterDescriptor
Register a FileReaderDescriptor type.
template<enum Format F>
struct arcsdec::v_1_0_0::RegisterFormat
Register a Format.

Typedefs

using FileReaders = std::unordered_map<std::string, std::unique_ptr<FileReaderDescriptor>>
Type for the container of available FileReaderDescriptor instances.
using FormatList = std::vector<std::unique_ptr<Matcher>>
An unordered list of Matchers for Formats.

Functions

template<class ReaderType>
auto cast_reader(std::unique_ptr<FileReader> file_reader) noexcept -> std::pair< std::unique_ptr< ReaderType >, std::unique_ptr< FileReader > > -> auto noexcept
Downcast a FileReader to a specialized ReaderType.
template<class T, typename... Args>
auto make_descriptor(Args && ... args) -> std::unique_ptr<FileReaderDescriptor>
Instantiate FileReaderDescriptor.
auto select_descriptor(const std::string& filename, const FileReaderSelection& selection, const FormatList& formats, const FileReaders& readers) -> std::unique_ptr<FileReaderDescriptor>
Select a FileReaderDescriptor.
auto select_reader(const std::string& filename, const FileReaderSelection& selection, const FormatList& formats, const FileReaders& readers) -> std::unique_ptr<FileReader>
Select a FileReader.

Function documentation

template<class ReaderType>
auto cast_reader(std::unique_ptr<FileReader> file_reader) noexcept -> std::pair< std::unique_ptr< ReaderType >, std::unique_ptr< FileReader > > noexcept

Downcast a FileReader to a specialized ReaderType.

Parameters
file_reader in The pointer to cast
Returns Pair of casting result and the original input pointer.

The first element of the returned pair is a pointer to the requested input object with the requested cast performed. If the cast fails, the first element is a nullptr. The unaltered input pointer is returned as a second element in any case.

template<class T, typename... Args>
std::unique_ptr<FileReaderDescriptor> make_descriptor(Args && ... args)

Instantiate FileReaderDescriptor.

Template parameters
T The type to instantiate
Args The constructor arguments

std::unique_ptr<FileReaderDescriptor> select_descriptor(const std::string& filename, const FileReaderSelection& selection, const FormatList& formats, const FileReaders& readers)

Select a FileReaderDescriptor.

Parameters
filename in Name of the file to read
selection
formats in Set of file formats to check filename for
readers in Set of available file readers
Returns Descriptor that accepts the input file.

Select a reader that is guaranteed to accept the current input file or return a nullptr.

std::unique_ptr<FileReader> select_reader(const std::string& filename, const FileReaderSelection& selection, const FormatList& formats, const FileReaders& readers)

Select a FileReader.

Parameters
filename in Name of the file to read
selection
formats in Set of file formats to check filename for
readers in Set of available file readers
Returns FileReader that accepts the input file.

Select a reader that is guaranteed to accept the current input file or return a null pointer.