TSDuck v3.46-4965
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::IntegerMap< KEY, VALUE, NAMESFILE, KEYNAMESECTION > Class Template Reference

#include <tsIntegerMap.h>

Inheritance diagram for ts::IntegerMap< KEY, VALUE, NAMESFILE, KEYNAMESECTION >:
Collaboration diagram for ts::IntegerMap< KEY, VALUE, NAMESFILE, KEYNAMESECTION >:

Public Types

using SuperClass = std::map<KEY, VALUE>
 Identification of the superclass.

Public Member Functions

 IntegerMap ()
 Default constructor.
void accumulate (const IntegerMap &val)
void addKeys (json::Value &parent, const UString &path, bool ignore_empty) const
void addNormalizedKeys (std::ostream &stm, const UChar *type, bool ignore_empty) const
UString toNormalizedKeys () const
UString toStringKeys (VALUE total=0) const

Detailed Description

template<typename KEY, typename VALUE, const UChar * NAMESFILE = nullptr, const UChar * KEYNAMESECTION = nullptr>
requires std::integral<KEY> && std::integral<VALUE>
class ts::IntegerMap< KEY, VALUE, NAMESFILE, KEYNAMESECTION >

Generic map of integers, indexed by integer.

Template Parameters
KEYInteger type for keys.
VALUEInteger type for values.
NAMESFILEIf not null, names file containing KEYNAMESECTION.
KEYNAMESECTIONIf not null, name of the section which defines names for the keys in the map.

Member Function Documentation

◆ accumulate()

template<typename KEY, typename VALUE, const ts::UChar * NAMESFILE, const ts::UChar * KEYNAMESECTION>
requires std::integral<KEY> && std::integral<VALUE>
void ts::IntegerMap< KEY, VALUE, NAMESFILE, KEYNAMESECTION >::accumulate ( const IntegerMap< KEY, VALUE, NAMESFILE, KEYNAMESECTION > & val)

Accumulate all values from another map. Non-existent entries in this object are implicitely created.

Parameters
[in]valValue map to add.

◆ toStringKeys()

template<typename KEY, typename VALUE, const ts::UChar * NAMESFILE, const ts::UChar * KEYNAMESECTION>
requires std::integral<KEY> && std::integral<VALUE>
ts::UString ts::IntegerMap< KEY, VALUE, NAMESFILE, KEYNAMESECTION >::toStringKeys ( VALUE total = 0) const

Format a string for all keys in the map. Include percentages of values and key name.

Parameters
[in]totalTotal sum of values. Can be larger than the sum of values in the map. If zero, the total is computed from the map.
Returns
A string for all keys in the map.

◆ toNormalizedKeys()

template<typename KEY, typename VALUE, const ts::UChar * NAMESFILE, const ts::UChar * KEYNAMESECTION>
requires std::integral<KEY> && std::integral<VALUE>
ts::UString ts::IntegerMap< KEY, VALUE, NAMESFILE, KEYNAMESECTION >::toNormalizedKeys ( ) const

Build a string of all keys for "normalized" output in TSDuck.

Returns
"Normalized" string representing the keys in this object.

◆ addNormalizedKeys()

template<typename KEY, typename VALUE, const ts::UChar * NAMESFILE, const ts::UChar * KEYNAMESECTION>
requires std::integral<KEY> && std::integral<VALUE>
void ts::IntegerMap< KEY, VALUE, NAMESFILE, KEYNAMESECTION >::addNormalizedKeys ( std::ostream & stm,
const UChar * type,
bool ignore_empty ) const

Display a normalized representation of all keys in the map. When the value is displayed, it is followed by a column.

Parameters
[in,out]stmOutput stream on which the map is displayed.
[in]typeType of the entry, as in "type=1,2,7:"
[in]ignore_emptyIf true and the map is empty, display nothing.

◆ addKeys()

template<typename KEY, typename VALUE, const ts::UChar * NAMESFILE, const ts::UChar * KEYNAMESECTION>
requires std::integral<KEY> && std::integral<VALUE>
void ts::IntegerMap< KEY, VALUE, NAMESFILE, KEYNAMESECTION >::addKeys ( json::Value & parent,
const UString & path,
bool ignore_empty ) const

Add a list of all keys as a JSON array.

Parameters
[in,out]parentExisting JSON parent.
[in]pathPath to access or create under parent. The created node is a JSON array.
[in]ignore_emptyIf true and the map is empty, do nothing.

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