~centralelyon2010/inkscape/imagelinks2

« back to all changes in this revision

Viewing changes to src/dom/io/bufferstream.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 __BUFFERSTREAM_H__
 
2
#define __BUFFERSTREAM_H__
 
3
/**
 
4
 * Phoebe DOM Implementation.
 
5
 *
 
6
 * This is a C++ approximation of the W3C DOM model, which follows
 
7
 * fairly closely the specifications in the various .idl files, copies of
 
8
 * which are provided for reference.  Most important is this one:
 
9
 *
 
10
 * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html
 
11
 *
 
12
 * Authors:
 
13
 *   Bob Jamison
 
14
 *
 
15
 * Copyright (C) 2006 Bob Jamison
 
16
 *
 
17
 *  This library is free software; you can redistribute it and/or
 
18
 *  modify it under the terms of the GNU Lesser General Public
 
19
 *  License as published by the Free Software Foundation; either
 
20
 *  version 2.1 of the License, or (at your option) any later version.
 
21
 *
 
22
 *  This library is distributed in the hope that it will be useful,
 
23
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
24
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
25
 *  Lesser General Public License for more details.
 
26
 *
 
27
 *  You should have received a copy of the GNU Lesser General Public
 
28
 *  License along with this library; if not, write to the Free Software
 
29
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
30
 */
 
31
 
 
32
 
 
33
#include "domstream.h"
 
34
 
 
35
 
 
36
namespace org
 
37
{
 
38
namespace w3c
 
39
{
 
40
namespace dom
 
41
{
 
42
namespace io
 
43
{
 
44
 
 
45
 
 
46
//#########################################################################
 
47
//# S T R I N G    I N P U T    S T R E A M
 
48
//#########################################################################
 
49
 
 
50
/**
 
51
 * This class is for reading character from a DOMString
 
52
 *
 
53
 */
 
54
class BufferInputStream : public InputStream
 
55
{
 
56
 
 
57
public:
 
58
 
 
59
    BufferInputStream(const std::vector<unsigned char> &sourceBuffer);
 
60
 
 
61
    virtual ~BufferInputStream();
 
62
 
 
63
    virtual int available();
 
64
 
 
65
    virtual void close();
 
66
 
 
67
    virtual int get();
 
68
 
 
69
private:
 
70
 
 
71
    const std::vector<unsigned char> &buffer;
 
72
 
 
73
    long position;
 
74
 
 
75
    bool closed;
 
76
 
 
77
}; // class BufferInputStream
 
78
 
 
79
 
 
80
 
 
81
 
 
82
//#########################################################################
 
83
//# B U F F E R     O U T P U T    S T R E A M
 
84
//#########################################################################
 
85
 
 
86
/**
 
87
 * This class is for sending a stream to a character buffer
 
88
 *
 
89
 */
 
90
class BufferOutputStream : public OutputStream
 
91
{
 
92
 
 
93
public:
 
94
 
 
95
    BufferOutputStream();
 
96
 
 
97
    virtual ~BufferOutputStream();
 
98
 
 
99
    virtual void close();
 
100
 
 
101
    virtual void flush();
 
102
 
 
103
    virtual void put(XMLCh ch);
 
104
 
 
105
    virtual std::vector<unsigned char> &getBuffer()
 
106
        { return buffer; }
 
107
 
 
108
    virtual void clear()
 
109
        { buffer.clear(); }
 
110
 
 
111
private:
 
112
 
 
113
    std::vector<unsigned char> buffer;
 
114
 
 
115
    bool closed;
 
116
 
 
117
 
 
118
}; // class BufferOutputStream
 
119
 
 
120
 
 
121
 
 
122
 
 
123
 
 
124
 
 
125
 
 
126
}  //namespace io
 
127
}  //namespace dom
 
128
}  //namespace w3c
 
129
}  //namespace org
 
130
 
 
131
 
 
132
 
 
133
#endif /* __BUFFERSTREAM_H__ */