~valavanisalex/ubuntu/precise/inkscape/fix-943984

« back to all changes in this revision

Viewing changes to inkscape-0.47pre1/src/svg/css-ostringstream.h

  • Committer: Bazaar Package Importer
  • Author(s): Bryce Harrington
  • Date: 2009-07-02 17:09:45 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20090702170945-nn6d6zswovbwju1t
Tags: 0.47~pre1-0ubuntu1
* New upstream release.
  - Don't constrain maximization on small resolution devices (pre0)
    (LP: #348842)
  - Fixes segfault on startup (pre0)
    (LP: #391149)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef SVG_CSS_OSTRINGSTREAM_H_INKSCAPE
 
2
#define SVG_CSS_OSTRINGSTREAM_H_INKSCAPE
 
3
 
 
4
#include <glib/gtypes.h>
 
5
#include <sstream>
 
6
 
 
7
namespace Inkscape {
 
8
 
 
9
typedef std::ios_base &(*std_oct_type)(std::ios_base &);
 
10
 
 
11
/**
 
12
 * A thin wrapper around std::ostringstream, but writing floating point numbers in the format
 
13
 * required by CSS: `.' as decimal separator, no `e' notation, no nan or inf.
 
14
 */
 
15
class CSSOStringStream {
 
16
private:
 
17
    std::ostringstream ostr;
 
18
 
 
19
public:
 
20
    CSSOStringStream();
 
21
 
 
22
#define INK_CSS_STR_OP(_t) \
 
23
    CSSOStringStream &operator<<(_t arg) {  \
 
24
        ostr << arg;    \
 
25
        return *this;   \
 
26
    }
 
27
 
 
28
    INK_CSS_STR_OP(char)
 
29
    INK_CSS_STR_OP(signed char)
 
30
    INK_CSS_STR_OP(unsigned char)
 
31
    INK_CSS_STR_OP(short)
 
32
    INK_CSS_STR_OP(unsigned short)
 
33
    INK_CSS_STR_OP(int)
 
34
    INK_CSS_STR_OP(unsigned int)
 
35
    INK_CSS_STR_OP(long)
 
36
    INK_CSS_STR_OP(unsigned long)
 
37
    INK_CSS_STR_OP(char const *)
 
38
    INK_CSS_STR_OP(signed char const *)
 
39
    INK_CSS_STR_OP(unsigned char const *)
 
40
    INK_CSS_STR_OP(std::string const &)
 
41
    INK_CSS_STR_OP(std_oct_type)
 
42
 
 
43
#undef INK_CSS_STR_OP
 
44
 
 
45
    gchar const *gcharp() const {
 
46
        return reinterpret_cast<gchar const *>(ostr.str().c_str());
 
47
    }
 
48
 
 
49
    std::string str() const {
 
50
        return ostr.str();
 
51
    }
 
52
 
 
53
    std::streamsize precision() const {
 
54
        return ostr.precision();
 
55
    }
 
56
 
 
57
    std::streamsize precision(std::streamsize p) {
 
58
        return ostr.precision(p);
 
59
    }
 
60
};
 
61
 
 
62
}
 
63
 
 
64
Inkscape::CSSOStringStream &operator<<(Inkscape::CSSOStringStream &os, float d);
 
65
 
 
66
Inkscape::CSSOStringStream &operator<<(Inkscape::CSSOStringStream &os, double d);
 
67
 
 
68
 
 
69
#endif /* !SVG_CSS_OSTRINGSTREAM_H_INKSCAPE */
 
70
 
 
71
/*
 
72
  Local Variables:
 
73
  mode:c++
 
74
  c-file-style:"stroustrup"
 
75
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
 
76
  indent-tabs-mode:nil
 
77
  fill-column:99
 
78
  End:
 
79
*/
 
80
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :