#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory>
#include "p6rgx.h"
using namespace P6R;
namespace {
{
public:
{
if (!ppIface) return eAccessFault;
*ppIface = NULL;
if(iid == IID_p6ICom) *ppIface =
static_cast<p6IDataStream*
>(
this);
else if(iid == IID_p6IDataStream) *ppIface =
static_cast<p6IDataStream*
>(
this);
else return eNoInterface;
return eOk;
}
{
return m_cRef++;
}
{
if(0 == (tmp = (--m_cRef))) { delete this; }
return tmp;
}
{
return eOk;
}
{
if (m_cBuffer && cData+1 > m_cBuffer)
{
free( m_pBuffer );
m_pBuffer = NULL;
m_cBuffer = 0;
}
if (!m_pBuffer)
{
m_pBuffer = (
P6CHAR*) malloc(cData+1);
m_cBuffer = cData;
}
if (m_pBuffer)
{
memcpy( m_pBuffer, pData, cData );
m_pBuffer[cData] = '\0';
printf( m_pBuffer );
}
return eOk;
}
{
CConsoleStream *pObj = NULL;
if(NULL != pOuter) return eNoAgregation;
if(NULL == ppIface) return eAccessFault;
*ppIface = NULL;
if (NULL != (pObj = new (std::nothrow) CConsoleStream() ))
{
pObj->addref();
err = pObj->queryInterface( iid, ppIface );
pObj->release();
}
return err;
}
CConsoleStream() : m_cRef(0), m_pBuffer(NULL), m_cBuffer(0) {;}
virtual ~CConsoleStream() { if (m_pBuffer) free(m_pBuffer); }
protected:
};
{
if (
P6FAILED( err )) printf(
"1 - Expected 0 but got %x\n", err );
offset = 0;
strLength = 0;
if (
P6FAILED( err )) printf(
"2 - Expected 0 but got %x\n", err );
if (!(0 == offset && 13 == strLength)) printf( "3 - Expected 0,13 but got %d,%d\n", offset, strLength );
if (
P6FAILED( err )) printf(
"4 - Expected 0 but got %x\n", err );
offset = 0;
strLength = 0;
if (
P6FAILED( err )) printf(
"5 - Expected 0 but got %x\n", err );
if (!(0 == offset && 14 == strLength)) printf( "6 - Expected 0,14 but got %d,%d\n", offset, strLength );
if (
P6FAILED( err )) printf(
"7 - Expected 0 but got %x\n", err );
if (
P6FAILED( err )) printf(
"8 - Expected 0 but got %x\n", err );
if (
P6FAILED( err )) printf(
"9 - Expected 0 but got %x\n", err );
offset = 0;
strLength = 0;
if (
P6FAILED( err )) printf(
"10 - Expected 0 but got %x\n", err );
if (!(0 == offset && 0 == strLength)) printf( "11 - Expected 0,0 but got %d,%d\n", offset, strLength );
if (
P6FAILED( err )) printf(
"12 - Expected 0 but got %x\n", err );
if (
P6FAILED( err )) printf(
"13 - Expected 0 but got %x\n", err );
if (
P6FAILED( err )) printf(
"14 - Expected 0 but got %x\n", err );
if (
P6FAILED( err )) printf(
"15 - Expected 0 but got %x\n", err );
return err;
}
}
int main(int argc,char *argv[])
{
{
{
err = runRegex( cpDataStream );
}
else printf("ERROR: Failed to initialize the loader [ %x ]\n", err );
}
else printf( "ERROR: Failed to create CConsoleStream [ %x ]\n", err );
return err;
}