00001 // to_string_v.hpp, created on 30.06.2009 by Sebastian Mies 00002 00003 #ifndef TO_STRING_V_HPP_ 00004 #define TO_STRING_V_HPP_ 00005 00006 #include <string> 00007 #include "vfacade.hpp" 00008 00009 using namespace std; 00010 00016 00017 class to_string_v { 00018 public: 00019 //--- to_string_v --------------------------------------------------------- 00020 00022 virtual string to_string() const = 0; 00023 00025 virtual bool assign(const std::string& text) = 0; 00026 00028 inline to_string_v& assign(const char* text) { 00029 to_string_v::assign(std::string(text)); 00030 return *this; 00031 } 00032 00034 inline to_string_v& operator=(const std::string& text) { 00035 assign(text); 00036 return *this; 00037 } 00038 00040 inline to_string_v& operator=(const char* text) { 00041 assign(text); 00042 return *this; 00043 } 00044 }; 00045 00046 typedef vfacade<to_string_v> to_string_vf; 00047 00049 template<class NonVirtual, class AdaptorType> 00050 class vobject_hull<NonVirtual, to_string_v, AdaptorType> : public to_string_v { 00051 private: 00052 typename AdaptorType::template adaptor_type<NonVirtual> obj; 00053 00054 public: 00055 template<typename T> 00056 explicit vobject_hull(T& obj) : 00057 obj(obj) { 00058 } 00059 00060 explicit vobject_hull() : 00061 obj() { 00062 } 00063 00064 //--- to_string_v --------------------------------------------------------- 00065 00067 virtual string to_string() const { 00068 return obj->to_string(); 00069 } 00070 00072 virtual bool assign(const std::string& text) { 00073 return obj->assign(text); 00074 } 00075 }; 00076 00077 #endif /* TO_STRING_V_HPP_ */