1 /**
2 * Phoebe DOM Implementation.
3 *
4 * This is a C++ approximation of the W3C DOM model, which follows
5 * fairly closely the specifications in the various .idl files, copies of
6 * which are provided for reference. Most important is this one:
7 *
8 * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html
9 *
10 * Authors:
11 * Bob Jamison
12 *
13 * Copyright (C) 2005 Bob Jamison
14 *
15 * This library is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU Lesser General Public
17 * License as published by the Free Software Foundation; either
18 * version 2.1 of the License, or (at your option) any later version.
19 *
20 * This library is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * Lesser General Public License for more details.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
30 /**
31 * Our base String stream classes. We implement these to
32 * be based on DOMString
33 *
34 * Authors:
35 * Bob Jamison <rjamison@titan.com>
36 *
37 * Copyright (C) 2004 Inkscape.org
38 *
39 * Released under GNU GPL, read the file 'COPYING' for more information
40 */
43 #include "stringstream.h"
45 namespace org
46 {
47 namespace w3c
48 {
49 namespace dom
50 {
54 //#########################################################################
55 //# S T R I N G I N P U T S T R E A M
56 //#########################################################################
59 /**
60 *
61 */
62 StringInputStream::StringInputStream(const DOMString &sourceString)
63 : buffer((DOMString &)sourceString)
64 {
65 position = 0;
66 }
68 /**
69 *
70 */
71 StringInputStream::~StringInputStream()
72 {
74 }
76 /**
77 * Returns the number of bytes that can be read (or skipped over) from
78 * this input stream without blocking by the next caller of a method for
79 * this input stream.
80 */
81 int StringInputStream::available()
82 {
83 return buffer.size() - position;
84 }
87 /**
88 * Closes this input stream and releases any system resources
89 * associated with the stream.
90 */
91 void StringInputStream::close()
92 {
93 }
95 /**
96 * Reads the next byte of data from the input stream. -1 if EOF
97 */
98 int StringInputStream::get()
99 {
100 if (position >= (int)buffer.size())
101 return -1;
102 int ch = (int) buffer[position++];
103 return ch;
104 }
109 //#########################################################################
110 //# S T R I N G O U T P U T S T R E A M
111 //#########################################################################
113 /**
114 *
115 */
116 StringOutputStream::StringOutputStream()
117 {
118 }
120 /**
121 *
122 */
123 StringOutputStream::~StringOutputStream()
124 {
125 }
127 /**
128 * Closes this output stream and releases any system resources
129 * associated with this stream.
130 */
131 void StringOutputStream::close()
132 {
133 }
135 /**
136 * Flushes this output stream and forces any buffered output
137 * bytes to be written out.
138 */
139 void StringOutputStream::flush()
140 {
141 //nothing to do
142 }
144 /**
145 * Writes the specified byte to this output stream.
146 */
147 void StringOutputStream::put(XMLCh ch)
148 {
149 buffer.push_back(ch);
150 }
155 } //namespace dom
156 } //namespace w3c
157 } //namespace org
159 //#########################################################################
160 //# E N D O F F I L E
161 //#########################################################################