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

Generic map of integers, indexed by integer. More...

#include <tsIntegerMap.h>

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

Public Types

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

Public Member Functions

 IntegerMap ()
 Default constructor.
 
void accumulate (const IntegerMap &val)
 Accumulate all values from another map.
 
void addKeys (json::Value &parent, const UString &path, bool ignore_empty) const
 Add a list of all keys as a JSON array.
 
void addNormalizedKeys (std::ostream &stm, const UChar *type, bool ignore_empty) const
 Display a normalized representation of all keys in the map.
 
UString toNormalizedKeys () const
 Build a string of all keys for "normalized" output in TSDuck.
 
UString toStringKeys (VALUE total=0) const
 Format a string for all keys in the map.
 

Static Public Attributes

static const UStringKEY_NAMES_SECTION
 Name of the section which define names for the keys in the map.
 

Detailed Description

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

Generic map of integers, indexed by integer.

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

Member Function Documentation

◆ accumulate()

template<typename KEY , typename VALUE , const ts::UString * KEYNAMESECTION, ts::NamesFile::Predefined NAMESFILE>
requires std::integral<KEY> && std::integral<VALUE>
void ts::IntegerMap< KEY, VALUE, KEYNAMESECTION, NAMESFILE >::accumulate ( const IntegerMap< KEY, VALUE, KEYNAMESECTION, NAMESFILE > &  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::UString * KEYNAMESECTION, ts::NamesFile::Predefined NAMESFILE>
requires std::integral<KEY> && std::integral<VALUE>
ts::UString ts::IntegerMap< KEY, VALUE, KEYNAMESECTION, NAMESFILE >::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::UString * KEYNAMESECTION, ts::NamesFile::Predefined NAMESFILE>
requires std::integral<KEY> && std::integral<VALUE>
ts::UString ts::IntegerMap< KEY, VALUE, KEYNAMESECTION, NAMESFILE >::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::UString * KEYNAMESECTION, ts::NamesFile::Predefined NAMESFILE>
requires std::integral<KEY> && std::integral<VALUE>
void ts::IntegerMap< KEY, VALUE, KEYNAMESECTION, NAMESFILE >::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::UString * KEYNAMESECTION, ts::NamesFile::Predefined NAMESFILE>
requires std::integral<KEY> && std::integral<VALUE>
void ts::IntegerMap< KEY, VALUE, KEYNAMESECTION, NAMESFILE >::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: