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

A class containing a set of integer values with names. More...

Public Member Functions

 QtlNamedIntSet (QtlLogger *log=0)
 Constructor. More...
 
 QtlNamedIntSet (const QtlNamedIntSet &other)
 Copy constructor. More...
 
bool addDefinition (const QString &definition)
 Add a definition of the form "value = name". More...
 
bool addDefinitions (const QStringList &definitions)
 Add a list of definitions of the form "value = name". More...
 
void addValue (quint32 value, const QString &name)
 Add a value. More...
 
int defaultBase () const
 Get the default base for name(). More...
 
quint32 defaultValue () const
 Get the default value for value(). More...
 
int defaultWidth () const
 Get the default width for name(). More...
 
bool hasName (quint32 value) const
 Check if an integer has a name. More...
 
bool loadDefinitions (const QString &fileName)
 Load a list of definitions of the form "value = name" from a file. More...
 
QString name (quint32 value, int defaultBase=-1, bool addBasePrefix=true, int width=-1) const
 Get the name of an integer. More...
 
QStringList names () const
 Get a list of all names. More...
 
const QtlNamedIntSetoperator= (const QtlNamedIntSet &other)
 Assignment. More...
 
void setDefaultBase (int defaultBase)
 Set the default base for name(). More...
 
void setDefaultValue (const quint32 &defaultValue)
 Set the default value for value(). More...
 
void setDefaultWidth (int defaultWidth)
 Set the default width for name(). More...
 
quint32 value (const QString &name) const
 Get a value from a name. More...
 
quint32 value (const QString &name, quint32 defaultValue) const
 Get a value from a name. More...
 

Private Types

typedef QMap< QString, quint32 > MapByName
 Translate names to values. More...
 

Private Attributes

int _defaultBase
 Default base for name(). More...
 
quint32 _defaultValue
 Default value for value(). More...
 
int _defaultWidth
 Default width for name(). More...
 
QtlLogger_log
 Where to log errors. More...
 
MapByName _mapByName
 Translate names to values. More...
 

Detailed Description

A class containing a set of integer values with names.

The values are 32-bit unsigned integers (quint32).

Member Typedef Documentation

◆ MapByName

typedef QMap<QString,quint32> QtlNamedIntSet::MapByName
private

Translate names to values.

Constructor & Destructor Documentation

◆ QtlNamedIntSet() [1/2]

QtlNamedIntSet::QtlNamedIntSet ( QtlLogger log = 0)
explicit

Constructor.

Parameters
[in]logWhere to log errors. Ignored if zero.

◆ QtlNamedIntSet() [2/2]

QtlNamedIntSet::QtlNamedIntSet ( const QtlNamedIntSet other)

Copy constructor.

Parameters
[in]otherOther instance to copy.

Member Function Documentation

◆ operator=()

const QtlNamedIntSet & QtlNamedIntSet::operator= ( const QtlNamedIntSet other)

Assignment.

Parameters
[in]otherOther instance to copy.

◆ addValue()

void QtlNamedIntSet::addValue ( quint32  value,
const QString &  name 
)

Add a value.

If a value with the same name already exists, replace it.

Parameters
[in]valueInteger value to add.
[in]nameName of the value.

◆ addDefinition()

bool QtlNamedIntSet::addDefinition ( const QString &  definition)

Add a definition of the form "value = name".

Empty lines or lines starting with '#' are ignored. If a value with the same name already exists, replace it. Errors are logged if a logger was specified.

Parameters
[in]definitionA string of the form "value = name". Base prefix like "0x" or "0" are recognized in the value.
Returns
True on success, false on error.

◆ addDefinitions()

bool QtlNamedIntSet::addDefinitions ( const QStringList &  definitions)

Add a list of definitions of the form "value = name".

Empty lines or lines starting with '#' are ignored. If a value with the same name already exists, replace it. Errors are logged if a logger was specified.

Parameters
[in]definitionsA list of strings of the form "value = name". Base prefix like "0x" or "0" are recognized in the value.
Returns
True on success, false on error.

◆ loadDefinitions()

bool QtlNamedIntSet::loadDefinitions ( const QString &  fileName)

Load a list of definitions of the form "value = name" from a file.

Empty lines or lines starting with '#' are ignored. If a value with the same name already exists, replace it. Errors are logged if a logger was specified.

Parameters
[in]fileNameA text file containing lines of the form "value = name". Base prefix like "0x" or "0" are recognized in the value.
Returns
True on success, false on error.

◆ names()

QStringList QtlNamedIntSet::names ( ) const

Get a list of all names.

Returns
A list of al names.

◆ value() [1/2]

quint32 QtlNamedIntSet::value ( const QString &  name) const
inline

Get a value from a name.

Parameters
[in]nameName of the value or a string representation of an integer.
Returns
The corresponding value or defaultValue() if the value has no name.

◆ value() [2/2]

quint32 QtlNamedIntSet::value ( const QString &  name,
quint32  defaultValue 
) const

Get a value from a name.

Parameters
[in]nameName of the value or a string representation of an integer.
[in]defaultValueDefault value to return if name is unknown.
Returns
The corresponding value or defaultValue if the value has no name.

◆ name()

QString QtlNamedIntSet::name ( quint32  value,
int  defaultBase = -1,
bool  addBasePrefix = true,
int  width = -1 
) const

Get the name of an integer.

If several names have the same value, return one of these names. If no name exists, a string representation of the value is returned.

Parameters
[in]valueThe value to get the name of.
[in]defaultBaseIf value has no name, base of the string representation. Valid values are 10, 16 and 8. If a negative value is specified, use defaultBase(). For any other value, return an empty string.
[in]addBasePrefixIf defaultBase is 16 or 8, add the standard prefix "0x" or "0".
[in]widthIf value has no name, gives the width of the value representation, not including the prefix. If a negative value is specified, use defaultWidth(). If zero is specified, do not justify.
Returns
The name for value or a string representation.

◆ hasName()

bool QtlNamedIntSet::hasName ( quint32  value) const
inline

Check if an integer has a name.

Parameters
[in]valueThe value to check the name of.
Returns
True if value has a name, false otherwise.

◆ defaultValue()

quint32 QtlNamedIntSet::defaultValue ( ) const
inline

Get the default value for value().

Returns
The value for value().
See also
value(const QString&)

◆ setDefaultValue()

void QtlNamedIntSet::setDefaultValue ( const quint32 &  defaultValue)
inline

Set the default value for value().

Parameters
[in]defaultValueThe value for value().
See also
value(const QString&)

◆ defaultBase()

int QtlNamedIntSet::defaultBase ( ) const
inline

Get the default base for name().

Returns
The default base for name().
See also
name()

◆ setDefaultBase()

void QtlNamedIntSet::setDefaultBase ( int  defaultBase)
inline

Set the default base for name().

Parameters
[in]defaultBaseThe default base for name().
See also
name()

◆ defaultWidth()

int QtlNamedIntSet::defaultWidth ( ) const
inline

Get the default width for name().

Returns
The default width for name().
See also
name()

◆ setDefaultWidth()

void QtlNamedIntSet::setDefaultWidth ( int  defaultWidth)
inline

Set the default width for name().

Parameters
[in]defaultWidthThe default width for name().
See also
name()

Member Data Documentation

◆ _log

QtlLogger* QtlNamedIntSet::_log
private

Where to log errors.

◆ _mapByName

MapByName QtlNamedIntSet::_mapByName
private

Translate names to values.

◆ _defaultValue

quint32 QtlNamedIntSet::_defaultValue
private

Default value for value().

◆ _defaultBase

int QtlNamedIntSet::_defaultBase
private

Default base for name().

◆ _defaultWidth

int QtlNamedIntSet::_defaultWidth
private

Default width for name().


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