libpgf
7.26.45
PGF - Progressive Graphics File
Toggle main menu visibility
Loading...
Searching...
No Matches
PGFstream.h
Go to the documentation of this file.
1
/*
2
* The Progressive Graphics File; http://www.libpgf.org
3
*
4
* $Date: 2007-06-11 10:56:17 +0200 (Mo, 11 Jun 2007) $
5
* $Revision: 299 $
6
*
7
* This file Copyright (C) 2006 xeraina GmbH, Switzerland
8
*
9
* This program is free software; you can redistribute it and/or
10
* modify it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE
11
* as published by the Free Software Foundation; either version 2.1
12
* of the License, or (at your option) any later version.
13
*
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
18
*
19
* You should have received a copy of the GNU General Public License
20
* along with this program; if not, write to the Free Software
21
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
*/
23
28
29
#pragma once
30
31
#include "
PGFtypes.h
"
32
#include <new>
33
34
namespace
pgf
{
39
class
CPGFStream
{
40
public
:
43
CPGFStream
() {}
44
47
virtual
~CPGFStream
() {}
48
53
virtual
void
Write
(
int
* count,
void
* buffer) = 0;
54
59
virtual
void
Read
(
int
* count,
void
* buffer) = 0;
60
65
virtual
void
SetPos
(
short
posMode, int64_t posOff) = 0;
66
70
virtual
uint64_t
GetPos
()
const
= 0;
71
75
virtual
bool
IsValid
()
const
= 0;
76
};
77
82
class
CPGFFileStream
:
public
CPGFStream
{
83
protected
:
84
HANDLE
m_hFile
;
85
86
public
:
87
CPGFFileStream
() :
m_hFile
(0) {}
90
CPGFFileStream
(HANDLE hFile) :
m_hFile
(hFile) {}
92
HANDLE
GetHandle
() {
return
m_hFile
; }
93
94
virtual
~CPGFFileStream
() {
m_hFile
= 0; }
95
virtual
void
Write
(
int
* count,
void
* buffer);
// throws IOException
96
virtual
void
Read
(
int
* count,
void
* buffer);
// throws IOException
97
virtual
void
SetPos
(
short
posMode, int64_t posOff);
// throws IOException
98
virtual
uint64_t
GetPos
()
const
;
// throws IOException
99
virtual
bool
IsValid
()
const
{
return
m_hFile
!= 0; }
100
};
101
106
class
CPGFMemoryStream
:
public
CPGFStream
{
107
protected
:
108
uint8_t*
m_buffer
, *
m_pos
;
109
uint8_t*
m_eos
;
110
size_t
m_size
;
111
bool
m_allocated
;
112
113
public
:
116
CPGFMemoryStream
(
size_t
size);
117
121
CPGFMemoryStream
(uint8_t* pBuffer,
size_t
size);
122
126
void
Reinitialize
(uint8_t* pBuffer,
size_t
size);
127
128
virtual
~CPGFMemoryStream
() {
129
m_pos
= 0;
130
if
(
m_allocated
) {
131
// the memory buffer has been allocated inside of CPMFmemoryStream constructor
132
delete
[]
m_buffer
;
m_buffer
= 0;
133
}
134
}
135
136
virtual
void
Write
(
int
* count,
void
* buffer);
// throws IOException
137
virtual
void
Read
(
int
* count,
void
* buffer);
138
virtual
void
SetPos
(
short
posMode, int64_t posOff);
// throws IOException
139
virtual
uint64_t
GetPos
()
const
{ ASSERT(
IsValid
());
return
m_pos
-
m_buffer
; }
140
virtual
bool
IsValid
()
const
{
return
m_buffer
!= 0; }
141
143
size_t
GetSize
()
const
{
return
m_size
; }
145
const
uint8_t*
GetBuffer
()
const
{
return
m_buffer
; }
147
uint8_t*
GetBuffer
() {
return
m_buffer
; }
149
uint64_t
GetEOS
()
const
{ ASSERT(
IsValid
());
return
m_eos
-
m_buffer
; }
151
void
SetEOS
(uint64_t length) { ASSERT(
IsValid
());
m_eos
=
m_buffer
+ length; }
152
};
153
158
#ifdef _MFC_VER
159
class
CPGFMemFileStream :
public
CPGFStream {
160
protected
:
161
CMemFile* m_memFile;
162
public
:
163
CPGFMemFileStream(CMemFile* memFile) : m_memFile(memFile) {}
164
virtual
bool
IsValid()
const
{
return
m_memFile !=
nullptr
; }
165
virtual
~CPGFMemFileStream() {}
166
virtual
void
Write(
int
* count,
void
* buffer);
// throws IOException
167
virtual
void
Read(
int
* count,
void
* buffer);
// throws IOException
168
virtual
void
SetPos(
short
posMode, int64_t posOff);
// throws IOException
169
virtual
uint64_t GetPos()
const
;
// throws IOException
170
};
171
#endif
172
177
#if defined(WIN32) || defined(WINCE)
178
class
CPGFIStream :
public
CPGFStream
{
179
protected
:
180
IStream* m_stream;
181
public
:
182
CPGFIStream(IStream* stream) : m_stream(stream) { m_stream->AddRef(); }
183
virtual
bool
IsValid()
const
{
return
m_stream != 0; }
184
virtual
~CPGFIStream() { m_stream->Release(); }
185
virtual
void
Write(
int
* count,
void
* buffer);
// throws IOException
186
virtual
void
Read(
int
* count,
void
* buffer);
// throws IOException
187
virtual
void
SetPos(
short
posMode, int64_t posOff);
// throws IOException
188
virtual
uint64_t GetPos()
const
;
// throws IOException
189
IStream* GetIStream()
const
{
return
m_stream; }
190
};
191
#endif
192
}
PGFtypes.h
PGF definitions.
pgf::CPGFFileStream::Read
virtual void Read(int *count, void *buffer)
Definition
PGFstream.cpp:49
pgf::CPGFFileStream::Write
virtual void Write(int *count, void *buffer)
Definition
PGFstream.cpp:39
pgf::CPGFFileStream::GetPos
virtual uint64_t GetPos() const
Definition
PGFstream.cpp:65
pgf::CPGFFileStream::~CPGFFileStream
virtual ~CPGFFileStream()
Definition
PGFstream.h:94
pgf::CPGFFileStream::IsValid
virtual bool IsValid() const
Definition
PGFstream.h:99
pgf::CPGFFileStream::CPGFFileStream
CPGFFileStream(HANDLE hFile)
Definition
PGFstream.h:90
pgf::CPGFFileStream::GetHandle
HANDLE GetHandle()
Definition
PGFstream.h:92
pgf::CPGFFileStream::m_hFile
HANDLE m_hFile
file handle
Definition
PGFstream.h:84
pgf::CPGFFileStream::SetPos
virtual void SetPos(short posMode, int64_t posOff)
Definition
PGFstream.cpp:58
pgf::CPGFFileStream::CPGFFileStream
CPGFFileStream()
Definition
PGFstream.h:87
pgf::CPGFMemoryStream::~CPGFMemoryStream
virtual ~CPGFMemoryStream()
Definition
PGFstream.h:128
pgf::CPGFMemoryStream::SetPos
virtual void SetPos(short posMode, int64_t posOff)
Definition
PGFstream.cpp:169
pgf::CPGFMemoryStream::SetEOS
void SetEOS(uint64_t length)
Definition
PGFstream.h:151
pgf::CPGFMemoryStream::m_pos
uint8_t * m_pos
buffer start address and current buffer address
Definition
PGFstream.h:108
pgf::CPGFMemoryStream::m_eos
uint8_t * m_eos
end of stream (first address beyond written area)
Definition
PGFstream.h:109
pgf::CPGFMemoryStream::GetBuffer
uint8_t * GetBuffer()
Definition
PGFstream.h:147
pgf::CPGFMemoryStream::Read
virtual void Read(int *count, void *buffer)
Definition
PGFstream.cpp:149
pgf::CPGFMemoryStream::Write
virtual void Write(int *count, void *buffer)
Definition
PGFstream.cpp:112
pgf::CPGFMemoryStream::Reinitialize
void Reinitialize(uint8_t *pBuffer, size_t size)
Definition
PGFstream.cpp:103
pgf::CPGFMemoryStream::IsValid
virtual bool IsValid() const
Definition
PGFstream.h:140
pgf::CPGFMemoryStream::GetSize
size_t GetSize() const
Definition
PGFstream.h:143
pgf::CPGFMemoryStream::GetBuffer
const uint8_t * GetBuffer() const
Definition
PGFstream.h:145
pgf::CPGFMemoryStream::m_size
size_t m_size
buffer size
Definition
PGFstream.h:110
pgf::CPGFMemoryStream::GetEOS
uint64_t GetEOS() const
Definition
PGFstream.h:149
pgf::CPGFMemoryStream::CPGFMemoryStream
CPGFMemoryStream(size_t size)
Definition
PGFstream.cpp:79
pgf::CPGFMemoryStream::GetPos
virtual uint64_t GetPos() const
Definition
PGFstream.h:139
pgf::CPGFMemoryStream::m_allocated
bool m_allocated
indicates a new allocated buffer
Definition
PGFstream.h:111
pgf::CPGFMemoryStream::m_buffer
uint8_t * m_buffer
Definition
PGFstream.h:108
pgf::CPGFStream
Abstract stream base class.
Definition
PGFstream.h:39
pgf::CPGFStream::Write
virtual void Write(int *count, void *buffer)=0
pgf::CPGFStream::IsValid
virtual bool IsValid() const =0
pgf::CPGFStream::~CPGFStream
virtual ~CPGFStream()
Standard destructor.
Definition
PGFstream.h:47
pgf::CPGFStream::CPGFStream
CPGFStream()
Standard constructor.
Definition
PGFstream.h:43
pgf::CPGFStream::Read
virtual void Read(int *count, void *buffer)=0
pgf::CPGFStream::GetPos
virtual uint64_t GetPos() const =0
pgf::CPGFStream::SetPos
virtual void SetPos(short posMode, int64_t posOff)=0
pgf
Definition
PGFimage.h:33
include
PGFstream.h
Generated on
for libpgf by
1.18.0