TSDuck v3.46-4965
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::TablePatchXML Class Reference

#include <tsTablePatchXML.h>

Public Member Functions

 TablePatchXML (DuckContext &duck)
void addPatchFileName (const UString &filename)
void addPatchFileNames (const UStringList &filenames)
void addPatchFileNames (const UStringVector &filenames)
bool applyPatches (BinaryTable &table) const
bool applyPatches (SectionPtr &section) const
void applyPatches (xml::Document &doc) const
void clear ()
void defineArgs (Args &args)
bool getExpandEnvironment () const
bool hasPatchFiles () const
bool loadArgs (DuckContext &duck, Args &args)
bool loadPatchFiles (const xml::Tweaks &tweaks=xml::Tweaks())
void setExpandEnvironment (bool expand)

Detailed Description

Implementation of on-the-fly table patching using XML. This class is typically used to handle --patch-xml command line options.

Constructor & Destructor Documentation

◆ TablePatchXML()

ts::TablePatchXML::TablePatchXML ( DuckContext & duck)
inline

Constructor.

Parameters
[in,out]duckTSDuck execution context.

Member Function Documentation

◆ defineArgs()

void ts::TablePatchXML::defineArgs ( Args & args)

Add command line option definitions in an Args.

Parameters
[in,out]argsCommand line arguments to update.

◆ loadArgs()

bool ts::TablePatchXML::loadArgs ( DuckContext & duck,
Args & args )

Load arguments from command line. Args error indicator is set in case of incorrect arguments.

Parameters
[in,out]duckTSDuck execution context.
[in,out]argsCommand line arguments.
Returns
True on success, false on error in argument line.

◆ clear()

void ts::TablePatchXML::clear ( )

Clear all previously loaded patch files, clear list of patch files.

◆ hasPatchFiles()

bool ts::TablePatchXML::hasPatchFiles ( ) const
inline

Check if there is some patch to apply. When false, no patch file was specified or loaded.

Returns
True if there is some patch to apply.

◆ addPatchFileName()

void ts::TablePatchXML::addPatchFileName ( const UString & filename)

Add a file name in the list of patch files. The file is not yet loaded.

Parameters
[in]filenameName of an XML patch file.

◆ addPatchFileNames() [1/2]

void ts::TablePatchXML::addPatchFileNames ( const UStringVector & filenames)

Add file names in the list of patch files. The files are not yet loaded.

Parameters
[in]filenamesNames of XML patch files. If a file name starts with "<?xml", this is considered as "inline XML content".

◆ addPatchFileNames() [2/2]

void ts::TablePatchXML::addPatchFileNames ( const UStringList & filenames)

Add file names in the list of patch files. The files are not yet loaded.

Parameters
[in]filenamesNames of XML patch files. If a file name starts with "<?xml", this is considered as "inline XML content".

◆ setExpandEnvironment()

void ts::TablePatchXML::setExpandEnvironment ( bool expand)
inline

Set expansion of environment variables in patch files.

Parameters
[in]expandIf true, expand all environment variables in the patch files before patching. More precisely, each patch file is internally duplicated first and then all environment variables are expanded in that copy. Therefore, if this TablePatchXML instance is used several times and the values of the environment variables changed in the meantime, the latest up-to-date values are always used.

◆ getExpandEnvironment()

bool ts::TablePatchXML::getExpandEnvironment ( ) const
inline

Check if expansion of environment variables is performed in patch files.

Returns
True if expansion of environment variables is performed in patch files.
See also
setExpandEnvironment()

◆ loadPatchFiles()

bool ts::TablePatchXML::loadPatchFiles ( const xml::Tweaks & tweaks = xml::Tweaks())

Load (or reload) the XML patch files.

Parameters
[in]tweaksXML tweaks to load in the documents.
Returns
True on success, false some error occurred in the input files.

◆ applyPatches() [1/3]

void ts::TablePatchXML::applyPatches ( xml::Document & doc) const

Apply the XML patch files to an XML document.

Parameters
[in,out]docThe XML document to patch.

◆ applyPatches() [2/3]

bool ts::TablePatchXML::applyPatches ( BinaryTable & table) const

Apply the XML patch files to a binary table.

Parameters
[in,out]tableThe binary table to patch.
Returns
True on success, false if the binary table or the patched XML is invalid. If the patch file deletes the table, then the returned value if true and the table is marked as invalid.

◆ applyPatches() [3/3]

bool ts::TablePatchXML::applyPatches ( SectionPtr & section) const

Apply the XML patch files to a binary section. This is a special processing since XML files are supposed to represent complete tables. The section is considered as section 0/0 of a complete table. The patch is applied on that table and the first section of the patched table is returned. Specific parts of the section are preserved, such as section number or last section number.

Parameters
[in,out]sectionSafe pointer to the section to patch. The pointer is modified, pointing to a new section content.
Returns
True on success, false if the binary section or the patched XML is invalid. If the patch file deletes the table, then the returned value if true and section is null.

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