ALPSCore reference
Classes | Namespaces | Macros | Functions
cast.hpp File Reference
#include <alps/config.hpp>
#include <alps/utilities/stacktrace.hpp>
#include <boost/bind.hpp>
#include <string>
#include <complex>
#include <typeinfo>
#include <type_traits>
#include <algorithm>
#include <stdexcept>
#include <cstdio>
Include dependency graph for cast.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  alps::bad_cast
 
struct  alps::cast_hook< U, T >
 
struct  alps::cast_hook< std::string, short >
 
struct  alps::cast_hook< short, std::string >
 
struct  alps::cast_hook< std::string, int >
 
struct  alps::cast_hook< int, std::string >
 
struct  alps::cast_hook< std::string, long >
 
struct  alps::cast_hook< long, std::string >
 
struct  alps::cast_hook< std::string, unsigned short >
 
struct  alps::cast_hook< unsigned short, std::string >
 
struct  alps::cast_hook< std::string, unsigned int >
 
struct  alps::cast_hook< unsigned int, std::string >
 
struct  alps::cast_hook< std::string, unsigned long >
 
struct  alps::cast_hook< unsigned long, std::string >
 
struct  alps::cast_hook< std::string, float >
 
struct  alps::cast_hook< float, std::string >
 
struct  alps::cast_hook< std::string, double >
 
struct  alps::cast_hook< double, std::string >
 
struct  alps::cast_hook< std::string, long double >
 
struct  alps::cast_hook< long double, std::string >
 
struct  alps::cast_hook< std::string, long long >
 
struct  alps::cast_hook< long long, std::string >
 
struct  alps::cast_hook< std::string, unsigned long long >
 
struct  alps::cast_hook< unsigned long long, std::string >
 
struct  alps::cast_hook< std::string, bool >
 
struct  alps::cast_hook< bool, std::string >
 
struct  alps::cast_hook< std::string, char >
 
struct  alps::cast_hook< char, std::string >
 
struct  alps::cast_hook< std::string, signed char >
 
struct  alps::cast_hook< signed char, std::string >
 
struct  alps::cast_hook< std::string, unsigned char >
 
struct  alps::cast_hook< unsigned char, std::string >
 
struct  alps::cast_hook< U, std::complex< T > >
 
struct  alps::cast_hook< std::complex< U >, T >
 
struct  alps::cast_hook< std::complex< U >, std::complex< T > >
 
struct  alps::cast_hook< std::string, std::complex< T > >
 
struct  alps::cast_hook< std::complex< T >, std::string >
 

Namespaces

 alps
 

Macros

#define ALPS_CAST_STRING(T, p, c)
 
#define ALPS_CAST_STRING_CHAR(T, U)
 

Functions

template<typename U , typename T >
alps::cast (T const &)
 
template<typename U , typename T >
void alps::cast (U const *src, U const *end, T *dest)
 

Macro Definition Documentation

#define ALPS_CAST_STRING (   T,
  p,
 
)
Value:
template<> struct cast_hook<std::string, T > { \
static inline std::string apply( T arg) { \
char buffer[255]; \
if (sprintf(buffer, "%" p "" c, arg) < 0) \
throw std::runtime_error( \
"error casting from " #T " to string" + ALPS_STACKTRACE \
); \
return buffer; \
} \
}; \
template<> struct cast_hook< T, std::string> { \
static inline T apply(std::string arg) { \
T value = 0; \
if (arg.size() && sscanf(arg.c_str(), "%" c, &value) < 0) \
throw std::runtime_error( \
"error casting from string to " #T ": " \
+ arg + ALPS_STACKTRACE \
); \
return value; \
} \
};
STL namespace.
#define ALPS_STACKTRACE
Definition: stacktrace.hpp:37

Definition at line 68 of file cast.hpp.

#define ALPS_CAST_STRING_CHAR (   T,
 
)
Value:
template<> struct cast_hook<std::string, T > { \
static inline std::string apply( T arg) { \
return cast_hook<std::string, U>::apply(arg); \
} \
}; \
template<> struct cast_hook<T, std::string> { \
static inline T apply(std::string arg) { \
return cast_hook< U , std::string>::apply(arg); \
} \
};
STL namespace.

Definition at line 103 of file cast.hpp.