1 #ifndef INKSCAPE_STRINGSTREAM_H
2 #define INKSCAPE_STRINGSTREAM_H
4 #include <glib/gtypes.h>
5 #include <sstream>
6 #include <string>
8 #include <2geom/forward.h>
10 namespace Inkscape {
12 typedef std::ios_base &(*std_oct_type)(std::ios_base &);
14 class SVGOStringStream {
15 private:
16 std::ostringstream ostr;
18 public:
19 SVGOStringStream();
21 #define INK_SVG_STR_OP(_t) \
22 SVGOStringStream &operator<<(_t arg) { \
23 ostr << arg; \
24 return *this; \
25 }
27 INK_SVG_STR_OP(char)
28 INK_SVG_STR_OP(signed char)
29 INK_SVG_STR_OP(unsigned char)
30 INK_SVG_STR_OP(short)
31 INK_SVG_STR_OP(unsigned short)
32 INK_SVG_STR_OP(int)
33 INK_SVG_STR_OP(unsigned int)
34 INK_SVG_STR_OP(long)
35 INK_SVG_STR_OP(unsigned long)
36 INK_SVG_STR_OP(char const *)
37 INK_SVG_STR_OP(signed char const *)
38 INK_SVG_STR_OP(unsigned char const *)
39 INK_SVG_STR_OP(std::string const &)
40 INK_SVG_STR_OP(std_oct_type)
42 #undef INK_SVG_STR_OP
44 gchar const *gcharp() const {
45 return reinterpret_cast<gchar const *>(ostr.str().c_str());
46 }
48 std::string str() const {
49 return ostr.str();
50 }
52 void str (std::string &s) {
53 ostr.str(s);
54 }
56 std::streamsize precision() const {
57 return ostr.precision();
58 }
60 std::streamsize precision(std::streamsize p) {
61 return ostr.precision(p);
62 }
64 std::ios::fmtflags setf(std::ios::fmtflags fmtfl) {
65 return ostr.setf(fmtfl);
66 }
68 std::ios::fmtflags setf(std::ios::fmtflags fmtfl, std::ios::fmtflags mask) {
69 return ostr.setf(fmtfl, mask);
70 }
72 void unsetf(std::ios::fmtflags mask) {
73 ostr.unsetf(mask);
74 }
75 };
77 }
79 Inkscape::SVGOStringStream &operator<<(Inkscape::SVGOStringStream &os, float d);
81 Inkscape::SVGOStringStream &operator<<(Inkscape::SVGOStringStream &os, double d);
83 Inkscape::SVGOStringStream &operator<<(Inkscape::SVGOStringStream &os, Geom::Point const & p);
85 #endif
87 /*
88 Local Variables:
89 mode:c++
90 c-file-style:"stroustrup"
91 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
92 indent-tabs-mode:nil
93 fill-column:99
94 End:
95 */
96 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :