1 #ifndef __DOM_IO_BASE64STREAM_H__
2 #define __DOM_IO_BASE64STREAM_H__
4 /**
5 * Phoebe DOM Implementation.
6 *
7 * Base64-enabled input and output streams
8 *
9 * This class allows easy encoding and decoding
10 * of Base64 data with a stream interface, hiding
11 * the implementation from the user.
12 *
13 * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html
14 *
15 * Authors:
16 * Bob Jamison
17 *
18 * Copyright (C) 2006 Bob Jamison
19 *
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License as published by the Free Software Foundation; either
23 * version 2.1 of the License, or (at your option) any later version.
24 *
25 * This library is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28 * Lesser General Public License for more details.
29 *
30 * You should have received a copy of the GNU Lesser General Public
31 * License along with this library; if not, write to the Free Software
32 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
33 */
37 #include "domstream.h"
40 namespace org
41 {
42 namespace w3c
43 {
44 namespace dom
45 {
46 namespace io
47 {
51 //#########################################################################
52 //# B A S E 6 4 I N P U T S T R E A M
53 //#########################################################################
55 /**
56 * This class is for decoding a Base-64 encoded InputStream source
57 *
58 */
59 class Base64InputStream : public BasicInputStream
60 {
62 public:
64 Base64InputStream(InputStream &sourceStream);
66 virtual ~Base64InputStream();
68 virtual int available();
70 virtual void close();
72 virtual int get();
74 private:
76 int outBytes[3];
78 int outCount;
80 int padCount;
82 bool done;
84 }; // class Base64InputStream
89 //#########################################################################
90 //# B A S E 6 4 O U T P U T S T R E A M
91 //#########################################################################
93 /**
94 * This class is for Base-64 encoding data going to the
95 * destination OutputStream
96 *
97 */
98 class Base64OutputStream : public BasicOutputStream
99 {
101 public:
103 Base64OutputStream(OutputStream &destinationStream);
105 virtual ~Base64OutputStream();
107 virtual void close();
109 virtual void flush();
111 virtual int put(XMLCh ch);
113 /**
114 * Sets the maximum line length for base64 output. If
115 * set to <=0, then there will be no line breaks;
116 */
117 virtual void setColumnWidth(int val)
118 { columnWidth = val; }
120 private:
122 void putCh(int ch);
124 int column;
126 int columnWidth;
128 unsigned long outBuf;
130 int bitCount;
132 }; // class Base64OutputStream
140 } //namespace io
141 } //namespace dom
142 } //namespace w3c
143 } //namespace org
146 #endif /* __INKSCAPE_IO_BASE64STREAM_H__ */