Debian Codegraph @

include/sstream_subst

raw
1 #ifndef __CM_SSTREAM__
2 #define __CM_SSTREAM__
3
4 #if 0
5 //#ifndef MSVC
6
7 #include <string>
8 #include <cstdio>
9 #include <strstream>
10 #include <algorithm>
11
12 namespace std {
13
14 class ostringstream
15 {
16 public:
17 ostringstream (const string & str = "")
18 : buffer(str) {}
19
20 const string & str() const
21 {
22 return buffer;
23 }
24
25 void str (const string & new_string)
26 {
27 buffer = new_string;
28 }
29
30 ostringstream & operator<< (const string & item)
31 {
32 buffer += item;
33
34 return *this;
35 }
36
37 ostringstream & operator<< (int item)
38 {
39 char temp[100];
40
41 sprintf (temp, "%d", item);
42 buffer += temp;
43
44 return *this;
45 }
46
47 ostringstream & operator<< (unsigned int item)
48 {
49 char temp[100];
50
51 sprintf (temp, "%u", item);
52 buffer += temp;
53
54 return *this;
55 }
56
57 ostringstream & operator<< (char item)
58 {
59 buffer += item;
60 return *this;
61 }
62
63 ostringstream & operator<< (double item)
64 {
65 char temp[1000];
66
67 sprintf (temp, "%g", item);
68 buffer += temp;
69
70 return *this;
71 }
72
73 private:
74 string buffer;
75 };
76
77
78
79 class istringstream
80 {
81 friend istringstream & getline (istringstream &, string &, char = '\n');
82
83 public:
84 istringstream (const string & str = "")
85 : buffer (str.c_str(), str.length()) {}
86
87 template <class T>
88 istringstream & operator>> (T & item)
89 {
90 buffer >> item;
91 return *this;
92 }
93
94 operator void * () const
95 {
96 return (void *) buffer;
97 }
98
99 private:
100 istrstream buffer;
101 };
102
103
104 inline istringstream & getline (istringstream & src_stream, string & str, char separator)
105 {
106 getline (src_stream.buffer, str, separator);
107 return src_stream;
108 }
109
110 } // End of namespace std
111
112 #endif
113
114 #endif
115