Code

moving trunk for module inkscape
[inkscape.git] / src / io / xsltstream.h
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 <rjamison@titan.com>
9  *
10  * Copyright (C) 2004 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     XsltStyleSheet(InputStream &source)  throw (StreamException);
39     
40     ~XsltStyleSheet();
41     
42     xsltStylesheetPtr stylesheet;
45 }; // class XsltStyleSheet
48 //#########################################################################
49 //# X S L T    I N P U T    S T R E A M
50 //#########################################################################
52 /**
53  * This class is for transforming stream input by a given stylesheet
54  */
55 class XsltInputStream : public BasicInputStream
56 {
58 public:
60     XsltInputStream(InputStream &xmlSource, XsltStyleSheet &stylesheet)
61                         throw (StreamException);
62     
63     virtual ~XsltInputStream() throw (StreamException);
64     
65     virtual int available() throw (StreamException);
66     
67     virtual void close() throw (StreamException);
68     
69     virtual int get() throw (StreamException);
70     
72 private:
74     XsltStyleSheet &stylesheet;
76     xmlChar *outbuf;
77     int outsize;
78     int outpos;
80 }; // class UriInputStream
85 //#########################################################################
86 //# X S L T    O U T P U T    S T R E A M
87 //#########################################################################
89 /**
90  * This class is for transforming stream output by a given stylesheet
91  */
92 class XsltOutputStream : public BasicOutputStream
93 {
95 public:
97     XsltOutputStream(OutputStream &destination, XsltStyleSheet &stylesheet)
98                              throw (StreamException);
99     
100     virtual ~XsltOutputStream() throw (StreamException);
101     
102     virtual void close() throw (StreamException);
103     
104     virtual void flush() throw (StreamException);
105     
106     virtual void put(int ch) throw (StreamException);
108 private:
110     XsltStyleSheet &stylesheet;
112     Glib::ustring outbuf;
113     
114     bool flushed;
116 }; // class UriOutputStream
120 } // namespace IO
121 } // namespace Inkscape
124 #endif /* __INKSCAPE_IO_XSLTSTREAM_H__ */