VHISTlib
1.84.0.3018
|
A parser for VHIST files. More...
#include <vhistparser.h>
Public Member Functions | |
VhistParser (ParseMode mode=MODE_ROBUST, QObject *pLogTarget=NULL) | |
Creates a new parser for VHIST files. | |
virtual | ~VhistParser () |
Destroys a VHIST parser instance. | |
bool | open (const QString &filename) |
Opens a VHIST file and parses it. | |
SectionTagList | getSections () |
Returns a list of all sections in the current VHIST file. | |
int | getNumSections () |
Returns the number of sections in the current VHIST file. | |
FileTagList | getFiles () |
Returns a list of all embedded files in the current VHIST file. | |
int | getNumFiles () |
Returns the number of embedded files in the current VHIST file. | |
FileTagList | getFilesInSection (int sectionId) |
Returns a list of embedded files which are part of a specific section. | |
FileTagList | getSectionlessFiles () |
Returns a list of embedded files, which are not part of any section. | |
MaybeSectionTag | getSection (int id) |
Returns the section with the given id. | |
MaybeFileTag | getFile (int id) |
Returnes the embedded file with the given id. | |
MaybeBytes | getFileContent (int id) |
Returns the content of a given embedded file. | |
bool | writeFileToDisk (int id, const QString &filename) |
Writes an embedded file from the current VHIST file to harddisk. | |
MD5Sums | calcChecksumsForFile (int id) |
Calculates the MD5 checksum for an embedded file. | |
QByteArray | getBytes (int startPos, int numBytes) |
Returns a part of the current VHIST file. |
A parser for VHIST files.
The parser can read all embedded files and sections in a time and memory efficient way, extract embedded files from the VHIST file and calculate checksums for them. The progress of the parsing and occuring errors are published via the log signal.
VhistParser::VhistParser | ( | ParseMode | mode = MODE_ROBUST , |
QObject * | pLogTarget = NULL |
||
) |
Creates a new parser for VHIST files.
[in] | mode | Specifies whether the parser should follow the vhist spec strictly or provide more robust parsing. |
[in] | pLogTarget | An optional object with a void log(const QString, const vhist::LogType) slot. The parser will send it's output to this object. |
MD5Sums VhistParser::calcChecksumsForFile | ( | int | id | ) |
Calculates the MD5 checksum for an embedded file.
The method will calculate a pair of checksums, one checksum for the compressed and one for the uncompressed data. If the embedded file has not been compressed, the compressed MD5 will be empty. The checksums are returned as hex digests. In the case of an error, 2 empty checksums are returned.
[in] | id | The id of the embedded file, for which the checksums should be calculated. |
QByteArray VhistParser::getBytes | ( | int | startPos, |
int | numBytes | ||
) |
Returns a part of the current VHIST file.
If the bytes could not be read, an array of length 0
is returned.
[in] | startPos | The index of the first byte, which is returned. |
[in] | numBytes | The number of bytes to return. |
MaybeFileTag VhistParser::getFile | ( | int | id | ) |
Returnes the embedded file with the given id.
If the id is not valid or no VHIST file is currently opened, a NULL
pointer if returned.
[in] | id | The id of the requested file. |
NULL
if and error occured. MaybeBytes VhistParser::getFileContent | ( | int | id | ) |
Returns the content of a given embedded file.
The content is returned as a QByteArray. If the file is compressed, it is automatically inflated. In the case of an error, a NULL
pointer is returned. This way, it's clear if the retrieval of a 0
bytes large file succeeded or failed.
[in] | id | The id of the requested file. |
NULL
pointer if an error occured. FileTagList VhistParser::getFiles | ( | ) |
Returns a list of all embedded files in the current VHIST file.
FileTagList VhistParser::getFilesInSection | ( | int | sectionId | ) |
Returns a list of embedded files which are part of a specific section.
If no VHIST file is currently open or the section does not exist, an empty list is returned.
[in] | sectionId | The id of the section, which's files should be returned. |
int VhistParser::getNumFiles | ( | ) |
Returns the number of embedded files in the current VHIST file.
int VhistParser::getNumSections | ( | ) |
Returns the number of sections in the current VHIST file.
MaybeSectionTag VhistParser::getSection | ( | int | id | ) |
Returns the section with the given id.
If the id is not valid or no VHIST file is currently opened, a NULL
pointer is returned.
[in] | id | The id of the section, which should be returned. |
NULL
if an error occured. FileTagList VhistParser::getSectionlessFiles | ( | ) |
Returns a list of embedded files, which are not part of any section.
SectionTagList VhistParser::getSections | ( | ) |
Returns a list of all sections in the current VHIST file.
If no file has been opened yet or if opening and parsing the last VHIST file failed, an empty list is returned.
bool VhistParser::open | ( | const QString & | filename | ) |
Opens a VHIST file and parses it.
If the file could not be opened or detecting the VHIST header failed, false
is returned.
[in] | filename | The name of the file, which should be opened. |
true
if opening and parsing the file succeeded and false
otherwise.bool VhistParser::writeFileToDisk | ( | int | id, |
const QString & | filename | ||
) |
Writes an embedded file from the current VHIST file to harddisk.
[in] | id | The id of the embedded file. |
[in] | filename | The location on the harddisk, to which the file should be written. |
true
if the operation succeeded and false
otherwise.