TSDuck v3.38-3691
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::NamesFile Class Reference

Representation of a ".names" file, containing names for identifiers. More...

#include <tsNamesFile.h>

Classes

class  RegisterExtensionFile
 A class to register additional names files to merge with the TSDuck names file. More...
 

Public Types

enum class  Predefined {
  DTV = 0 ,
  IP = 1 ,
  OUI = 2 ,
  DEKTEC = 3 ,
  HIDES = 4
}
 Identifiers for some predefined TSDuck names files. More...
 
using Value = uint64_t
 Largest integer type we manage in the repository of names.
 

Public Member Functions

 NamesFile (const UString &fileName, bool mergeExtensions=false)
 Constructor.
 
virtual ~NamesFile ()
 Virtual destructor.
 
UString configurationFile () const
 Get the complete path of the configuration file from which the names were loaded.
 
size_t errorCount () const
 Get the number of errors in the configuration file.
 
bool nameExists (const UString &sectionName, Value value) const
 Check if a name exists in a specified section.
 
UString nameFromSection (const UString &sectionName, Value value, NamesFlags flags=NamesFlags::NAME, size_t bits=0, Value alternateValue=0) const
 Get a name from a specified section.
 
UString nameFromSectionWithFallback (const UString &sectionName, Value value1, Value value2, NamesFlags flags=NamesFlags::NAME, size_t bits=0, Value alternateValue=0) const
 Get a name from a specified section, with alternate fallback value.
 

Static Public Member Functions

static void DeleteInstance (Predefined index)
 Delete a common instance of NamesFile for a predefined configuration file.
 
static UString Formatted (Value value, const UString &name, NamesFlags flags, size_t bits, Value alternateValue=0)
 Format a name using flags.
 
static const NamesFileInstance (const UString &fileName, bool mergeExtensions=false)
 Get a common instance of NamesFile for a given configuration file.
 
static const NamesFileInstance (Predefined index)
 Get a common instance of NamesFile for a predefined configuration file.
 
static void UnregisterExtensionFile (const UString &filename)
 Unregister a previously registered extension.
 

Detailed Description

Representation of a ".names" file, containing names for identifiers.

In an instance of NamesFile, all names are loaded from one configuration file.

Member Enumeration Documentation

◆ Predefined

enum class ts::NamesFile::Predefined
strong

Identifiers for some predefined TSDuck names files.

Using an idenfier is faster than looking for a file name.

Enumerator
DTV 

All Digital TV definitions (MPEG, DVB, ATSC, ISDB).

IP 

Internet protocols definitions.

OUI 

IEEE Organizationally Unique Identifiers.

DEKTEC 

Dektec devices definitions.

HIDES 

HiDes modulators definitions.

Constructor & Destructor Documentation

◆ NamesFile()

ts::NamesFile::NamesFile ( const UString fileName,
bool  mergeExtensions = false 
)

Constructor.

Using this constructor directly is discouraged. Use Instance() instead.

Parameters
[in]fileNameConfiguration file name. Typically without directory name. Without directory, the file is automatically searched in the TSDuck configuration directory.
[in]mergeExtensionsIf true, merge the content of names files from TSDuck extensions.
See also
Instance(const UString&, bool);
Instance(Predefined, bool);

Member Function Documentation

◆ Instance() [1/2]

static const NamesFile * ts::NamesFile::Instance ( const UString fileName,
bool  mergeExtensions = false 
)
static

Get a common instance of NamesFile for a given configuration file.

The file is loaded once and the instance is created the first time. When the same file is requested again, the same instance is returned.

Parameters
[in]fileNameConfiguration file name without directory name. The file is searched in the TSDuck configuration directory.
[in]mergeExtensionsIf true, merge the content of names files from TSDuck extensions when the file is loaded the first time.
Returns
A pointer to the NamesFile instance for that file. Never return a null pointer. In case of error (non existent file for instance), an empty instance is returned for that file.

◆ Instance() [2/2]

static const NamesFile * ts::NamesFile::Instance ( Predefined  index)
static

Get a common instance of NamesFile for a predefined configuration file.

The file is loaded once and the instance is created the first time. When the same file is requested again, the same instance is returned.

Parameters
[in]indexIdentifier of the predefined file to get.
Returns
A pointer to the NamesFile instance for that file. Never return a null pointer. In case of error (non existent file for instance), an empty instance is returned for that file.

◆ DeleteInstance()

static void ts::NamesFile::DeleteInstance ( Predefined  index)
static

Delete a common instance of NamesFile for a predefined configuration file.

This should never be necessary unless TSDuck extensions are loaded on the fly. This never happens since extensions are registered in macro TS_REGISTER_NAMES_FILE. This is useful in test programs only.

Parameters
[in]indexIdentifier of the predefined file to get.

◆ configurationFile()

UString ts::NamesFile::configurationFile ( ) const
inline

Get the complete path of the configuration file from which the names were loaded.

Returns
The complete path of the configuration file. Empty if does not exist.

◆ errorCount()

size_t ts::NamesFile::errorCount ( ) const
inline

Get the number of errors in the configuration file.

Returns
The number of errors in the configuration file.

◆ nameExists()

bool ts::NamesFile::nameExists ( const UString sectionName,
Value  value 
) const

Check if a name exists in a specified section.

Parameters
[in]sectionNameName of section to search. Not case-sensitive.
[in]valueValue to get the name for.
Returns
True if a name exists for value in sectionName.

◆ nameFromSection()

UString ts::NamesFile::nameFromSection ( const UString sectionName,
Value  value,
NamesFlags  flags = NamesFlags::NAME,
size_t  bits = 0,
Value  alternateValue = 0 
) const

Get a name from a specified section.

Parameters
[in]sectionNameName of section to search. Not case-sensitive.
[in]valueValue to get the name for.
[in]flagsPresentation flags.
[in]bitsNominal size in bits of the data, optional.
[in]alternateValueDisplay this integer value if flags ALTERNATE is set.
Returns
The corresponding name.

◆ nameFromSectionWithFallback()

UString ts::NamesFile::nameFromSectionWithFallback ( const UString sectionName,
Value  value1,
Value  value2,
NamesFlags  flags = NamesFlags::NAME,
size_t  bits = 0,
Value  alternateValue = 0 
) const

Get a name from a specified section, with alternate fallback value.

Parameters
[in]sectionNameName of section to search. Not case-sensitive.
[in]value1Value to get the name for.
[in]value2Alternate value if no name is found for value1.
[in]flagsPresentation flags.
[in]bitsNominal size in bits of the data, optional.
[in]alternateValueDisplay this integer value if flags ALTERNATE is set.
Returns
The corresponding name.

◆ Formatted()

static UString ts::NamesFile::Formatted ( Value  value,
const UString name,
NamesFlags  flags,
size_t  bits,
Value  alternateValue = 0 
)
static

Format a name using flags.

Parameters
[in]valueValue for the name.
[in]nameName for the value.
[in]flagsPresentation flags.
[in]bitsNominal size in bits of the data, optional.
[in]alternateValueDisplay this integer value if flags ALTERNATE is set.
Returns
The corresponding name.

◆ UnregisterExtensionFile()

static void ts::NamesFile::UnregisterExtensionFile ( const UString filename)
static

Unregister a previously registered extension.

Parameters
[in]filenameName of the names file to unregister,

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