CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ioutils.cc
Go to the documentation of this file.
3 
4 #include <iostream>
5 #include <iomanip>
6 #include <algorithm>
7 
8 bool ato<bool>::operator () (const std::string &c) const {
9  bool ret;
10  std::string loc = c;
11  std::transform(loc.begin(),loc.end(),loc.begin(),::tolower);
12  std::stringstream in(loc.c_str());
13  in >> ret;;
14  if (in.fail()) {
15  in.clear();
16  in >> std::setiosflags(std::ios::boolalpha) >> ret;
17  }
18  return ret;
19 }
20 
21 #ifndef CMS_CHAR_STREAM
22 #define CSTR .c_str()
23 #else
24 #define CSTR
25 #endif
26 
27 #ifdef CMS_CHAR_STREAM //linux
28 toa::~toa() {
29  oss().rdbuf()->freeze(0);
30 }
31 #else
33 }
34 #endif
35 
36 std::string & toa::localS() {
37  static boost::thread_specific_ptr<std::string> local_s;
38  if (!local_s.get()) local_s.reset(new std::string);
39  return *local_s;
40 }
41 
42 const char * toa::operator () (const int&c) const {
43  oss() << c;
44 #ifdef CMS_CHAR_STREAM
45  oss() << ends;
46 #endif
47  localS() = oss().str();
48  return localS().c_str();
49 }
50 
51 const char * toa::operator () (bool c) const {
52  oss() << std::setiosflags(std::ios::boolalpha) << c;
53 #ifdef CMS_CHAR_STREAM
54  oss() << ends;
55 #endif
56  localS() = oss().str();
57  return localS().c_str();
58 }
59 
60 
61 const char * toa::operator () (const double&c) const {
62  oss() << c;
63 #ifdef CMS_CHAR_STREAM
64  oss() << ends;
65 #endif
66  localS() = oss().str();
67  return localS().c_str();
68 }
69 
70 const char * toa::operator () (const char c[], int n) const {
71  localS().assign(c,n);
72  return localS().c_str();
73 }
const T & operator()(const T &c) const
Definition: ioutils.h:23
const char * operator()(const unsigned short int &c) const
Definition: ioutils.h:102
static std::string & localS()
Definition: ioutils.cc:36
~toa()
Definition: ioutils.cc:32
std::ostringstream & oss() const
Definition: ioutils.h:124