ALPS Project: ALPS library
Header file valuetype.h
This header contains the ValueType class, a class that
can store any numerical, boolean or string value.
Synopsis
namespace palm {
class ValueType {
public:
ValueType();
ValueType( bool x);
ValueType( int8_t x);
ValueType( int16_t x);
ValueType( int32_t x);
ValueType( int64_t x);
ValueType( uint8_t x);
ValueType( uint16_t x);
ValueType( uint32_t x);
ValueType( uint64_t x);
ValueType( float x);
ValueType( double x);
ValueType( long double x);
template <class T> ValueType( std::complex<T> x);
ValueType( const std::string& x);
ValueType( const char* x);
inline operator bool () const;
inline operator int8_t () const;
inline operator int16_t () const;
inline operator int32_t () const;
inline operator int64_t () const;
inline operator uint8_t () const;
inline operator uint16_t () const;
inline operator uint32_t () const;
inline operator uint64_t () const;
inline operator float () const;
inline operator double () const;
inline operator long double () const;
template <class T> inline operator std::complex<T> () const;
inline operator std::string () const;
inline const char* c_str() const;
inline ValueType& operator=(bool x);
inline ValueType& operator=(int8_t x);
inline ValueType& operator=(int16_t x);
inline ValueType& operator=(int32_t x);
inline ValueType& operator=(int64_t x);
inline ValueType& operator=(uint8_t x);
inline ValueType& operator=(uint16_t x);
inline ValueType& operator=(uint32_t x);
inline ValueType& operator=(uint64_t x);
inline ValueType& operator=(float x);
inline ValueType& operator=(double x);
inline ValueType& operator=(long double x);
template <class T> inline ValueType& operator=(std::complex<T> x);
inline ValueType& operator=(const std::string& x);
inline ValueType& operator=(const char* x);
type_tag_t getType() const;
inline bool valid() const;
template T get() const ;
};
} // end namespace
STD::ostream& operator <<(STD::ostream& os, const palm::ValueType& v);
The ValueType class
ValueType();
initialized to an invalid value.
ValueType( bool x);
ValueType( int8_t x);
ValueType( int16_t x);
ValueType( int32_t x);
ValueType( int64_t x);
ValueType( uint8_t x);
ValueType( uint16_t x);
ValueType( uint32_t x);
ValueType( uint64_t x);
ValueType( float x);
ValueType( double x);
ValueType( long double x);
template <class T> ValueType( std::complex<T> x);
initialize from a numerical or boolean value.
ValueType( const std::string& x);
initializes from a std::string.
ValueType( const char* x);
initializes from a C-style string.
ValueType& operator=(bool x);
ValueType& operator=(int8_t x);
ValueType& operator=(int16_t x);
ValueType& operator=(int32_t x);
ValueType& operator=(int64_t x);
ValueType& operator=(uint8_t x);
ValueType& operator=(uint16_t x);
ValueType& operator=(uint32_t x);
ValueType& operator=(uint64_t x);
ValueType& operator=(float x);
ValueType& operator=(double x);
ValueType& operator=(long double x);
template <class T> inline ValueType& operator=(std::complex<T> x);
assign a numerical value
ValueType& operator=(const std::string& x);
assigns from a std::string.
ValueType& operator=(const char* x);
assigns from a C-style string.
operator bool () const;
operator int8_t () const;
operator int16_t () const;
operator int32_t () const;
operator int64_t () const;
operator uint8_t () const;
operator uint16_t () const;
operator uint32_t () const;
operator uint64_t () const;
operator float () const;
operator double () const;
operator long double () const;
template <class T> inline operator std::complex<T> () const;
operator std::string () const;
attempt a conversion to the type. If this is impossible
a std::runtime_error is thrown.
const char* c_str() const;
attempts a conversion to the type. If this is impossible
a std::runtime_error is thrown.
template T get() const ;
attempts a conversion to the type T. If this is impossible
a std::runtime_error is thrown.
type_tag_t getType() const;
returns the value palm::TypeTraits<T>::type_tag for the
type T which is currently stored in the class, or
palm::TypeTraits<void>::type_tag if no valid value
is stored.
bool valid() const;
returns true if a value is stored in the class.
std::ostream& operator <<(std::ostream& os, const palm::ValueType& v);
writes the stored value to an ostream if a valid value is stored.
Nothing is written otherwise.
(c) 1994-2002 by Matthias Troyer