Serial-TCP/IPbridge  1.0
Typedefs | Functions
conversions.h File Reference

Various conversion functions for common usage - declarations. More...

#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <limits>

Go to the source code of this file.

Typedefs

typedef char * PtrToChar
 

Functions

template<typename T >
std::string toString (const T &value)
 Converts the selected value into a string. More...
 
template<>
std::string toString< bool > (const bool &value)
 Specialization for bool. More...
 
template<>
std::string toString< double > (const double &value)
 Specialization for double. More...
 
template<>
std::string toString< float > (const float &value)
 Specialization for float. More...
 
template<>
std::string toString< long double > (const long double &value)
 Specialization for long double. More...
 
template<>
std::string toString< std::string > (const std::string &value)
 Specialization for std::string. More...
 
template<>
std::string toString< PtrToChar > (const PtrToChar &value)
 Specialization for char *. More...
 
template<>
std::string toString< char > (const char &value)
 Specialization for char. More...
 
template<typename N >
bool strToNum (const std::string &str, N &number, std::ios_base &(*format)(std::ios_base &)=std::dec)
 Converts the selected string into a number. More...
 

Detailed Description

Various conversion functions for common usage - declarations.

Encoding: UTF-8 Project: Serial-TCP/IP bridge

Author
Petr Zemek, xzeme.nosp@m.k02@.nosp@m.stud..nosp@m.fit..nosp@m.vutbr.nosp@m..cz
Date
2009

Typedef Documentation

typedef char* PtrToChar

Function Documentation

template<typename N >
bool strToNum ( const std::string &  str,
N &  number,
std::ios_base &(*)(std::ios_base &)  format = std::dec 
)
inline

Converts the selected string into a number.

Parameters
strString that should be converted into a number.
numberInto this parameter the result number will be stored.
formatNumber format (e.g. std::dec, std::hex).
Returns
True if the conversion went ok, false otherwise.

If the conversion fails, number value will be left unchanged.

Referenced by Config::parseNumber().

template<typename T >
std::string toString ( const T &  value)
inline

Converts the selected value into a string.

Parameters
valueValue that should be converted into string

Referenced by Config::parseNumber().

template<>
std::string toString< bool > ( const bool &  value)
inline

Specialization for bool.

template<>
std::string toString< char > ( const char &  value)
inline

Specialization for char.

template<>
std::string toString< double > ( const double &  value)
inline

Specialization for double.

template<>
std::string toString< float > ( const float &  value)
inline

Specialization for float.

template<>
std::string toString< long double > ( const long double &  value)
inline

Specialization for long double.

template<>
std::string toString< PtrToChar > ( const PtrToChar value)
inline

Specialization for char *.

template<>
std::string toString< std::string > ( const std::string &  value)
inline

Specialization for std::string.