Attribute of an XML element.
More...
#include <tsxmlAttribute.h>
|
| Attribute () |
| Default constructor.
|
|
| Attribute (const UString &name, const UString &value=UString(), size_t line=0) |
| Full constructor.
|
|
const UString | formattedValue (const Tweaks &tweaks) const |
| Get the formatted attribute value with quotes and escaped characters.
|
|
bool | isValid () const |
| Check if the attribute is valid.
|
|
size_t | lineNumber () const |
| Get the line number in input document.
|
|
const UString & | name () const |
| Get the attribute name with original case sensitivity.
|
|
size_t | sequence () const |
| Get the update sequence number.
|
|
void | setBool (bool value) |
| Set a bool attribute to a node.
|
|
void | setDate (const Time &value) |
| Set a date (without hours) attribute of an XML element.
|
|
void | setDateTime (const Time &value) |
| Set a date/time attribute of an XML element.
|
|
void | setEnum (const Enumeration &definition, int value) |
| Set an enumeration attribute of a node.
|
|
template<typename FLT , typename std::enable_if< std::is_floating_point< FLT >::value >::type * = nullptr> |
void | setFloat (FLT value, size_t width=0, size_t precision=6, bool force_sign=false) |
| Set an attribute with a floating point value to a node.
|
|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr> |
void | setInteger (INT value, bool hexa=false) |
| Set an attribute with an integer value to a node.
|
|
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr> |
void | setIntEnum (const Enumeration &definition, INT value) |
| Set an enumeration attribute of a node.
|
|
void | setString (const UString &value) |
| Set a string attribute.
|
|
template<class Rep , class Period > |
void | setTime (const cn::duration< Rep, Period > &value) |
| Set a time attribute of an XML element in "hh:mm:ss" format.
|
|
const UString & | value () const |
| Get the attribute value.
|
|
|
static bool | DateFromString (Time &value, const UString &str) |
| Convert a string into a date (without hours), as required in attributes.
|
|
static bool | DateTimeFromString (Time &value, const UString &str) |
| Convert a string into a date/time, as required in attributes.
|
|
static UString | DateTimeToString (const Time &value) |
| Convert a date/time into a string, as required in attributes.
|
|
static UString | DateToString (const Time &value) |
| Convert a date (without time) into a string, as required in attributes.
|
|
template<class Rep , class Period > |
static bool | TimeFromString (cn::duration< Rep, Period > &value, const UString &str) |
| Convert a string into a time, as required in attributes.
|
|
template<class Rep , class Period > |
static UString | TimeToString (const cn::duration< Rep, Period > &value) |
| Convert a time (without date) into a string, as required in attributes.
|
|
Attribute of an XML element.
◆ 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] | name | Attribute name with original case sensitivity. |
[in] | value | Attribute value. |
[in] | line | Line number in input document. |
◆ 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 with original case sensitivity.
- Returns
- A constant reference to the attribute name with original case sensitivity.
◆ 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] | tweaks | Formatting 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
-
◆ setBool()
void ts::xml::Attribute::setBool |
( |
bool |
value | ) |
|
Set a bool attribute to a node.
- Parameters
-
◆ setInteger()
template<typename
INT , typename std::enable_if< std::is_integral<
INT >
::value >::type * = nullptr>
void ts::xml::Attribute::setInteger |
( |
INT |
value, |
|
|
bool |
hexa = false |
|
) |
| |
|
inline |
Set an attribute with an integer value to a node.
- Template Parameters
-
- Parameters
-
[in] | value | Attribute value. |
[in] | hexa | If 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()
void ts::xml::Attribute::setEnum |
( |
const Enumeration & |
definition, |
|
|
int |
value |
|
) |
| |
Set an enumeration attribute of a node.
- Parameters
-
[in] | definition | The definition of enumeration values. |
[in] | value | Attribute value. |
◆ setIntEnum()
template<typename
INT , typename std::enable_if< std::is_integral<
INT >
::value >::type * = nullptr>
void ts::xml::Attribute::setIntEnum |
( |
const Enumeration & |
definition, |
|
|
INT |
value |
|
) |
| |
|
inline |
Set an enumeration attribute of a node.
- Template Parameters
-
- Parameters
-
[in] | definition | The definition of enumeration values. |
[in] | value | Attribute value. |
◆ setFloat()
template<typename FLT , typename std::enable_if< std::is_floating_point< FLT >
::value >::type * = nullptr>
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
-
FLT | a floating point type. |
- Parameters
-
[in] | value | Attribute value. |
[in] | width | Width of the formatted number, not including the optional prefix and separator. |
[in] | precision | Precision to use after the decimal point. Default is 6 digits. |
[in] | force_sign | If 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
-
◆ setDate()
void ts::xml::Attribute::setDate |
( |
const Time & |
value | ) |
|
Set a date (without hours) attribute of an XML element.
- Parameters
-
◆ 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
-
◆ DateTimeToString()
static UString ts::xml::Attribute::DateTimeToString |
( |
const Time & |
value | ) |
|
|
static |
Convert a date/time into a string, as required in attributes.
- Parameters
-
- Returns
- The corresponding string.
◆ DateToString()
static UString ts::xml::Attribute::DateToString |
( |
const Time & |
value | ) |
|
|
static |
Convert a date (without time) into a string, as required in attributes.
- Parameters
-
- Returns
- The corresponding string.
◆ TimeToString()
template<class Rep , class Period >
static 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
-
- Returns
- The corresponding string.
◆ DateTimeFromString()
static 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] | value | Time value. Unmodified in case of error. |
[in] | str | Time value as a string. |
- Returns
- True on success, false on error.
◆ DateFromString()
static 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] | value | Date value. Unmodified in case of error. |
[in] | str | Date 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] | value | Time value. Unmodified in case of error. |
[in] | str | Time value as a string. |
- Returns
- True on success, false on error.
◆ INVALID
A constant static invalid instance.
Used as universal invalid attribute.
The documentation for this class was generated from the following file: