ALPS Project
Header file stringvalue.h
This header contains the StringValue class, a class that
can store any numerical, boolean or string value in a std::string. Conversions are performed by boost::lexical_cast. it replaces the deprecated ValueType class.
Synopsis
namespace alps {
class StringValue {
public:
StringValue();
StringValue(const std::string&);
StringValue(const char*);
template <class T> StringValue(const T& x);
const StringValue& operator=(const std::string& x);
const StringValue& operator=(const char* x);
template <class T> const StringValue& operator=(const T& x);
bool operator==(const StringValue&) const;
bool operator!=(const StringValue&) const;
operator std::string ();
operator bool() const;
template <class T> operator T() const;
template <class T> T get() const;
const char* c_str() const;
};
std::ostream& operator <<(std::ostream& os, const palm::StringValue& v);
std::istream& operator >>(std::istream& is, palm::StringValue& v);
}
The StringValue class
StringValue();
initialized to an empty string.
StringValue( const std::string& x);
initializes from a std::string.
StringValue( const char* x);
initializes from a C-style string.
template <class T> StringValue(const T& x);
initialize from any other type by converting to a std::string using lexical_cast.
StringValue& operator=(const std::string& x);
assigns from a std::string.
StringValue& operator=(const char* x);
assigns from a C-style string.
template <class T> const StringValue& operator=(const T& x);
assign any other type by converting to a std::string using lexical_cast.
bool operator==(const StringValue&) const;
bool operator!=(const StringValue&) const;
The comparison operators compare the string representation.
operator std::string () const;
return the string representation
const char* c_str() const;
return a representation as C-style string.
template <class T> T get() const;
operator bool() const;
template <class T> operator T() const;
template <class T> T get() const ;
converts the underlying string to type T using boost::lexical_cast. Conversion to bool also interprets the strings true and false as boolean values.
std::ostream& operator <<(std::ostream& os, const palm::StringValue& v);
writes the stored string to an ostream.
std::istream& operator >>(std::istream& is, palm::StringValue& v);
reads a std::string from the stream and stores it in v.
copyright (c) 1994-2003 by Matthias Troyer