1 #ifndef __INKSCAPE_IO_XSLTSTREAM_H__
2 #define __INKSCAPE_IO_XSLTSTREAM_H__
3 /**
4 * Xslt-enabled input and output streams
5 *
6 *
7 * Authors:
8 * Bob Jamison <ishmalius@gmail.com>
9 *
10 * Copyright (C) 2004-2008 Inkscape.org
11 *
12 * Released under GNU GPL, read the file 'COPYING' for more information
13 */
16 #include "inkscapestream.h"
18 #include <libxslt/xslt.h>
19 #include <libxslt/xsltInternals.h>
22 namespace Inkscape
23 {
24 namespace IO
25 {
27 //#########################################################################
28 //# X S L T S T Y L E S H E E T
29 //#########################################################################
30 /**
31 * This is a container for reusing a loaded stylesheet
32 */
33 class XsltStyleSheet
34 {
36 public:
38 /**
39 * Constructor with loading
40 */
41 XsltStyleSheet(InputStream &source) throw (StreamException);
43 /**
44 * Simple constructor, no loading
45 */
46 XsltStyleSheet();
48 /**
49 * Loader
50 */
51 bool read(InputStream &source);
53 /**
54 * Destructor
55 */
56 virtual ~XsltStyleSheet();
58 xsltStylesheetPtr stylesheet;
61 }; // class XsltStyleSheet
64 //#########################################################################
65 //# X S L T I N P U T S T R E A M
66 //#########################################################################
68 /**
69 * This class is for transforming stream input by a given stylesheet
70 */
71 class XsltInputStream : public BasicInputStream
72 {
74 public:
76 XsltInputStream(InputStream &xmlSource, XsltStyleSheet &stylesheet)
77 throw (StreamException);
79 virtual ~XsltInputStream() throw (StreamException);
81 virtual int available() throw (StreamException);
83 virtual void close() throw (StreamException);
85 virtual int get() throw (StreamException);
88 private:
90 XsltStyleSheet &stylesheet;
92 xmlChar *outbuf;
93 int outsize;
94 int outpos;
96 }; // class UriInputStream
101 //#########################################################################
102 //# X S L T O U T P U T S T R E A M
103 //#########################################################################
105 /**
106 * This class is for transforming stream output by a given stylesheet
107 */
108 class XsltOutputStream : public BasicOutputStream
109 {
111 public:
113 XsltOutputStream(OutputStream &destination, XsltStyleSheet &stylesheet)
114 throw (StreamException);
116 virtual ~XsltOutputStream() throw (StreamException);
118 virtual void close() throw (StreamException);
120 virtual void flush() throw (StreamException);
122 virtual void put(int ch) throw (StreamException);
124 private:
126 XsltStyleSheet &stylesheet;
128 Glib::ustring outbuf;
130 bool flushed;
132 }; // class UriOutputStream
136 } // namespace IO
137 } // namespace Inkscape
140 #endif /* __INKSCAPE_IO_XSLTSTREAM_H__ */