Utilities

Detailed Description

The conversion utilities of the Platinum core library include functions to convert byte orders, to format and parse numbers, and to perform checked numeric conversions.

Basic application support is provided by the Pt::Arg class and the Pt::Settings class. The first one is a convenient way to parse and process program options and the latter one allows to load and store application settings in files or other places.

Two types are useful to get type information Pt::TypeTraits and Pt::TypeInfo. TypeTraits are used for generic programming, for example to deduce the pointer type in templated code, or to branch differently for const and non-const types. The TypeInfo class is a wrapper for std::type_info, which makes it easier to store and compare type information. The std::type_info is normally not copyable and comparable. Pt::SourceInfo is used to store information about a location in the source code.

Classes

class  Arg< T >
 Read and extract command-line options. More...
 
class  ConversionError
 Indicates a failed conversion. More...
 
class  NonCopyable
 Protects derived classes from being copied. More...
 
class  Settings
 Store application settings. More...
 
class  SettingsError
 Settings Format Error. More...
 
class  Singleton< T >
 Singleton class template More...
 
class  SourceInfo
 Source code info class. More...
 
class  TypeInfo
 Extended API for std::type_info. More...
 
struct  TypeTraits< T >
 Traits for type properties. More...
 

Functions

template<typename T >
beToHost (const T &value)
 Converts a value from big-endian to host-byteorder. More...
 
template<typename OutIterT , typename T , typename FormatT >
OutIterT formatFloat (OutIterT it, T d, const FormatT &fmt, int precision)
 Formats a floating point value in a given format.
 
template<typename OutIterT , typename T >
OutIterT formatFloat (OutIterT it, T d)
 Formats a floating point value in default format.
 
template<typename OutIterT , typename T , typename FormatT >
OutIterT formatInt (OutIterT it, T i, const FormatT &fmt)
 Formats an integer in a given format.
 
template<typename OutIterT , typename T >
OutIterT formatInt (OutIterT it, T i)
 Formats an integer in a decimal format.
 
template<typename CharT , typename T , typename FormatT >
CharT * formatInt (CharT *buf, std::size_t buflen, T si, const FormatT &fmt)
 Formats an integer in a given format.
 
template<typename T >
hostToBe (const T &value)
 Converts a value from the host-byteorder to big-endian. More...
 
template<typename T >
hostToLe (const T &value)
 Converts a value from host-byteorder to little-endian. More...
 
bool isBigEndian ()
 Returns true, if the cpu is big-endian (high-byte first).
 
bool isLittleEndian ()
 Returns true, if the cpu is little-endian (low-byte first).
 
template<typename T >
leToHost (const T &value)
 Converts a value from little-endian to host-byteorder. More...
 
template<typename R , typename T >
narrow (T from)
 Checked numeric conversion.
 
template<typename InIterT , typename T , typename FormatT >
InIterT parseFloat (InIterT it, InIterT end, T &n, const FormatT &fmt, bool &ok)
 Parses a floating point value in a given format.
 
template<typename InIterT , typename T , typename FormatT >
InIterT parseFloat (InIterT it, InIterT end, T &n, const FormatT &fmt)
 Parses a floating point value in a given format.
 
template<typename InIterT , typename T >
InIterT parseFloat (InIterT it, InIterT end, T &n, bool &ok)
 Parses a floating point value.
 
template<typename InIterT , typename T >
InIterT parseFloat (InIterT it, InIterT end, T &n)
 Parses a floating point value.
 
template<typename InIterT , typename T , typename FormatT >
InIterT parseInt (InIterT it, InIterT end, T &n, const FormatT &fmt, bool &ok)
 Parses an integer value in a given format.
 
template<typename InIterT , typename T , typename FormatT >
InIterT parseInt (InIterT it, InIterT end, T &n, const FormatT &fmt)
 Parses an integer value in a given format.
 
template<typename InIterT , typename T >
InIterT parseInt (InIterT it, InIterT end, T &n, bool &ok)
 Parses an integer value in decimal format.
 
template<typename InIterT , typename T >
InIterT parseInt (InIterT it, InIterT end, T &n)
 Parses an integer value in decimal format.
 
template<typename InIter , typename T >
parseInt (InIter it, InIter end)
 Parses an integer value in decimal format.
 
int8_t swab (int32_t value)
 Swaps the byteorder of an int32_t.
 
uint8_t swab (uint32_t value)
 Swaps the byteorder of a uint32_t.
 

Function Documentation

T Pt::hostToLe ( const T &  value)

This function does nothing on a LE system, but calls swap() on a BE system. The generic swap() function expects the type passed in to be an integer type and so does this function. Overloading swab can remove this restriction and may improve performance for custom types.

T Pt::leToHost ( const T &  value)

This function does nothing on a LE system, but calls swap() on a BE system. The generic swap() function expects the type passed in to be an integer type and so does this function. Overloading swab can remove this restriction and may improve performance for custom types.

T Pt::hostToBe ( const T &  value)

This function does nothing on a BE system, but calls swap() on a LE system. The generic swap() function expects the type passed in to be an integer type and so does this function. Overloading swab can remove this restriction and may improve performance for custom types.

T Pt::beToHost ( const T &  value)

This function does nothing on a BE system, but calls swap() on a LE system. The generic swap() function expects the type passed in to be an integer type and so does this function. Overloading swab can remove this restriction and may improve performance for custom types.