You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
996 B
44 lines
996 B
|
|
#define MAXOVERFLOWBYTES 16
|
|
|
|
class CINetCodeConverter
|
|
{
|
|
public:
|
|
CINetCodeConverter();
|
|
~CINetCodeConverter() {}
|
|
HRESULT GetStringSizeA(BYTE const* pbySource, long lSourceSize, long* plDestSize);
|
|
HRESULT ConvertStringA(BYTE const* pbySource, long lSourceSize, BYTE* pbyDest, long lDestSize, long* lConvertedSize = NULL);
|
|
|
|
private:
|
|
BOOL fOutputMode;
|
|
BYTE* pbyOutput;
|
|
long lOutputLimit;
|
|
long lNumOutputBytes;
|
|
int nNumOverflowBytes;
|
|
BYTE OverflowBuffer[MAXOVERFLOWBYTES];
|
|
|
|
HRESULT WalkString(BYTE const* pbySource, long lSourceSize, long* lConvertedSize);
|
|
HRESULT EndOfDest(BYTE by);
|
|
HRESULT OutputOverflowBuffer();
|
|
|
|
protected:
|
|
virtual HRESULT ConvertByte(BYTE by) = 0;
|
|
virtual HRESULT CleanUp() {return S_OK;}
|
|
|
|
protected:
|
|
inline HRESULT Output(BYTE by)
|
|
{
|
|
HRESULT hr = S_OK;
|
|
|
|
if (fOutputMode) {
|
|
if (lNumOutputBytes < lOutputLimit)
|
|
*pbyOutput++ = by;
|
|
else
|
|
hr = EndOfDest(by);
|
|
}
|
|
|
|
lNumOutputBytes++;
|
|
|
|
return hr;
|
|
}
|
|
};
|