1 #ifndef INKSCAPE_STRINGSTREAM_H
2 #define INKSCAPE_STRINGSTREAM_H
4 #include <glib/gtypes.h>
5 #include <sstream>
7 namespace Inkscape {
9 typedef std::ios_base &(*std_oct_type)(std::ios_base &);
11 class SVGOStringStream {
12 private:
13 std::ostringstream ostr;
15 public:
16 SVGOStringStream();
18 #define INK_SVG_STR_OP(_t) \
19 SVGOStringStream &operator<<(_t arg) { \
20 ostr << arg; \
21 return *this; \
22 }
24 INK_SVG_STR_OP(char)
25 INK_SVG_STR_OP(signed char)
26 INK_SVG_STR_OP(unsigned char)
27 INK_SVG_STR_OP(short)
28 INK_SVG_STR_OP(unsigned short)
29 INK_SVG_STR_OP(int)
30 INK_SVG_STR_OP(unsigned int)
31 INK_SVG_STR_OP(long)
32 INK_SVG_STR_OP(unsigned long)
33 INK_SVG_STR_OP(char const *)
34 INK_SVG_STR_OP(signed char const *)
35 INK_SVG_STR_OP(unsigned char const *)
36 INK_SVG_STR_OP(std::string const &)
37 INK_SVG_STR_OP(std_oct_type)
39 #undef INK_SVG_STR_OP
41 gchar const *gcharp() const {
42 return reinterpret_cast<gchar const *>(ostr.str().c_str());
43 }
45 std::string str() const {
46 return ostr.str();
47 }
49 std::streamsize precision() const {
50 return ostr.precision();
51 }
53 std::streamsize precision(std::streamsize p) {
54 return ostr.precision(p);
55 }
56 };
58 }
60 Inkscape::SVGOStringStream &operator<<(Inkscape::SVGOStringStream &os, float d);
62 Inkscape::SVGOStringStream &operator<<(Inkscape::SVGOStringStream &os, double d);
65 #endif
67 /*
68 Local Variables:
69 mode:c++
70 c-file-style:"stroustrup"
71 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
72 indent-tabs-mode:nil
73 fill-column:99
74 End:
75 */
76 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :