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 * Authors:
38 * Bob Jamison <rjamison@titan.com>
39 *
40 * Copyright (C) 2004 Inkscape.org
41 *
42 * Released under GNU GPL, read the file 'COPYING' for more information
43 */
46 #include "uri.h"
47 #include "domstream.h"
50 namespace org
51 {
52 namespace w3c
53 {
54 namespace dom
55 {
58 //#########################################################################
59 //# U R I I N P U T S T R E A M / R E A D E R
60 //#########################################################################
62 /**
63 * This class is for receiving a stream of data from a resource
64 * defined in a URI
65 */
66 class UriInputStream : public InputStream
67 {
69 public:
71 UriInputStream(const URI &source) throw(StreamException);
73 virtual ~UriInputStream() throw(StreamException);
75 virtual int available() throw(StreamException);
77 virtual void close() throw(StreamException);
79 virtual int get() throw(StreamException);
81 private:
83 bool closed;
85 FILE *inf; //for file: uris
86 unsigned char *data; //for data: uris
87 int dataPos; // current read position in data field
88 int dataLen; // length of data buffer
90 URI uri;
92 int scheme;
94 }; // class UriInputStream
99 /**
100 * This class is for receiving a stream of formatted data from a resource
101 * defined in a URI
102 */
103 class UriReader : public Reader
104 {
106 public:
108 UriReader(const URI &source) throw(StreamException);
110 virtual ~UriReader() throw(StreamException);
112 virtual int available() throw(StreamException);
114 virtual void close() throw(StreamException);
116 virtual int get() throw(StreamException);
118 private:
120 UriInputStream *inputStream;
122 }; // class UriReader
126 //#########################################################################
127 //# U R I O U T P U T S T R E A M / W R I T E R
128 //#########################################################################
130 /**
131 * This class is for sending a stream to a destination resource
132 * defined in a URI
133 *
134 */
135 class UriOutputStream : public OutputStream
136 {
138 public:
140 UriOutputStream(const URI &destination) throw(StreamException);
142 virtual ~UriOutputStream() throw(StreamException);
144 virtual void close() throw(StreamException);
146 virtual void flush() throw(StreamException);
148 virtual void put(XMLCh ch) throw(StreamException);
150 private:
152 bool closed;
153 bool ownsFile;
155 FILE *outf; //for file: uris
156 DOMString data; //for data: uris
158 URI uri;
160 int scheme;
162 }; // class UriOutputStream
168 /**
169 * This class is for sending a stream of formatted data to a resource
170 * defined in a URI
171 */
172 class UriWriter : public Writer
173 {
175 public:
177 UriWriter(const URI &source) throw(StreamException);
179 virtual ~UriWriter() throw(StreamException);
181 virtual void close() throw(StreamException);
183 virtual void flush() throw(StreamException);
185 virtual void put(XMLCh ch) throw(StreamException);
187 private:
189 UriOutputStream *outputStream;
191 }; // class UriReader
198 } //namespace dom
199 } //namespace w3c
200 } //namespace org
202 /*#########################################################################
203 ## E N D O F F I L E
204 #########################################################################*/
207 #endif /* __URISTREAM_H__ */