Code

Super duper mega (fun!) commit: replaced encoding=utf-8 with fileencoding=utf-8 in...
[inkscape.git] / src / svg / stringstream.h
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     }
51     
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 class SVGIStringStream:public std::istringstream {
79 public:
80     SVGIStringStream();
81     SVGIStringStream(const std::string &str);
82 };
84 }
86 Inkscape::SVGOStringStream &operator<<(Inkscape::SVGOStringStream &os, float d);
88 Inkscape::SVGOStringStream &operator<<(Inkscape::SVGOStringStream &os, double d);
90 Inkscape::SVGOStringStream &operator<<(Inkscape::SVGOStringStream &os, Geom::Point const & p);
92 #endif
94 /*
95   Local Variables:
96   mode:c++
97   c-file-style:"stroustrup"
98   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
99   indent-tabs-mode:nil
100   fill-column:99
101   End:
102 */
103 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :