// Copyright (C) 2010, Guy Barrand. All rights reserved. // See the file tools.license for terms. #ifndef tools_charp_out #define tools_charp_out #include "snpf" #include namespace tools { class charp_out : public std::string { typedef std::string parent; public: charp_out(const char* a_value) { char _s[512]; if(sizeof(unsigned long)==sizeof(char*)) { //majority of cases. snpf(_s,sizeof(_s),"%lu",a_value); parent::operator+=(_s); } else if(sizeof(unsigned long long)==sizeof(char*)) { //majority of cases. snpf(_s,sizeof(_s),"%llu",a_value); parent::operator+=(_s); } else { parent::operator+=("charp_out_failed"); } } public: charp_out(const charp_out& a_from):parent(a_from){} charp_out& operator=(const charp_out& a_from){parent::operator=(a_from);return *this;} }; } #endif