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

Define an element of an argument list with mixed integer and string input types. More...

#include <tsArgMix.h>

Inheritance diagram for ts::ArgMixIn:
Collaboration diagram for ts::ArgMixIn:

Public Member Functions

 ArgMixIn ()=default
 Default constructor.
 
 ArgMixIn (ArgMixIn &&other) noexcept
 Move constructor.
 
 ArgMixIn (bool b)
 Constructor from a bool.
 
 ArgMixIn (const AbstractNumber &s)
 Constructor from an AbstractNumber object.
 
 ArgMixIn (const ArgMixIn &other)
 Copy constructor.
 
 ArgMixIn (const char *s)
 Constructor from a nul-terminated string of 8-bit characters.
 
template<class Rep , class Period >
 ArgMixIn (const cn::duration< Rep, Period > &d)
 Constructor from a std::chrono::duration value.
 
 ArgMixIn (const fs::path &s)
 Constructor from a std::filesystem::path object.
 
 ArgMixIn (const std::string &s)
 Constructor from a C++ string of 8-bit characters.
 
 ArgMixIn (const StringifyInterface &s)
 Constructor from a stringifiable object.
 
 ArgMixIn (const UChar *s)
 Constructor from a nul-terminated string of 16-bit characters.
 
 ArgMixIn (const UString &s)
 Constructor from a C++ string of 16-bit characters.
 
 ArgMixIn (double d)
 Constructor from a double.
 
template<typename T , typename std::enable_if< std::is_integral< T >::value||std::is_enum< T >::value, int >::type = 0>
 ArgMixIn (T i)
 Constructor from an integer or enum type.
 
std::intmax_t den () const
 In the case of a std::chrono::duration value, return the denominator of the ratio.
 
bool isAbstractNumber () const
 Check if the argument value is an AbstractNumber value, either input or output.
 
bool isAnyString () const
 Check if the argument value is a string of any type.
 
bool isAnyString16 () const
 Check if the argument value is a string of 16-bit characters.
 
bool isAnyString8 () const
 Check if the argument value is a string of 8-bit characters.
 
bool isBool () const
 Check if the argument value is a bool.
 
bool isCharPtr () const
 Check if the argument value is a char* string.
 
bool isChrono () const
 Check if the argument value is a std::chrono::duration value.
 
bool isDouble () const
 Check if the argument value is a double floating point value, either input or output.
 
bool isInteger () const
 Check if the argument value is an integer, either input or output.
 
bool isOutputInteger () const
 Check if the argument value is an output integer.
 
bool isSigned () const
 Check if the argument value is a signed integer, either input or output.
 
bool isString () const
 Check if the argument value is a std::string.
 
bool isUCharPtr () const
 Check if the argument value is a UChar* string.
 
bool isUnsigned () const
 Check if the argument value is an unsigned integer, either input or output.
 
bool isUString () const
 Check if the argument value is a ts::UString.
 
std::intmax_t num () const
 In the case of a std::chrono::duration value, return the numerator of the ratio.
 
size_t size () const
 Get the original integer size in bytes of the argument data.
 
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr>
bool storeInteger (INT i) const
 Store an integer value in the argument data, for pointers to integer.
 
const AbstractNumbertoAbstractNumber () const
 Get the argument data value as constant reference to an AbstractNumber instance.
 
bool toBool () const
 Get the argument data value as a bool.
 
const char * toCharPtr () const
 Get the argument data value as a nul-terminated string of 8-bit characters.
 
double toDouble () const
 Get the argument data value as a double floating point value.
 
int32_t toInt32 () const
 Get the argument data value as a 32-bit signed integer.
 
int64_t toInt64 () const
 Get the argument data value as a 64-bit signed integer.
 
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr>
INT toInteger (bool raw=false) const
 Get the argument data value as an integer.
 
const std::string & toString () const
 Get the argument data value as constant reference to a C++ string of 8-bit characters.
 
const UChartoUCharPtr () const
 Get the argument data value as a nul-terminated string of 16-bit characters.
 
uint32_t toUInt32 () const
 Get the argument data value as a 32-bit unsigned integer.
 
uint64_t toUInt64 () const
 Get the argument data value as a 64-bit unsigned integer.
 
const UStringtoUString () const
 Get the argument data value as constant reference to a C++ string of 16-bit characters.
 

Protected Types

enum  : TypeFlags {
  INTEGER = 0x0001 ,
  SIGNED = 0x0002 ,
  STRING = 0x0004 ,
  CLASS = 0x0008 ,
  BIT1 = 0x0010 ,
  BIT8 = 0x0020 ,
  BIT16 = 0x0040 ,
  BIT32 = 0x0080 ,
  BIT64 = 0x0100 ,
  POINTER = 0x0200 ,
  STRINGIFY = 0x0400 ,
  PATH = 0x0800 ,
  DOUBLE = 0x1000 ,
  ANUMBER = 0x2000 ,
  CHRONO = 0x4000
}
 Anonymous enum, used as bitmask. More...
 
using TypeFlags = uint16_t
 Type of an argument, used as bitmask.
 

Static Protected Attributes

static constexpr TypeFlags BITPATH
 Size flag for std::filesystem::path, either BIT8 or BIT16.
 

Detailed Description

Define an element of an argument list with mixed integer and string input types.

This class is typically used as element in an std::initializer_list. This mechanism is used by ts::UString::Format() for instance.

An instance of ArgMixIn may reference external data. The lifetime of the pointed data must be longer than the ArgMixIn instance. This is the case for a std::initializer_list<ArgMixIn> which is used as parameter to Format(). But this is not guaranteed in other usages.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum : TypeFlags
protectedinherited

Anonymous enum, used as bitmask.

Enumerator
INTEGER 

Integer type.

SIGNED 

With INTEGER, 1 means signed, 0 means unsigned.

STRING 

String of characters.

CLASS 

With STRING, 1 means std::string or ts::UString, O means const char* or const UChar*.

BIT1 

1-bit integer, ie. bool.

BIT8 

8-bit integer or string of 8-bit characters (char).

BIT16 

16-bit integer or string of 16-bit characters (UChar).

BIT32 

32-bit integer.

BIT64 

64-bit integer.

POINTER 

A pointer to a writeable data (data type is given by other bits).

STRINGIFY 

A pointer to a StringifyInterface object.

PATH 

A pointer to a StringifyInterface object.

DOUBLE 

Double floating point type.

ANUMBER 

A pointer to an AbstractNumber object.

CHRONO 

A instance of std::chrono::duration.

Constructor & Destructor Documentation

◆ ArgMixIn() [1/13]

ts::ArgMixIn::ArgMixIn ( const ArgMixIn other)
inline

Copy constructor.

Parameters
[in]otherOther instance to copy.

◆ ArgMixIn() [2/13]

ts::ArgMixIn::ArgMixIn ( ArgMixIn &&  other)
inlinenoexcept

Move constructor.

Parameters
[in,out]otherOther instance to move.

◆ ArgMixIn() [3/13]

ts::ArgMixIn::ArgMixIn ( const char *  s)
inline

Constructor from a nul-terminated string of 8-bit characters.

Parameters
[in]sAddress of nul-terminated string.

◆ ArgMixIn() [4/13]

ts::ArgMixIn::ArgMixIn ( const UChar s)
inline

Constructor from a nul-terminated string of 16-bit characters.

Parameters
[in]sAddress of nul-terminated string.

◆ ArgMixIn() [5/13]

ts::ArgMixIn::ArgMixIn ( const std::string &  s)
inline

Constructor from a C++ string of 8-bit characters.

Parameters
[in]sReference to a C++ string.

◆ ArgMixIn() [6/13]

ts::ArgMixIn::ArgMixIn ( const UString s)
inline

Constructor from a C++ string of 16-bit characters.

Parameters
[in]sReference to a C++ string.

◆ ArgMixIn() [7/13]

ts::ArgMixIn::ArgMixIn ( const StringifyInterface s)
inline

Constructor from a stringifiable object.

Parameters
[in]sReference to a stringifiable object.

◆ ArgMixIn() [8/13]

ts::ArgMixIn::ArgMixIn ( const fs::path &  s)
inline

Constructor from a std::filesystem::path object.

Parameters
[in]sReference to a path object.

◆ ArgMixIn() [9/13]

ts::ArgMixIn::ArgMixIn ( const AbstractNumber s)
inline

Constructor from an AbstractNumber object.

Parameters
[in]sReference to an AbstractNumber object.

◆ ArgMixIn() [10/13]

ts::ArgMixIn::ArgMixIn ( bool  b)
inline

Constructor from a bool.

Parameters
[in]bBoolean value.

◆ ArgMixIn() [11/13]

ts::ArgMixIn::ArgMixIn ( double  d)
inline

Constructor from a double.

Parameters
[in]ddouble value.

◆ ArgMixIn() [12/13]

template<typename T , typename std::enable_if< std::is_integral< T >::value||std::is_enum< T >::value, int >::type = 0>
ts::ArgMixIn::ArgMixIn ( i)
inline

Constructor from an integer or enum type.

Parameters
[in]iInteger value of the ArgMix. Internally stored as a 32-bit or 64-bit integer.

◆ ArgMixIn() [13/13]

template<class Rep , class Period >
ts::ArgMixIn::ArgMixIn ( const cn::duration< Rep, Period > &  d)
inline

Constructor from a std::chrono::duration value.

Parameters
[in]dA std::chrono::duration value.

Member Function Documentation

◆ isInteger()

bool ts::ArgMix::isInteger ( ) const
inlineinherited

Check if the argument value is an integer, either input or output.

Returns
True if the argument value is an integer.

◆ isOutputInteger()

bool ts::ArgMix::isOutputInteger ( ) const
inlineinherited

Check if the argument value is an output integer.

Returns
True if the argument value is an output integer.

◆ isSigned()

bool ts::ArgMix::isSigned ( ) const
inlineinherited

Check if the argument value is a signed integer, either input or output.

Returns
True if the argument value is a signed integer.

◆ isUnsigned()

bool ts::ArgMix::isUnsigned ( ) const
inlineinherited

Check if the argument value is an unsigned integer, either input or output.

Returns
True if the argument value is an unsigned integer.

◆ isBool()

bool ts::ArgMix::isBool ( ) const
inlineinherited

Check if the argument value is a bool.

Returns
True if the argument value is a bool.

◆ isAnyString()

bool ts::ArgMix::isAnyString ( ) const
inlineinherited

Check if the argument value is a string of any type.

Returns
True if the argument value is a string.

◆ isAnyString8()

bool ts::ArgMix::isAnyString8 ( ) const
inlineinherited

Check if the argument value is a string of 8-bit characters.

Returns
True if the argument value is a string of 8-bit characters (char* or std::string).

◆ isAnyString16()

bool ts::ArgMix::isAnyString16 ( ) const
inlineinherited

Check if the argument value is a string of 16-bit characters.

Returns
True if the argument value is a string of 16-bit characters (UChar* or ts::UString).

◆ isCharPtr()

bool ts::ArgMix::isCharPtr ( ) const
inlineinherited

Check if the argument value is a char* string.

Returns
True if the argument value is a char* string.

◆ isString()

bool ts::ArgMix::isString ( ) const
inlineinherited

Check if the argument value is a std::string.

Returns
True if the argument value is a std::string.

◆ isUCharPtr()

bool ts::ArgMix::isUCharPtr ( ) const
inlineinherited

Check if the argument value is a UChar* string.

Returns
True if the argument value is a UChar* string.

◆ isUString()

bool ts::ArgMix::isUString ( ) const
inlineinherited

Check if the argument value is a ts::UString.

Returns
True if the argument value is a ts::UString.

◆ isDouble()

bool ts::ArgMix::isDouble ( ) const
inlineinherited

Check if the argument value is a double floating point value, either input or output.

Returns
True if the argument value is a double.

◆ isAbstractNumber()

bool ts::ArgMix::isAbstractNumber ( ) const
inlineinherited

Check if the argument value is an AbstractNumber value, either input or output.

Returns
True if the argument value is an AbstractNumber.

◆ isChrono()

bool ts::ArgMix::isChrono ( ) const
inlineinherited

Check if the argument value is a std::chrono::duration value.

Returns
True if the argument value is a std::chrono::duration value.

◆ size()

size_t ts::ArgMix::size ( ) const
inlineinherited

Get the original integer size in bytes of the argument data.

Returns
The original integer size in bytes of the argument data or zero for a string or double.

◆ toInteger()

template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * >
INT ts::ArgMix::toInteger ( bool  raw = false) const
inherited

Get the argument data value as an integer.

Template Parameters
INTAn integer type.
Parameters
[in]rawIn the case of fixed-point value, return the integral part when false (the default) and the raw value if true. Ignored for plain integer types.
Returns
The argument data as an integer value of type INT or zero for a string or double.

◆ toInt32()

int32_t ts::ArgMix::toInt32 ( ) const
inlineinherited

Get the argument data value as a 32-bit signed integer.

Returns
The argument data as an integer value or zero for a string or double.

◆ toUInt32()

uint32_t ts::ArgMix::toUInt32 ( ) const
inlineinherited

Get the argument data value as a 32-bit unsigned integer.

Returns
The argument data as an integer value or zero for a string or double.

◆ toInt64()

int64_t ts::ArgMix::toInt64 ( ) const
inlineinherited

Get the argument data value as a 64-bit signed integer.

Returns
The argument data as an integer value or zero for a string or double.

◆ toUInt64()

uint64_t ts::ArgMix::toUInt64 ( ) const
inlineinherited

Get the argument data value as a 64-bit unsigned integer.

Returns
The argument data as an integer value or zero for a string or double.

◆ toBool()

bool ts::ArgMix::toBool ( ) const
inlineinherited

Get the argument data value as a bool.

Returns
The argument data as a bool value or false for a string or double.

◆ toCharPtr()

const char * ts::ArgMix::toCharPtr ( ) const
inherited

Get the argument data value as a nul-terminated string of 8-bit characters.

Returns
Address of the nul-terminated string for CHARPTR or STRING, an empty string for other data types.

◆ toUCharPtr()

const UChar * ts::ArgMix::toUCharPtr ( ) const
inherited

Get the argument data value as a nul-terminated string of 16-bit characters.

Returns
Address of the nul-terminated string for UCHARPTR or USTRING, an empty string for other data types.

◆ toString()

const std::string & ts::ArgMix::toString ( ) const
inherited

Get the argument data value as constant reference to a C++ string of 8-bit characters.

Returns
Reference to the string for STRING, to an empty string for other data types.

◆ toUString()

const UString & ts::ArgMix::toUString ( ) const
inherited

Get the argument data value as constant reference to a C++ string of 16-bit characters.

Returns
Reference to the string for USTRING, to an empty string for other data types.

◆ toDouble()

double ts::ArgMix::toDouble ( ) const
inherited

Get the argument data value as a double floating point value.

Returns
The argument data as a double or zero for a string. Integers are converted to double.

◆ toAbstractNumber()

const AbstractNumber & ts::ArgMix::toAbstractNumber ( ) const
inherited

Get the argument data value as constant reference to an AbstractNumber instance.

Returns
Reference to the AbstractNumber.

◆ num()

std::intmax_t ts::ArgMix::num ( ) const
inlineinherited

In the case of a std::chrono::duration value, return the numerator of the ratio.

The chrono count is obtained using tsInt64().

Returns
The numerator of the ratio for a std::chrono::duration value, zero otherwise.

◆ den()

std::intmax_t ts::ArgMix::den ( ) const
inlineinherited

In the case of a std::chrono::duration value, return the denominator of the ratio.

The chrono count is obtained using tsInt64().

Returns
The denominator of the ratio for a std::chrono::duration value, zero otherwise.

◆ storeInteger()

template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * >
bool ts::ArgMix::storeInteger ( INT  i) const
inherited

Store an integer value in the argument data, for pointers to integer.

Template Parameters
INTAn integer type.
Parameters
[in]iThe integer value to store in the argument data.
Returns
True on success, false if the argument data is not a pointer to integer.

Member Data Documentation

◆ BITPATH

constexpr TypeFlags ts::ArgMix::BITPATH
staticconstexprprotectedinherited
Initial value:
=
@ BIT16
16-bit integer or string of 16-bit characters (UChar).
Definition tsArgMix.h:264

Size flag for std::filesystem::path, either BIT8 or BIT16.


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