g4tools  5.4.0
charp_out
Go to the documentation of this file.
1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
2 // See the file tools.license for terms.
3 
4 #ifndef tools_charp_out
5 #define tools_charp_out
6 
7 #include "snpf"
8 #include <string>
9 
10 namespace tools {
11 
12 class charp_out : public std::string {
13  typedef std::string parent;
14 public:
15  charp_out(const char* a_value) {
16  char s[512];
17  if(sizeof(unsigned long)==sizeof(char*)) { //majority of cases.
18  snpf(s,sizeof(s),"%lu",a_value);
19  parent::operator+=(s);
20  } else if(sizeof(unsigned long long)==sizeof(char*)) { //majority of cases.
21  snpf(s,sizeof(s),"%llu",a_value);
22  parent::operator+=(s);
23  } else {
24  parent::operator+=("charp_out_failed");
25  }
26  }
27 public:
28  charp_out(const charp_out& a_from):parent(a_from){}
29  charp_out& operator=(const charp_out& a_from){parent::operator=(a_from);return *this;}
30 };
31 
32 }
33 
34 #endif
tools::charp_out::charp_out
charp_out(const charp_out &a_from)
Definition: charp_out:28
tools::charp_out::charp_out
charp_out(const char *a_value)
Definition: charp_out:15
snpf
tools::snpf
int snpf(char *a_s, size_t a_n, const char *a_fmt,...)
Definition: snpf:27
tools::charp_out
Definition: charp_out:12
tools
inlined C code : ///////////////////////////////////
Definition: aida_ntuple:26
tools::charp_out::operator=
charp_out & operator=(const charp_out &a_from)
Definition: charp_out:29