Code

fix some includes
[inkscape.git] / src / dom / io / uristream.h
1 #ifndef __URISTREAM_H__
2 #define __URISTREAM_H__
4 /**
5  * Phoebe DOM Implementation.
6  *
7  * This is a C++ approximation of the W3C DOM model, which follows
8  * fairly closely the specifications in the various .idl files, copies of
9  * which are provided for reference.  Most important is this one:
10  *
11  * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html
12  *
13  * Authors:
14  *   Bob Jamison
15  *
16  * Copyright (C) 2005 Bob Jamison
17  *
18  *  This library is free software; you can redistribute it and/or
19  *  modify it under the terms of the GNU Lesser General Public
20  *  License as published by the Free Software Foundation; either
21  *  version 2.1 of the License, or (at your option) any later version.
22  *
23  *  This library is distributed in the hope that it will be useful,
24  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
25  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
26  *  Lesser General Public License for more details.
27  *
28  *  You should have received a copy of the GNU Lesser General Public
29  *  License along with this library; if not, write to the Free Software
30  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
31  */
33 /**
34  * This should be the only way that we provide sources/sinks
35  * to any input/output stream.
36  *
37  */
40 #include "uri.h"
41 #include "domstream.h"
42 #include "httpclient.h"
45 namespace org
46 {
47 namespace w3c
48 {
49 namespace dom
50 {
51 namespace io
52 {
55 //#########################################################################
56 //# U R I    I N P U T    S T R E A M   /   R E A D E R
57 //#########################################################################
59 /**
60  * This class is for receiving a stream of data from a resource
61  * defined in a URI
62  */
63 class UriInputStream : public InputStream
64 {
66 public:
68     UriInputStream(const URI &source) throw(StreamException);
70     virtual ~UriInputStream() throw(StreamException);
72     virtual int available() throw(StreamException);
74     virtual void close() throw(StreamException);
76     virtual int get() throw(StreamException);
78 private:
80     void init() throw(StreamException);//common code called by constructor
82     bool closed;
84     FILE *inf;           //for file: uris
85     unsigned char *data; //for data: uris
86     int dataPos;         //  current read position in data field
87     int dataLen;         //  length of data buffer
89     URI uri;
91     int scheme;
93     HttpClient httpClient;
95 }; // class UriInputStream
100 /**
101  * This class is for receiving a stream of formatted data from a resource
102  * defined in a URI
103  */
104 class UriReader : public Reader
107 public:
109     UriReader(const URI &source) throw(StreamException);
111     virtual ~UriReader() throw(StreamException);
113     virtual int available() throw(StreamException);
115     virtual void close() throw(StreamException);
117     virtual int get() throw(StreamException);
119 private:
121     UriInputStream *inputStream;
123 }; // class UriReader
127 //#########################################################################
128 //# U R I    O U T P U T    S T R E A M    /    W R I T E R
129 //#########################################################################
131 /**
132  * This class is for sending a stream to a destination resource
133  * defined in a URI
134  *
135  */
136 class UriOutputStream : public OutputStream
139 public:
141     UriOutputStream(const URI &destination) throw(StreamException);
143     virtual ~UriOutputStream() throw(StreamException);
145     virtual void close() throw(StreamException);
147     virtual void flush() throw(StreamException);
149     virtual void put(XMLCh ch) throw(StreamException);
151 private:
153     void init() throw(StreamException); //common code called by constructor
155     bool closed;
156     bool ownsFile;
158     FILE *outf;     //for file: uris
159     DOMString data; //for data: uris
161     URI uri;
163     int scheme;
165     HttpClient httpClient;
167 }; // class UriOutputStream
173 /**
174  * This class is for sending a stream of formatted data to a resource
175  * defined in a URI
176  */
177 class UriWriter : public Writer
180 public:
182     UriWriter(const URI &source) throw(StreamException);
184     virtual ~UriWriter() throw(StreamException);
186     virtual void close() throw(StreamException);
188     virtual void flush() throw(StreamException);
190     virtual void put(XMLCh ch) throw(StreamException);
192 private:
194     UriOutputStream *outputStream;
196 }; // class UriReader
203 }  //namespace io
204 }  //namespace dom
205 }  //namespace w3c
206 }  //namespace org
208 /*#########################################################################
209 ## E N D    O F    F I L E
210 #########################################################################*/
213 #endif /* __URISTREAM_H__ */