TSDuck Version 3.32-2769 (TSDuck - The MPEG Transport Stream Toolkit)
ts::ArgMix Class Reference

Base class for elements of an argument list with mixed types. More...

Inheritance diagram for ts::ArgMix:

Public Member Functions

 ArgMix (ArgMix &&other)
 Move constructor. More...
 
 ArgMix (const ArgMix &other)
 Copy constructor. More...
 
 ~ArgMix ()
 Destructor.
 
bool isAbstractNumber () const
 Check if the argument value is an AbstractNumber value, either input or output. More...
 
bool isAnyString () const
 Check if the argument value is a string of any type. More...
 
bool isAnyString16 () const
 Check if the argument value is a string of 16-bit characters. More...
 
bool isAnyString8 () const
 Check if the argument value is a string of 8-bit characters. More...
 
bool isBool () const
 Check if the argument value is a bool. More...
 
bool isCharPtr () const
 Check if the argument value is a char* string. More...
 
bool isDouble () const
 Check if the argument value is a double floating point value, either input or output. More...
 
bool isInteger () const
 Check if the argument value is an integer, either input or output. More...
 
bool isOutputInteger () const
 Check if the argument value is an output integer. More...
 
bool isSigned () const
 Check if the argument value is a signed integer, either input or output. More...
 
bool isString () const
 Check if the argument value is a std::string. More...
 
bool isUCharPtr () const
 Check if the argument value is a UChar* string. More...
 
bool isUnsigned () const
 Check if the argument value is an unsigned integer, either input or output. More...
 
bool isUString () const
 Check if the argument value is a ts::UString. More...
 
size_t size () const
 Get the original integer size in bytes of the argument data. More...
 
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. More...
 
const AbstractNumbertoAbstractNumber () const
 Get the argument data value as constant reference to an AbstractNumber instance. More...
 
bool toBool () const
 Get the argument data value as a bool. More...
 
const char * toCharPtr () const
 Get the argument data value as a nul-terminated string of 8-bit characters. More...
 
double toDouble () const
 Get the argument data value as a double floating point value. More...
 
int32_t toInt32 () const
 Get the argument data value as a 32-bit signed integer. More...
 
int64_t toInt64 () const
 Get the argument data value as a 64-bit signed integer. More...
 
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. More...
 
const std::string & toString () const
 Get the argument data value as constant reference to a C++ string of 8-bit characters. More...
 
const UChartoUCharPtr () const
 Get the argument data value as a nul-terminated string of 16-bit characters. More...
 
uint32_t toUInt32 () const
 Get the argument data value as a 32-bit unsigned integer. More...
 
uint64_t toUInt64 () const
 Get the argument data value as a 64-bit unsigned integer. More...
 
const UStringtoUString () const
 Get the argument data value as constant reference to a C++ string of 16-bit characters. More...
 

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,
  DOUBLE = 0x0800,
  ANUMBER = 0x1000
}
 Anonymous enum, used as bitmask. More...
 
typedef uint16_t TypeFlags
 Type of an argument, used as bitmask.
 

Protected Member Functions

 ArgMix ()
 Default constructor. More...
 
 ArgMix (TypeFlags type, size_t size, const Value value)
 Constructor for subclasses. More...
 

Detailed Description

Base class for elements of an argument list with mixed types.

This class is typically used as element in an std::initializer_list to build type-safe variable argument lists. Instances of ArgMix are directly built in the initializer list and cannot be copied or assigned.

This is a base class. It can be used only through the two derived classes ArgMixIn and ArgMixOut.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum : TypeFlags
protected

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.

DOUBLE 

Double floating point type.

ANUMBER 

A pointer to an AbstractNumber object.

Constructor & Destructor Documentation

◆ ArgMix() [1/4]

ts::ArgMix::ArgMix ( const ArgMix other)

Copy constructor.

Parameters
[in]otherOther instance to copy.

◆ ArgMix() [2/4]

ts::ArgMix::ArgMix ( ArgMix &&  other)

Move constructor.

Parameters
[in,out]otherOther instance to move.

◆ ArgMix() [3/4]

ts::ArgMix::ArgMix ( )
protected

Default constructor.

The argument does not represent anything.

◆ ArgMix() [4/4]

ts::ArgMix::ArgMix ( TypeFlags  type,
size_t  size,
const Value  value 
)
protected

Constructor for subclasses.

Parameters
[in]typeIndicate which overlay to use in _value.
[in]sizeOriginal size for integer type.
[in]valueActual value of the argument.

Member Function Documentation

◆ isInteger()

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

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
inline

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
inline

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
inline

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
inline

Check if the argument value is a bool.

Returns
True if the argument value is a bool.

◆ isAnyString()

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

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
inline

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
inline

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
inline

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
inline

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
inline

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
inline

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
inline

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
inline

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

Returns
True if the argument value is an AbstractNumber.

◆ size()

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

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 * = nullptr>
INT ts::ArgMix::toInteger ( bool  raw = false) const

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
inline

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
inline

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
inline

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
inline

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
inline

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

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

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

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

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

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

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

Returns
Reference to the AbstractNumber.

◆ storeInteger()

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

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.

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