qse/ase/com/Buffer.cpp

60 lines
1.1 KiB
C++
Raw Normal View History

2006-12-09 11:50:08 +00:00
/*
2006-12-10 16:13:50 +00:00
* $Id: Buffer.cpp,v 1.4 2006-12-10 16:13:50 bacon Exp $
2006-12-09 11:50:08 +00:00
*/
#include "stdafx.h"
#include "Buffer.h"
CBuffer::CBuffer ()
{
#ifdef _DEBUG
TCHAR x[128];
2006-12-09 17:36:27 +00:00
_sntprintf (x, 128, _T("CBuffer::CBuffer %p"), this);
2006-12-09 11:50:08 +00:00
MessageBox (NULL, x, x, MB_OK);
#endif
2006-12-10 05:59:52 +00:00
str = NULL;
2006-12-09 11:50:08 +00:00
}
CBuffer::~CBuffer ()
{
#ifdef _DEBUG
TCHAR x[128];
_sntprintf (x, 128, _T("CBuffer::~CBuffer %p"), this);
MessageBox (NULL, x, x, MB_OK);
#endif
2006-12-10 05:59:52 +00:00
if (str != NULL) SysFreeString (str);
2006-12-09 11:50:08 +00:00
}
2006-12-10 05:59:52 +00:00
STDMETHODIMP CBuffer::get_Value (BSTR *pVal)
2006-12-09 11:50:08 +00:00
{
2006-12-10 05:59:52 +00:00
if (str == NULL) *pVal = NULL;
else
{
BSTR tmp = SysAllocStringLen(str, SysStringLen(str));
if (tmp == NULL) return E_OUTOFMEMORY;
*pVal = tmp;
}
2006-12-09 11:50:08 +00:00
return S_OK;
}
2006-12-10 05:59:52 +00:00
STDMETHODIMP CBuffer::put_Value (BSTR newVal)
2006-12-09 11:50:08 +00:00
{
2006-12-10 05:59:52 +00:00
if (str != NULL) SysFreeString (str);
if (newVal == NULL) str = newVal;
else
{
str = SysAllocStringLen (newVal, SysStringLen(newVal));
if (str == NULL) return E_OUTOFMEMORY;
}
2006-12-09 11:50:08 +00:00
return S_OK;
}
2006-12-10 16:13:50 +00:00
BOOL CBuffer::PutValue (const TCHAR* val, SIZE_T len)
{
if (str != NULL) SysFreeString (str);
str = SysAllocStringLen (val, len);
return (str == NULL)? FALSE: TRUE;
}