MagicFormatDetector Class Reference

Format detection implementation that uses magic numbers. More...

#include <magicformatdetector.h>

Inherits FormatDetector.

List of all members.

Public Member Functions

void addMagicNumber (const std::string &format, const std::string &magicNumber)
 Map a magic number matching the beginning of the file to a format.
void addMagicNumber (const std::string &format, const std::string &magicNumber, int offset)
 Shift a magic number and map it to a format.

Detailed Description

Format detection implementation that uses magic numbers.

A magic number is a byte string, found in the beginning of the file and unique to a format. A list can be found here : http://www.garykessler.net/library/file_sigs.html

When two magic numbers match a file the longest will have priority


Member Function Documentation

void MagicFormatDetector::addMagicNumber ( const std::string &  format,
const std::string &  magicNumber 
)

Map a magic number matching the beginning of the file to a format.

Parameters:
format
magicNumberthe magic number shall be given as a string with space separated bytes given as two-digit hex numbers. "xx" can be given instead of a number to specify that there is no requirement for the byte.
void MagicFormatDetector::addMagicNumber ( const std::string &  format,
const std::string &  magicNumber,
int  offset 
)

Shift a magic number and map it to a format.

Equivalent to addMagicNumber(format, "xx "+magicNumber, offset-1) if offset > 0


The documentation for this class was generated from the following file: