35 lines
850 B
Plaintext
35 lines
850 B
Plaintext
// 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 <string>
|
|
|
|
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
|