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

Representation of a "configuration section". More...

#include <tsConfigSection.h>

Public Member Functions

 ConfigSection ()=default
 Constructor.
 
void append (const UString &entry, bool val)
 Append a boolean value to an entry.
 
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr>
void append (const UString &entry, const INT &val)
 Append an integer value to an entry.
 
void append (const UString &entry, const std::vector< bool > &val)
 Append a vector of booleans to an entry.
 
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr>
void append (const UString &entry, const std::vector< INT > &val)
 Append a vector of integers to an entry.
 
void append (const UString &entry, const UChar *val)
 Append a string value to an entry.
 
void append (const UString &entry, const UString &val)
 Append a string value to an entry.
 
void append (const UString &entry, const UStringVector &val)
 Append a vector of strings to an entry.
 
bool boolValue (const UString &entry, size_t index=0, bool defvalue=false) const
 Get a boolean value in an entry.
 
void deleteEntry (const UString &entry)
 Delete an entry.
 
size_t entryCount () const
 Get the number of entries in the section.
 
void getEntryNames (UStringVector &names) const
 Get the names of all entries in the section.
 
void reset ()
 Reset content of the section.
 
std::ostream & save (std::ostream &strm) const
 Save the content of the section in a text streams.
 
void set (const UString &entry, bool val)
 Set the boolean value of an entry.
 
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr>
void set (const UString &entry, const INT &val)
 Set the integer value of an entry.
 
void set (const UString &entry, const std::vector< bool > &val)
 Set the value of an entry from a vector of booleans.
 
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr>
void set (const UString &entry, const std::vector< INT > &val)
 Set the value of an entry from a vector of integers.
 
void set (const UString &entry, const UChar *val)
 Set the string value of an entry.
 
void set (const UString &entry, const UString &val)
 Set the string value of an entry.
 
void set (const UString &entry, const UStringVector &val)
 Set the value of an entry from a vector of strings.
 
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr>
INT value (const UString &entry, size_t index=0, const INT &defvalue=static_cast< INT >(0)) const
 Get an integer value in an entry.
 
UString value (const UString &entry, size_t index=0, const UString &defvalue=UString()) const
 Get a value in an entry.
 
size_t valueCount (const UString &entry) const
 Get the number of values in an entry.
 

Detailed Description

Representation of a "configuration section".

A configuration section contains a list of "entries". Each entry has one or more values. A value can be interpreted as a string, integer or boolean.

Member Function Documentation

◆ entryCount()

size_t ts::ConfigSection::entryCount ( ) const
inline

Get the number of entries in the section.

Returns
The number of entries in the section.

◆ getEntryNames()

void ts::ConfigSection::getEntryNames ( UStringVector names) const

Get the names of all entries in the section.

Parameters
[out]namesThe returned names of all entries in the section.

◆ valueCount()

size_t ts::ConfigSection::valueCount ( const UString entry) const

Get the number of values in an entry.

Parameters
[in]entryEntry name.
Returns
The number of values in entry or 0 if the entry does not exist.

◆ value() [1/2]

UString ts::ConfigSection::value ( const UString entry,
size_t  index = 0,
const UString defvalue = UString() 
) const

Get a value in an entry.

Parameters
[in]entryEntry name.
[in]indexIndex of the value in the entry.
[in]defvalueDefault value.
Returns
The value in the entry or defvalue if entry does not exist, or if index is out of range

◆ value() [2/2]

template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * >
INT ts::ConfigSection::value ( const UString entry,
size_t  index = 0,
const INT defvalue = static_cast<INT>(0) 
) const

Get an integer value in an entry.

Template Parameters
INTAn integer type.
Parameters
[in]entryEntry name.
[in]indexIndex of the value in the entry.
[in]defvalueDefault value.
Returns
The value in the entry or defvalue if entry does not exist, or if index is out of range.

◆ boolValue()

bool ts::ConfigSection::boolValue ( const UString entry,
size_t  index = 0,
bool  defvalue = false 
) const

Get a boolean value in an entry.

Parameters
[in]entryEntry name.
[in]indexIndex of the value in the entry.
[in]defvalueDefault value.
Returns
The value in the entry or defvalue if entry does not exist, or if index is out of range, or if the value cannot be interpreted as a boolean. Valid boolean representations are "true" / "yes" / "1" and "false" / "no" / "0".

◆ deleteEntry()

void ts::ConfigSection::deleteEntry ( const UString entry)
inline

Delete an entry.

Parameters
[in]entryEntry name.

◆ set() [1/7]

void ts::ConfigSection::set ( const UString entry,
const UString val 
)

Set the string value of an entry.

Parameters
[in]entryEntry name.
[in]valThe value to set.

◆ set() [2/7]

void ts::ConfigSection::set ( const UString entry,
const UChar val 
)
inline

Set the string value of an entry.

Parameters
[in]entryEntry name.
[in]valThe value to set.

◆ set() [3/7]

void ts::ConfigSection::set ( const UString entry,
const UStringVector val 
)

Set the value of an entry from a vector of strings.

Parameters
[in]entryEntry name.
[in]valThe values to set.

◆ set() [4/7]

void ts::ConfigSection::set ( const UString entry,
bool  val 
)

Set the boolean value of an entry.

Parameters
[in]entryEntry name.
[in]valThe value to set.

◆ set() [5/7]

void ts::ConfigSection::set ( const UString entry,
const std::vector< bool > &  val 
)

Set the value of an entry from a vector of booleans.

Parameters
[in]entryEntry name.
[in]valThe values to set.

◆ set() [6/7]

template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr>
void ts::ConfigSection::set ( const UString entry,
const INT val 
)
inline

Set the integer value of an entry.

Template Parameters
INTAn integer type.
Parameters
[in]entryEntry name.
[in]valThe value to set.

◆ set() [7/7]

template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * >
void ts::ConfigSection::set ( const UString entry,
const std::vector< INT > &  val 
)

Set the value of an entry from a vector of integers.

Template Parameters
INTAn integer type.
Parameters
[in]entryEntry name.
[in]valThe values to set.

◆ append() [1/7]

void ts::ConfigSection::append ( const UString entry,
const UString val 
)

Append a string value to an entry.

Parameters
[in]entryEntry name.
[in]valThe value to set.

◆ append() [2/7]

void ts::ConfigSection::append ( const UString entry,
const UChar val 
)
inline

Append a string value to an entry.

Parameters
[in]entryEntry name.
[in]valThe value to set.

◆ append() [3/7]

void ts::ConfigSection::append ( const UString entry,
const UStringVector val 
)

Append a vector of strings to an entry.

Parameters
[in]entryEntry name.
[in]valThe values to append.

◆ append() [4/7]

void ts::ConfigSection::append ( const UString entry,
bool  val 
)

Append a boolean value to an entry.

Parameters
[in]entryEntry name.
[in]valThe value to append.

◆ append() [5/7]

void ts::ConfigSection::append ( const UString entry,
const std::vector< bool > &  val 
)

Append a vector of booleans to an entry.

Parameters
[in]entryEntry name.
[in]valThe values to append.

◆ append() [6/7]

template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * >
void ts::ConfigSection::append ( const UString entry,
const INT val 
)

Append an integer value to an entry.

Template Parameters
INTAn integer type.
Parameters
[in]entryEntry name.
[in]valThe value to append.

◆ append() [7/7]

template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * >
void ts::ConfigSection::append ( const UString entry,
const std::vector< INT > &  val 
)

Append a vector of integers to an entry.

Template Parameters
INTAn integer type.
Parameters
[in]entryEntry name.
[in]valThe values to append.

◆ save()

std::ostream & ts::ConfigSection::save ( std::ostream &  strm) const

Save the content of the section in a text streams.

Parameters
[in,out]strmAn standard stream in output mode.
Returns
A reference to the strm object.

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