diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:29:01 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:29:01 +0000 |
commit | 35a96bde514a8897f6f0fcc41c5833bf63df2e2a (patch) | |
tree | 657d15a03cc46bd099fc2c6546a7a4ad43815d9f /src/svg/stringstream.h | |
parent | Initial commit. (diff) | |
download | inkscape-35a96bde514a8897f6f0fcc41c5833bf63df2e2a.tar.xz inkscape-35a96bde514a8897f6f0fcc41c5833bf63df2e2a.zip |
Adding upstream version 1.0.2.upstream/1.0.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/svg/stringstream.h')
-rw-r--r-- | src/svg/stringstream.h | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/src/svg/stringstream.h b/src/svg/stringstream.h new file mode 100644 index 0000000..f5d9073 --- /dev/null +++ b/src/svg/stringstream.h @@ -0,0 +1,107 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** @file + * TODO: insert short description here + *//* + * Authors: see git history + * + * Copyright (C) 2014 Authors + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ +#ifndef INKSCAPE_STRINGSTREAM_H +#define INKSCAPE_STRINGSTREAM_H + +#include <sstream> +#include <string> + +#include <2geom/forward.h> + +namespace Inkscape { + +typedef std::ios_base &(*std_oct_type)(std::ios_base &); + +class SVGOStringStream { +private: + std::ostringstream ostr; + +public: + SVGOStringStream(); + +#define INK_SVG_STR_OP(_t) \ + SVGOStringStream &operator<<(_t arg) { \ + ostr << arg; \ + return *this; \ + } + + INK_SVG_STR_OP(char) + INK_SVG_STR_OP(signed char) + INK_SVG_STR_OP(unsigned char) + INK_SVG_STR_OP(short) + INK_SVG_STR_OP(unsigned short) + INK_SVG_STR_OP(int) + INK_SVG_STR_OP(unsigned int) + INK_SVG_STR_OP(long) + INK_SVG_STR_OP(unsigned long) + INK_SVG_STR_OP(char const *) + INK_SVG_STR_OP(signed char const *) + INK_SVG_STR_OP(unsigned char const *) + INK_SVG_STR_OP(std::string const &) + INK_SVG_STR_OP(std_oct_type) + +#undef INK_SVG_STR_OP + + std::string str() const { + return ostr.str(); + } + + void str (std::string &s) { + ostr.str(s); + } + + std::streamsize precision() const { + return ostr.precision(); + } + + std::streamsize precision(std::streamsize p) { + return ostr.precision(p); + } + + std::ios::fmtflags setf(std::ios::fmtflags fmtfl) { + return ostr.setf(fmtfl); + } + + std::ios::fmtflags setf(std::ios::fmtflags fmtfl, std::ios::fmtflags mask) { + return ostr.setf(fmtfl, mask); + } + + void unsetf(std::ios::fmtflags mask) { + ostr.unsetf(mask); + } +}; + +class SVGIStringStream:public std::istringstream { + +public: + SVGIStringStream(); + SVGIStringStream(const std::string &str); +}; + +} + +Inkscape::SVGOStringStream &operator<<(Inkscape::SVGOStringStream &os, float d); + +Inkscape::SVGOStringStream &operator<<(Inkscape::SVGOStringStream &os, double d); + +Inkscape::SVGOStringStream &operator<<(Inkscape::SVGOStringStream &os, Geom::Point const & p); + +#endif + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : |