Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
stringstream.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
/*
5 * Authors: see git history
6 *
7 * Copyright (C) 2014 Authors
8 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
9 */
10#ifndef INKSCAPE_STRINGSTREAM_H
11#define INKSCAPE_STRINGSTREAM_H
12
13#include <sstream>
14#include <string>
15#include <type_traits>
16
17#include <2geom/forward.h>
18
19namespace Inkscape {
20
22private:
23 std::ostringstream ostr;
24
25public:
27
28 template <typename T,
29 // disable this template for float and double
30 typename std::enable_if<!std::is_floating_point<T>::value, int>::type = 0>
32 {
33 static_assert(!std::is_base_of<Geom::Point, T>::value, "");
34 ostr << arg;
35 return *this;
36 }
37
38 SVGOStringStream &operator<<(double);
39 SVGOStringStream &operator<<(Geom::Point const &);
40
41 std::string str() const {
42 return ostr.str();
43 }
44
45 void str (std::string &s) {
46 ostr.str(s);
47 }
48
49 std::streamsize precision() const {
50 return ostr.precision();
51 }
52
53 std::streamsize precision(std::streamsize p) {
54 return ostr.precision(p);
55 }
56
57 std::ios::fmtflags setf(std::ios::fmtflags fmtfl) {
58 return ostr.setf(fmtfl);
59 }
60
61 std::ios::fmtflags setf(std::ios::fmtflags fmtfl, std::ios::fmtflags mask) {
62 return ostr.setf(fmtfl, mask);
63 }
64
65 void unsetf(std::ios::fmtflags mask) {
66 ostr.unsetf(mask);
67 }
68};
69
70class SVGIStringStream:public std::istringstream {
71
72public:
74 SVGIStringStream(const std::string &str);
75};
76
77}
78
79#endif
80
81/*
82 Local Variables:
83 mode:c++
84 c-file-style:"stroustrup"
85 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
86 indent-tabs-mode:nil
87 fill-column:99
88 End:
89*/
90// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
Two-dimensional point that doubles as a vector.
Definition point.h:66
SVGOStringStream & operator<<(T const &arg)
std::streamsize precision(std::streamsize p)
std::ostringstream ostr
std::string str() const
std::ios::fmtflags setf(std::ios::fmtflags fmtfl, std::ios::fmtflags mask)
std::streamsize precision() const
std::ios::fmtflags setf(std::ios::fmtflags fmtfl)
void str(std::string &s)
void unsetf(std::ios::fmtflags mask)
Contains forward declarations of 2geom types.
Helper class to stream background task notifications as a series of messages.