qse/ase/com/Buffer.cpp

52 lines
868 B
C++
Raw Normal View History

2006-12-09 11:50:08 +00:00
/*
2007-02-03 10:52:36 +00:00
* $Id: Buffer.cpp,v 1.6 2007-02-03 10:52:12 bacon Exp $
*
* {License}
2006-12-09 11:50:08 +00:00
*/
#include "stdafx.h"
#include "Buffer.h"
CBuffer::CBuffer ()
{
2006-12-10 05:59:52 +00:00
str = NULL;
2006-12-09 11:50:08 +00:00
}
CBuffer::~CBuffer ()
{
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;
}