QtlMovie 1.12 (A specialized FFmpeg front-end)
QtlSubStationAlphaParser Class Reference

A basic parser for Sub Station Alpha (SSA/ASS) subtitles files. More...

Inheritance diagram for QtlSubStationAlphaParser:

Signals

void sectionChanged (const QString &sectionName)
 Emitted at the start of a section. More...
 
void subtitleFrame (const QtlSubStationAlphaFramePtr &frame)
 Emitted when a subtitle frame is found. More...
 

Public Member Functions

 QtlSubStationAlphaParser (QtlLogger *log=0, QObject *parent=0)
 Constructor. More...
 
bool addFile (const QString &fileName, const char *codecName="UTF-8")
 Provide a complete input file. More...
 
void addLine (const QString &line)
 Provide one input line. More...
 
void addLines (const QStringList &lines)
 Provide input lines. More...
 
QString currentSection () const
 Get the current section name. More...
 
QString getScriptInfo (const QString &name, const QString &defaultValue=QString()) const
 Get one field of the script info. More...
 
bool isAdvanced () const
 Check if the format is "advanced" Sub Station Alpha (aka ASS). More...
 
bool scriptInfoCompleted () const
 Check if the [Script Info] section has been completely parsed. More...
 

Static Public Member Functions

static QString normalized (const QString &name)
 Convert an identifier to a normalized format. More...
 

Private Attributes

QStringList _formatList
 Current list of formats, in normalized form. More...
 
QMap< QString, QString > _infoMap
 Map of script info, using normalized type names as keys. More...
 
bool _isAdvanced
 True for ASS, false for SSA. More...
 
QtlLogger_log
 Message logger. More...
 
QtlNullLogger _nullLog
 Default logger. More...
 
bool _scriptInfoCompleted
 True if [Script Info] section has been completely parsed. More...
 
QString _sectionName
 Current section name. More...
 
QString _sectionNormalized
 Current section name. More...
 
QtlSubStationAlphaStyleMap _styles
 Map of styles, using normalized names as keys. More...
 

Detailed Description

A basic parser for Sub Station Alpha (SSA/ASS) subtitles files.

SSA: Sub Station Alpha version 4. ASS: Advanced Sub Station Alpha version 4+. SSA/ASS specification: http://moodub.free.fr/video/ass-specs.doc

Constructor & Destructor Documentation

◆ QtlSubStationAlphaParser()

QtlSubStationAlphaParser::QtlSubStationAlphaParser ( QtlLogger log = 0,
QObject *  parent = 0 
)
explicit

Constructor.

Parameters
[in]logWhere to log errors.
[in]parentOptional parent object.

Member Function Documentation

◆ addLine()

void QtlSubStationAlphaParser::addLine ( const QString &  line)

Provide one input line.

Parameters
[in]lineOne line of ASS/SSA file.

◆ addLines()

void QtlSubStationAlphaParser::addLines ( const QStringList &  lines)

Provide input lines.

Parameters
[in]linesLines of ASS/SSA file.

◆ addFile()

bool QtlSubStationAlphaParser::addFile ( const QString &  fileName,
const char *  codecName = "UTF-8" 
)

Provide a complete input file.

Parameters
[in]fileNameName of an ASS/SSA file.
[in]codecNameCodec name for the file. Default is UTF-8.
Returns
True on success, false on error (file not found, etc.)
See also
QTextStream::setCodec()

◆ currentSection()

QString QtlSubStationAlphaParser::currentSection ( ) const
inline

Get the current section name.

Returns
The current section name.

◆ isAdvanced()

bool QtlSubStationAlphaParser::isAdvanced ( ) const
inline

Check if the format is "advanced" Sub Station Alpha (aka ASS).

Returns
True for ASS, false for SSA.

◆ scriptInfoCompleted()

bool QtlSubStationAlphaParser::scriptInfoCompleted ( ) const
inline

Check if the [Script Info] section has been completely parsed.

Returns
True if the [Script Info] section has been completely parsed.

◆ getScriptInfo()

QString QtlSubStationAlphaParser::getScriptInfo ( const QString &  name,
const QString &  defaultValue = QString() 
) const

Get one field of the script info.

Parameters
[in]nameInfo name.
[in]defaultValueDefault value if the field is not found.
Returns
The information value as a string.

◆ normalized()

QString QtlSubStationAlphaParser::normalized ( const QString &  name)
static

Convert an identifier to a normalized format.

This method is useless for applications.

Parameters
[in]nameIdentifier.
Returns
Normalized format, in lower case, with all spaces "simplified".

◆ sectionChanged

void QtlSubStationAlphaParser::sectionChanged ( const QString &  sectionName)
signal

Emitted at the start of a section.

Parameters
[in]sectionNameName of the section, as it appears in the file.

◆ subtitleFrame

void QtlSubStationAlphaParser::subtitleFrame ( const QtlSubStationAlphaFramePtr frame)
signal

Emitted when a subtitle frame is found.

Parameters
[in]frameSmart pointer to a subtitle frame.

Member Data Documentation

◆ _nullLog

QtlNullLogger QtlSubStationAlphaParser::_nullLog
private

Default logger.

◆ _log

QtlLogger* QtlSubStationAlphaParser::_log
private

Message logger.

◆ _isAdvanced

bool QtlSubStationAlphaParser::_isAdvanced
private

True for ASS, false for SSA.

◆ _scriptInfoCompleted

bool QtlSubStationAlphaParser::_scriptInfoCompleted
private

True if [Script Info] section has been completely parsed.

◆ _sectionName

QString QtlSubStationAlphaParser::_sectionName
private

Current section name.

◆ _sectionNormalized

QString QtlSubStationAlphaParser::_sectionNormalized
private

Current section name.

◆ _formatList

QStringList QtlSubStationAlphaParser::_formatList
private

Current list of formats, in normalized form.

◆ _infoMap

QMap<QString,QString> QtlSubStationAlphaParser::_infoMap
private

Map of script info, using normalized type names as keys.

◆ _styles

QtlSubStationAlphaStyleMap QtlSubStationAlphaParser::_styles
private

Map of styles, using normalized names as keys.


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