TSDuck v3.46-4930
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::xml::Attribute Class Reference

#include <tsxmlAttribute.h>

Public Member Functions

 Attribute ()
 Attribute (const UString &name, const UString &value=UString(), size_t line=0)
void expandEnvironment ()
const UString formattedValue (const Tweaks &tweaks) const
bool ignoreNamespace () const
bool isValid () const
size_t lineNumber () const
const UString & name () const
bool nameMatch (const UChar *str) const
bool nameMatch (const UChar *str, bool ignore_namespace) const
bool nameMatch (const UString &str) const
bool nameMatch (const UString &str, bool ignore_namespace) const
size_t sequence () const
void setBool (bool value)
void setDate (const Time &value)
void setDateTime (const Time &value)
template<typename INT>
requires ts::int_enum<INT>
void setEnum (const Names &definition, INT value)
template<typename FLT>
requires std::floating_point<FLT>
void setFloat (FLT value, size_t width=0, size_t precision=6, bool force_sign=false)
void setIignoreNamespace (bool ignore)
template<typename INT>
requires std::integral<INT>
void setInteger (INT value, bool hexa=false)
void setString (const UString &value)
template<class Rep, class Period>
void setTime (const cn::duration< Rep, Period > &value)
const UString & value () const

Static Public Member Functions

static bool DateFromString (Time &value, const UString &str)
static bool DateTimeFromString (Time &value, const UString &str)
static UString DateTimeToString (const Time &value)
static UString DateToString (const Time &value)
static const Attribute & INVALID ()
template<class Rep, class Period>
static bool TimeFromString (cn::duration< Rep, Period > &value, const UString &str)
template<class Rep, class Period>
static UString TimeToString (const cn::duration< Rep, Period > &value)

Detailed Description

Attribute of an XML element.

Constructor & Destructor Documentation

◆ Attribute() [1/2]

ts::xml::Attribute::Attribute ( )

Default constructor. The argument is initially invalid, everything will fail.

◆ Attribute() [2/2]

ts::xml::Attribute::Attribute ( const UString & name,
const UString & value = UString(),
size_t line = 0 )
explicit

Full constructor.

Parameters
[in]nameAttribute name.
[in]valueAttribute value.
[in]lineLine number in input document.

Member Function Documentation

◆ isValid()

bool ts::xml::Attribute::isValid ( ) const
inline

Check if the attribute is valid.

Returns
True if the attribute is valid.

◆ lineNumber()

size_t ts::xml::Attribute::lineNumber ( ) const
inline

Get the line number in input document.

Returns
The line number in input document, zero if the attribute was built programmatically.

◆ name()

const UString & ts::xml::Attribute::name ( ) const
inline

Get the attribute name.

Returns
A constant reference to the attribute name.

◆ nameMatch() [1/4]

bool ts::xml::Attribute::nameMatch ( const UChar * str) const
inline

Check if the name of the attribute matches a given value, case-insensitive.

Parameters
[in]strThe string value to compare.
Returns
True is the name of this object matches str.

◆ nameMatch() [2/4]

bool ts::xml::Attribute::nameMatch ( const UString & str) const
inline

Check if the name of the attribute matches a given value, case-insensitive.

Parameters
[in]strThe string value to compare.
Returns
True is the name of this object matches str.

◆ nameMatch() [3/4]

bool ts::xml::Attribute::nameMatch ( const UChar * str,
bool ignore_namespace ) const

Check if the name of the attribute matches a given value, case-insensitive.

Parameters
[in]strThe string value to compare.
[in]ignore_namespaceIf true, ignore namespaces in the comparison.
Returns
True is the name of this object matches str.

◆ nameMatch() [4/4]

bool ts::xml::Attribute::nameMatch ( const UString & str,
bool ignore_namespace ) const
inline

Check if the name of the attribute matches a given value, case-insensitive.

Parameters
[in]strThe string value to compare.
[in]ignore_namespaceIf true, ignore namespaces in the comparison.
Returns
True is the name of this object matches str.

◆ ignoreNamespace()

bool ts::xml::Attribute::ignoreNamespace ( ) const
inline

Check if namespace is ignored by default when comparing attribute names.

Returns
True if namespace is ignored by default.

◆ setIignoreNamespace()

void ts::xml::Attribute::setIignoreNamespace ( bool ignore)
inline

Specify if namespace is ignored by default when comparing attribute names.

Parameters
[in]ignoreIt true, namespace is ignored by default.

◆ value()

const UString & ts::xml::Attribute::value ( ) const
inline

Get the attribute value.

Returns
A constant reference to the attribute value.

◆ formattedValue()

const UString ts::xml::Attribute::formattedValue ( const Tweaks & tweaks) const

Get the formatted attribute value with quotes and escaped characters.

Parameters
[in]tweaksFormatting tweaks.
Returns
The formatted value of the attribute.

◆ sequence()

size_t ts::xml::Attribute::sequence ( ) const
inline

Get the update sequence number. Each time an attribute is updated, a global (non-thread-safe) index is incremented. The method returns the value of the global index the last time the attribute was modified. This is a way to rebuild the list of attributes in their order of modification.

Returns
The update sequence number.

◆ setString()

void ts::xml::Attribute::setString ( const UString & value)

Set a string attribute.

Parameters
[in]valueAttribute value.

◆ setBool()

void ts::xml::Attribute::setBool ( bool value)

Set a bool attribute to a node.

Parameters
[in]valueAttribute value.

◆ setInteger()

template<typename INT>
requires std::integral<INT>
void ts::xml::Attribute::setInteger ( INT value,
bool hexa = false )
inline

Set an attribute with an integer value to a node.

Template Parameters
INTAn integer type.
Parameters
[in]valueAttribute value.
[in]hexaIf true, use an hexadecimal representation. When decimal is used, a comma is used as thousands separator. When hexadecimal is used, a 0x prefix is added.

◆ setEnum()

template<typename INT>
requires ts::int_enum<INT>
void ts::xml::Attribute::setEnum ( const Names & definition,
INT value )
inline

Set an enumeration attribute of a node.

Template Parameters
INTAn integer or enum type.
Parameters
[in]definitionThe definition of enumeration values.
[in]valueAttribute value.

◆ setFloat()

template<typename FLT>
requires std::floating_point<FLT>
void ts::xml::Attribute::setFloat ( FLT value,
size_t width = 0,
size_t precision = 6,
bool force_sign = false )
inline

Set an attribute with a floating point value to a node.

Template Parameters
FLTa floating point type.
Parameters
[in]valueAttribute value.
[in]widthWidth of the formatted number, not including the optional prefix and separator.
[in]precisionPrecision to use after the decimal point. Default is 6 digits.
[in]force_signIf true, force a '+' sign for positive values.

◆ setDateTime()

void ts::xml::Attribute::setDateTime ( const Time & value)

Set a date/time attribute of an XML element.

Parameters
[in]valueAttribute value.

◆ setDate()

void ts::xml::Attribute::setDate ( const Time & value)

Set a date (without hours) attribute of an XML element.

Parameters
[in]valueAttribute value.

◆ setTime()

template<class Rep, class Period>
void ts::xml::Attribute::setTime ( const cn::duration< Rep, Period > & value)
inline

Set a time attribute of an XML element in "hh:mm:ss" format.

Parameters
[in]valueAttribute value.

◆ DateTimeToString()

UString ts::xml::Attribute::DateTimeToString ( const Time & value)
static

Convert a date/time into a string, as required in attributes.

Parameters
[in]valueTime value.
Returns
The corresponding string.

◆ DateToString()

UString ts::xml::Attribute::DateToString ( const Time & value)
static

Convert a date (without time) into a string, as required in attributes.

Parameters
[in]valueTime value.
Returns
The corresponding string.

◆ TimeToString()

template<class Rep, class Period>
UString ts::xml::Attribute::TimeToString ( const cn::duration< Rep, Period > & value)
static

Convert a time (without date) into a string, as required in attributes.

Parameters
[in]valueTime value.
Returns
The corresponding string.

◆ DateTimeFromString()

bool ts::xml::Attribute::DateTimeFromString ( Time & value,
const UString & str )
static

Convert a string into a date/time, as required in attributes.

Parameters
[in,out]valueTime value. Unmodified in case of error.
[in]strTime value as a string.
Returns
True on success, false on error.

◆ DateFromString()

bool ts::xml::Attribute::DateFromString ( Time & value,
const UString & str )
static

Convert a string into a date (without hours), as required in attributes.

Parameters
[in,out]valueDate value. Unmodified in case of error.
[in]strDate value as a string.
Returns
True on success, false on error.

◆ TimeFromString()

template<class Rep, class Period>
bool ts::xml::Attribute::TimeFromString ( cn::duration< Rep, Period > & value,
const UString & str )
static

Convert a string into a time, as required in attributes.

Parameters
[in,out]valueTime value. Unmodified in case of error.
[in]strTime value as a string.
Returns
True on success, false on error.

◆ expandEnvironment()

void ts::xml::Attribute::expandEnvironment ( )

Expand all environment variables in the attribute value. Environment variables are referenced using '${varname}' in text, attributes, names.

◆ INVALID()

const Attribute & ts::xml::Attribute::INVALID ( )
static

A constant static invalid instance. Used as universal invalid attribute.

Returns
A constant reference to the universal invalid attribute.

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