~centralelyon2010/inkscape/imagelinks2

« back to all changes in this revision

Viewing changes to src/dom/io/base64stream.h

  • Committer: ishmal
  • Date: 2006-04-12 13:25:21 UTC
  • Revision ID: ishmal@users.sourceforge.net-20060412132521-5ynoezpwbzq4d1c3
Add new rearranged /dom directory

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef __DOM_IO_BASE64STREAM_H__
 
2
#define __DOM_IO_BASE64STREAM_H__
 
3
 
 
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
 */
 
34
 
 
35
 
 
36
 
 
37
#include "domstream.h"
 
38
 
 
39
 
 
40
namespace org
 
41
{
 
42
namespace w3c
 
43
{
 
44
namespace dom
 
45
{
 
46
namespace io
 
47
{
 
48
 
 
49
 
 
50
 
 
51
//#########################################################################
 
52
//# B A S E 6 4     I N P U T    S T R E A M
 
53
//#########################################################################
 
54
 
 
55
/**
 
56
 * This class is for decoding a Base-64 encoded InputStream source
 
57
 *
 
58
 */
 
59
class Base64InputStream : public BasicInputStream
 
60
{
 
61
 
 
62
public:
 
63
 
 
64
    Base64InputStream(InputStream &sourceStream);
 
65
 
 
66
    virtual ~Base64InputStream();
 
67
 
 
68
    virtual int available();
 
69
 
 
70
    virtual void close();
 
71
 
 
72
    virtual int get();
 
73
 
 
74
private:
 
75
 
 
76
    int outBytes[3];
 
77
 
 
78
    int outCount;
 
79
 
 
80
    int padCount;
 
81
 
 
82
    bool done;
 
83
 
 
84
}; // class Base64InputStream
 
85
 
 
86
 
 
87
 
 
88
 
 
89
//#########################################################################
 
90
//# B A S E 6 4   O U T P U T    S T R E A M
 
91
//#########################################################################
 
92
 
 
93
/**
 
94
 * This class is for Base-64 encoding data going to the
 
95
 * destination OutputStream
 
96
 *
 
97
 */
 
98
class Base64OutputStream : public BasicOutputStream
 
99
{
 
100
 
 
101
public:
 
102
 
 
103
    Base64OutputStream(OutputStream &destinationStream);
 
104
 
 
105
    virtual ~Base64OutputStream();
 
106
 
 
107
    virtual void close();
 
108
 
 
109
    virtual void flush();
 
110
 
 
111
    virtual void put(int ch);
 
112
 
 
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; }
 
119
 
 
120
private:
 
121
 
 
122
    void putCh(int ch);
 
123
 
 
124
    int column;
 
125
 
 
126
    int columnWidth;
 
127
 
 
128
    unsigned long outBuf;
 
129
 
 
130
    int bitCount;
 
131
 
 
132
}; // class Base64OutputStream
 
133
 
 
134
 
 
135
 
 
136
 
 
137
 
 
138
 
 
139
 
 
140
}  //namespace io
 
141
}  //namespace dom
 
142
}  //namespace w3c
 
143
}  //namespace org
 
144
 
 
145
 
 
146
#endif /* __INKSCAPE_IO_BASE64STREAM_H__ */