00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef INCL_PLDATASRC
00012 #define INCL_PLDATASRC
00013
00014 #include "plexcept.h"
00015 #include "plpaintlibdefs.h"
00016
00017 #ifndef AFX_PLOBJECT_H__E40881E3_C809_11D3_97BC_0050046F615E__INCLUDED_
00018 #include "plobject.h"
00019 #endif
00020
00021 class PLIProgressNotification;
00022
00023
00024
00025
00026
00027 class PLDataSource : public PLObject
00028 {
00029
00030 public:
00031
00032
00033
00034 PLDataSource
00035 ( PLIProgressNotification * pNotification = NULL
00036 );
00037
00038
00039 virtual ~PLDataSource
00040 ();
00041
00042
00043 virtual void Open
00044 ( const char * pszName,
00045 int FileSize
00046 );
00047
00048 #ifdef _WINDOWS
00049
00050 virtual void OpenW
00051 ( const wchar_t * pszwName,
00052 int FileSize
00053 );
00054 #endif
00055
00056
00057 virtual void Close
00058 ();
00059
00060
00061 char * GetName
00062 ();
00063
00064 #ifdef _WINDOWS
00065
00066 wchar_t * GetNameW
00067 ();
00068
00069
00070 bool NameIsWide
00071 ();
00072 #endif
00073
00074
00075 virtual PLBYTE * GetBufferPtr
00076 ( int MinBytesInBuffer
00077 ) = 0;
00078
00079
00080 virtual PLBYTE * ReadNBytes
00081 ( int n
00082 );
00083
00084
00085 int GetFileSize
00086 ();
00087
00088
00089
00090 virtual PLBYTE * ReadEverything
00091 () = 0;
00092
00093
00094 PLBYTE * Read1Byte
00095 ();
00096
00097
00098 PLBYTE * Read2Bytes
00099 ();
00100
00101
00102 PLBYTE * Read4Bytes
00103 ();
00104
00105
00106 void OProgressNotification
00107 ( double part
00108 );
00109
00110
00111 void AlignToWord
00112 ();
00113
00114
00115 void Skip
00116 ( int n
00117 );
00118
00119
00120 void CheckEOF
00121 ();
00122
00123 protected:
00124
00125 private:
00126 char * m_pszName;
00127
00128 #ifdef _WINDOWS
00129 wchar_t * m_pszwName;
00130 bool m_bNameIsWide;
00131 #endif
00132 int m_FileSize;
00133 int m_BytesRead;
00134 bool m_bSrcLSBFirst;
00135
00136 PLIProgressNotification * m_pNotification;
00137 };
00138
00139
00140 #ifdef _WINDOWS
00141 inline bool PLDataSource::NameIsWide
00142 ()
00143 {
00144 return m_bNameIsWide;
00145 }
00146 #endif
00147
00148 inline int PLDataSource::GetFileSize
00149 ()
00150 {
00151 return m_FileSize;
00152 }
00153
00154 inline PLBYTE * PLDataSource::Read1Byte
00155 ()
00156 {
00157 return ReadNBytes (1);
00158 }
00159
00160
00161 inline PLBYTE * PLDataSource::Read2Bytes
00162 ()
00163 {
00164 return ReadNBytes (2);
00165 }
00166
00167
00168 inline PLBYTE * PLDataSource::Read4Bytes
00169 ()
00170 {
00171 return ReadNBytes (4);
00172 }
00173
00174 inline void PLDataSource::AlignToWord
00175 ()
00176 {
00177 if (m_BytesRead & 1)
00178 Read1Byte();
00179 }
00180
00181
00182 inline void PLDataSource::Skip
00183 ( int n
00184 )
00185 {
00186 ReadNBytes (n);
00187 }
00188
00189 inline void PLDataSource::CheckEOF
00190 ()
00191 {
00192
00193 if (m_FileSize < m_BytesRead)
00194 {
00195 throw PLTextException (PL_ERREND_OF_FILE,
00196 "End of file reached while decoding.\n");
00197 }
00198 }
00199
00200 #endif
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222