1
#include "svg/stringstream.h"
2
#include "svg/strip-trailing-zeros.h"
3
#include "preferences.h"
4
#include <2geom/point.h>
6
Inkscape::SVGOStringStream::SVGOStringStream()
8
/* These two are probably unnecessary now that we provide our own operator<< for float and
10
ostr.imbue(std::locale::classic());
11
ostr.setf(std::ios::showpoint);
13
/* This one is (currently) needed though, as we currently use ostr.precision as a sort of
14
variable for storing the desired precision: see our two precision methods and our operator<<
15
methods for float and double. */
16
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
17
ostr.precision(prefs->getInt("/options/svgoutput/numericprecision", 8));
20
Inkscape::SVGOStringStream &
21
operator<<(Inkscape::SVGOStringStream &os, float d)
23
/* Try as integer first. */
33
s.imbue(std::locale::classic());
34
s.flags(os.setf(std::ios::showpoint));
35
s.precision(os.precision());
37
os << strip_trailing_zeros(s.str());
41
Inkscape::SVGOStringStream &
42
operator<<(Inkscape::SVGOStringStream &os, double d)
44
/* Try as integer first. */
54
s.imbue(std::locale::classic());
55
s.flags(os.setf(std::ios::showpoint));
56
s.precision(os.precision());
58
os << strip_trailing_zeros(s.str());
62
Inkscape::SVGOStringStream &
63
operator<<(Inkscape::SVGOStringStream &os, Geom::Point const & p)
65
os << p[0] << ',' << p[1];
72
c-file-style:"stroustrup"
73
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
78
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :