API for abstract FileReaders module

API for describing FileReaders for several file Formats.

A Format represents a file format. A Codec represents an audio codec. For Formats as well as for Codecs, their respective names can be achieved by functions name().

A file can be matched against a Format by a FormatMatcher. A FormatMatcher is defined with some referential Bytes of a file or a SuffixSet for filenames.

Bytes denote a reference sequence of bytes. They consist of an offset, denoting their required start position in the file and a ByteSequence which is a sequence of concrete byte values that may or may not contain wildcards.

A FormatMatcher matches Bytes passed or a concrete filename suffix for matching its reference information. The interpretation of the match of one or both of these input informations is in the responsibility of the caller. This is a base mechanism for checking a file for a certain format and codec.

A FileReader is an abstract base for either reading metadata/TOC files or audio files. Any concrete FileReader implements a reading capability for at least one Format and at least one Codec. The FileReader interface defines only the capability to return a FileReaderDescriptor. (The definition of other capabilities is left to subclasses, as there are AudioReader and MetadataParser.)

A FileReaderDescriptor contains metainformation about some concrete FileReader and can inform about whether this respective FileReader has the capability to read a particular file in question. FileReaderDescriptors either accept or do not accept any particular Formats. Any FileReaderDescriptor can create the concrete FileReader it describes. Any concrete FileReader can return its specific FileReaderDescriptor, accordingly.

An InputFormatException indicates any error concerning the input file format. A FileReadException indicates problems while actually reading the file.

There are some helpers for implementing own FileReaderDescriptors. Function read_bytes() reads a specified amount of bytes from a specified position in the file. The function returns a ByteSequence that is compatible with the input for file format checks. Function get_suffix() returns the suffix of a given filename. This suffix can be matched case-insensitive against a set of suffices by ci_match_suffix().

The AudioReader and MetadataParser APIs are built on this API.

Classes

class arcsdec::v_1_0_0::Bytes
A sequence of bytes read from a specific offset in a file.
class arcsdec::v_1_0_0::ByteSeq
Byte sequence with or without wildcards.
class arcsdec::v_1_0_0::FileReader
Abstract base class for FileReaders.
class arcsdec::v_1_0_0::FileReaderDescriptor
Abstract base class for the properties of a FileReader.
class arcsdec::v_1_0_0::FileReadException
Reports an error while reading a file.
template<enum Format F>
class arcsdec::v_1_0_0::FormatMatcher
Matcher for file formats.
class arcsdec::v_1_0_0::InputFormatException
Reports an error concerning the input file format.
class arcsdec::v_1_0_0::Matcher
Interface for matchers.

Enums

enum class Codec: unsigned { UNKNOWN, PCM_S16BE, PCM_S16BE_PLANAR, PCM_S16LE, PCM_S16LE_PLANAR, PCM_S32BE, PCM_S32BE_PLANAR, PCM_S32LE, PCM_S32LE_PLANAR, FLAC, WAVPACK, MONKEY, ALAC, NONE }
A supported audio codec.
enum class Format: unsigned { UNKNOWN, CUE, CDRDAO, WAV, FLAC, APE, CAF, M4A, OGG, WV, AIFF }
List of supported file formats for metadata and audio.
enum class InputType: unsigned { AUDIO, TOC }
Input filetype.

Typedefs

using ByteSequence = ByteSeq
A sequence of bytes.
using LibInfo = std::list<LibInfoEntry>
Represents a list of pairs of a library name and an additional string.
using LibInfoEntry = std::pair<std::string, std::string>
Entry of a LibInfo.
using SuffixSet = std::set<details::ci_string>
A set of filename suffices.

Functions

auto libinfo_entry_filepath(const std::string& libname) -> LibInfoEntry
Create a LibInfoEntry for libname, lookup filepath of library.
auto name(Codec codec) -> std::string
Name of the codec.
auto name(Format format) -> std::string
Name of the format.

Enum documentation

enum class Codec: unsigned

A supported audio codec.

The supported codecs are only the tested codecs, in fact other lossless codecs can be silently supported if an appropriate FileReader accepts a Format that supports this Codec and accepts Codec::UNKNOWN. However, the best practise is to explicitly support a Codec by an explicit check for it.

Codec::UNKNOWN represents a codec that was checked but could not be recognized. Codec::NONE represents the information that no codec is expected, supported or available.

The intention is to support inspecting the capabilities of FileReaders.

enum class Format: unsigned

List of supported file formats for metadata and audio.

Format::UNKNOWN represents a Format that was checked but could not be recognized.

The intention is to support inspecting the capabilities of FileReaders.

enum class InputType: unsigned

Input filetype.

Typedef documentation

using ByteSequence = ByteSeq

A sequence of bytes.

As read from a file.

using LibInfo = std::list<LibInfoEntry>

Represents a list of pairs of a library name and an additional string.

using LibInfoEntry = std::pair<std::string, std::string>

Entry of a LibInfo.

An entry for a LibInfo consists of the library name and an additional string. The additional string can be used for information about the library.

using SuffixSet = std::set<details::ci_string>

A set of filename suffices.

An ordered set of case-insensitive strings. Defines a value_type and is iterable as required by std::find_if.

Function documentation

LibInfoEntry libinfo_entry_filepath(const std::string& libname)

Create a LibInfoEntry for libname, lookup filepath of library.

Parameters
libname in Name of a library.
Returns A LibInfoEntry that contains the concrete filepath for the library.

The second part will contain the concrete filepath for the library named libname. The libarcsdec binary is inspected to lookup this information.

std::string name(Codec codec)

Name of the codec.

Parameters
codec in The Codec to get the name for
Returns Name of the Codec.

std::string name(Format format)

Name of the format.

Parameters
format in The Format to get the name for
Returns Name of the Format.