#include "ccontenthandler.h"
using namespace P6R;
namespace P6EXAMPLES {
CContentHandler::CContentHandler() : m_bInitialized(
P6FALSE ),
m_cpStr( ),
m_cpConsole( ),
m_cpLoc( ),
m_startPair( 0 ),
m_value( 0 ),
m_startObj( 0 ),
m_startArray( 0 )
{ }
CContentHandler::~CContentHandler()
{
}
{
if (m_bInitialized) return eAlreadyInitialized;
if (!pConsole || !pStr ) return eInvalidArg;
m_cpConsole = pConsole;
m_cpStr = pStr;
return eOk;
}
{
if (!m_bInitialized) return eNotInitialized;
m_cpConsole->writeStdout("-> hit endDocument()\n",NULL,0,NULL);
return eOk;
}
{
if (!m_bInitialized) return eNotInitialized;
m_cpConsole->writeStdout("-> entered endObject() %1$ %2$\n",&args[0],2,NULL);
if (0 != (nestingLevel - m_startObj)) {
m_cpConsole->writeStdout("-> Error: endObject - expected 0 but got %d\n",&args[0],1,NULL);
}
m_startObj--;
return eOk;
}
{
if (!m_bInitialized) return eNotInitialized;
m_cpConsole->writeStdout("-> entered endArray() %1$ %2$\n",&args[0],2,NULL);
if (0 != (nestingLevel - m_startArray)) {
m_cpConsole->writeStdout("-> Error: endArray - expected 0 but got %1$",&args[0],1,NULL);
}
m_startArray--;
return eOk;
}
{
if (!m_bInitialized) return eNotInitialized;
if (NULL == pObject) return eInvalidArg;
m_cpLoc = pObject;
return eOk;
}
{
if (!m_bInitialized) return eNotInitialized;
m_cpConsole->writeStdout("-> entered startDocument()\n",NULL,0,NULL);
return eOk;
}
{
if (!m_bInitialized) return eNotInitialized;
m_cpConsole->writeStdout("-> entered startObject() %1$ %2$\n",&args[0],2,NULL);
if (1 != (nestingLevel - m_startObj)) {
m_cpConsole->writeStdout("-> Error: startObj - expected 1 but got %1$",&args[0],1,NULL);
}
m_startObj++;
return eOk;
}
{
if (!m_bInitialized) return eNotInitialized;
m_cpConsole->writeStdout("-> entered startPair() [ %1$ ] %2$\n",&args[0],2,NULL);
switch( m_startPair ) {
case 0:
m_cpConsole->writeStdout("-> Error: startPair - expected 6 but got %1$",&args[0],1,NULL);
}
err = m_cpStr->strncmp(
"\"menu\"", pName->
pStart, 6, &iResult );
if (0 != iResult) {
m_cpConsole->writeStdout("-> Error: startPair - expected 0 but got %1$",&args[0],1,NULL);
}
m_startPair++;
break;
case 1:
m_cpConsole->writeStdout("-> Error: startPair - expected 4 but got %1$",&args[0],1,NULL);
}
err = m_cpStr->strncmp(
"\"id\"", pName->
pStart, 4, &iResult );
if (0 != iResult) {
m_cpConsole->writeStdout("-> Error: startPair - expected 0 but got %1$",&args[0],1,NULL);
}
m_startPair++;
break;
case 2: case 5: case 7: case 9:
m_cpConsole->writeStdout("-> Error: startPair - expected 7 but got %1$",&args[0],1,NULL);
}
err = m_cpStr->strncmp(
"\"value\"", pName->
pStart, 7, &iResult );
if (0 != iResult) {
m_cpConsole->writeStdout("-> Error: startPair - expected 0 but got %1$",&args[0],1,NULL);
}
m_startPair++;
break;
case 3:
m_cpConsole->writeStdout("-> Error: startPair - expected 7 but got %1$",&args[0],1,NULL);
}
err = m_cpStr->strncmp(
"\"popup\"", pName->
pStart, 7, &iResult );
if (0 != iResult) {
m_cpConsole->writeStdout("-> Error: startPair - expected 0 but got %1$",&args[0],1,NULL);
}
m_startPair++;
break;
case 4:
m_cpConsole->writeStdout("-> Error: startPair - expected 10 but got %1$",&args[0],1,NULL);
}
err = m_cpStr->strncmp(
"\"menuitem\"", pName->
pStart, 10, &iResult );
if (0 != iResult) {
m_cpConsole->writeStdout("-> Error: startPair - expected 0 but got %1$",&args[0],1,NULL);
}
m_startPair++;
break;
case 6: case 8: case 10:
m_cpConsole->writeStdout("-> Error: startPair - expected 9 but got %1$",&args[0],1,NULL);
}
err = m_cpStr->strncmp(
"\"onclick\"", pName->
pStart, 9, &iResult );
if (0 != iResult) {
m_cpConsole->writeStdout("-> Error: startPair - expected 0 but got %1$",&args[0],1,NULL);
}
m_startPair++;
break;
case 11:
m_cpConsole->writeStdout("-> Error: startPair - expected 10 but got %1$",&args[0],1,NULL);
}
err = m_cpStr->strncmp(
"\"readings\"", pName->
pStart, 10, &iResult );
if (0 != iResult) {
m_cpConsole->writeStdout("-> Error: startPair - expected 0 but got %1$",&args[0],1,NULL);
}
m_startPair++;
break;
case 12:
m_cpConsole->writeStdout("-> Error: startPair - expected 9 but got %1$",&args[0],1,NULL);
}
err = m_cpStr->strncmp(
"\"encoded\"", pName->
pStart, 9, &iResult );
if (0 != iResult) {
m_cpConsole->writeStdout("-> Error: startPair - expected 0 but got %1$",&args[0],1,NULL);
}
m_startPair++;
break;
default:
m_cpConsole->writeStdout("Error: startPair out of range got [ %1$ ]\n",&args[0],1,NULL);
break;
}
return eOk;
}
{
if (!m_bInitialized) return eNotInitialized;
m_cpConsole->writeStdout("-> entered startArray() %1$\n",&args[0],1,NULL);
if (1 != (nestingLevel - m_startArray)) {
m_cpConsole->writeStdout("-> Error: startArray - expected 1 but got %1$",&args[0],1,NULL);
}
m_startArray++;
return eOk;
}
{
if (!m_bInitialized) return eNotInitialized;
m_cpConsole->writeStdout("-> entered value() %1$ %2$\n",&args[0],2,NULL);
switch( m_value ) {
case 0:
m_cpConsole->writeStdout("-> ERROR: value - %1$ but got %2$",&args[0],2,NULL);
}
m_cpConsole->writeStdout("-> ERROR: value - 6 but got %1$",&args[0],1,NULL);
}
err = m_cpStr->strncmp(
"\"file\"", pValue->
jstring.
pStart, 6, &iResult );
if (0 != iResult) {
m_cpConsole->writeStdout("-> Error: value - expected 0 but got %1$",&args[0],1,NULL);
}
m_value++;
break;
case 1:
m_cpConsole->writeStdout("-> ERROR: value - %1$ but got %2$",&args[0],2,NULL);
}
m_cpConsole->writeStdout("-> ERROR: value - 6 but got %1$",&args[0],1,NULL);
}
err = m_cpStr->strncmp(
"\"File\"", pValue->
jstring.
pStart, 6, &iResult );
if (0 != iResult) {
m_cpConsole->writeStdout("-> Error: value - expected 0 but got %1$",&args[0],1,NULL);
}
m_value++;
break;
case 2:
m_cpConsole->writeStdout("-> ERROR: value - %1$ but got %2$",&args[0],2,NULL);
}
m_cpConsole->writeStdout("-> ERROR: value - 5 but got %1$",&args[0],1,NULL);
}
err = m_cpStr->strncmp(
"\"New\"", pValue->
jstring.
pStart, 5, &iResult );
if (0 != iResult) {
m_cpConsole->writeStdout("-> Error: value - expected 0 but got %1$",&args[0],1,NULL);
}
m_value++;
break;
case 3:
m_cpConsole->writeStdout("-> ERROR: value - %1$ but got %2$",&args[0],2,NULL);
}
m_cpConsole->writeStdout("-> ERROR: value - 16 but got %1$",&args[0],1,NULL);
}
err = m_cpStr->strncmp(
"\"CreateNewDoc()\"", pValue->
jstring.
pStart, 16, &iResult );
if (0 != iResult) {
m_cpConsole->writeStdout("-> Error: value - expected 0 but got %1$",&args[0],1,NULL);
}
m_value++;
break;
case 4:
m_cpConsole->writeStdout("-> ERROR: value - %1$ but got %2$",&args[0],2,NULL);
}
m_cpConsole->writeStdout("-> ERROR: value - 6 but got %1$",&args[0],1,NULL);
}
err = m_cpStr->strncmp(
"\"Open\"", pValue->
jstring.
pStart, 6, &iResult );
if (0 != iResult) {
m_cpConsole->writeStdout("-> Error: value - expected 0 but got %1$",&args[0],1,NULL);
}
m_value++;
break;
case 5:
m_cpConsole->writeStdout("-> ERROR: value - %1$ but got %2$",&args[0],2,NULL);
}
m_cpConsole->writeStdout("-> ERROR: value - 11 but got %1$",&args[0],1,NULL);
}
err = m_cpStr->strncmp(
"\"OpenDoc()\"", pValue->
jstring.
pStart, 11, &iResult );
if (0 != iResult) {
m_cpConsole->writeStdout("-> Error: value - expected 0 but got %1$",&args[0],1,NULL);
}
m_value++;
break;
case 6:
m_cpConsole->writeStdout("-> ERROR: value - %1$ but got %2$",&args[0],2,NULL);
}
m_cpConsole->writeStdout("-> ERROR: value - 7 but got %1$",&args[0],1,NULL);
}
err = m_cpStr->strncmp(
"\"Close\"", pValue->
jstring.
pStart, 7, &iResult );
if (0 != iResult) {
m_cpConsole->writeStdout("-> Error: value - expected 0 but got %1$",&args[0],1,NULL);
}
m_value++;
break;
case 7:
m_cpConsole->writeStdout("-> ERROR: value - %1$ but got %2$",&args[0],2,NULL);
}
m_cpConsole->writeStdout("-> ERROR: value - 12 but got %1$",&args[0],1,NULL);
}
err = m_cpStr->strncmp(
"\"CloseDoc()\"", pValue->
jstring.
pStart, 12, &iResult );
if (0 != iResult) {
m_cpConsole->writeStdout("-> Error: value - expected 0 but got %1$",&args[0],1,NULL);
}
m_value++;
break;
case 8:
m_cpConsole->writeStdout("-> ERROR: value - %1$ but got %2$",&args[0],2,NULL);
}
m_cpConsole->writeStdout("-> ERROR: value - 3 but got %1$",&args[0],1,NULL);
}
err = m_cpStr->strncmp(
"-30", pValue->
jstring.
pStart, 3, &iResult );
if (0 != iResult) {
m_cpConsole->writeStdout("-> Error: value - expected 0 but got %1$",&args[0],1,NULL);
}
m_cpConsole->writeStdout("-> ERROR: value - -30 but got %1$",&args[0],1,NULL);
}
m_value++;
break;
case 9:
m_cpConsole->writeStdout("-> ERROR: value - %1$ but got %2$",&args[0],2,NULL);
}
m_cpConsole->writeStdout("-> ERROR: value - 2 but got %1$",&args[0],1,NULL);
}
err = m_cpStr->strncmp(
"44", pValue->
jstring.
pStart, 2, &iResult );
if (0 != iResult) {
m_cpConsole->writeStdout("-> Error: value - expected 0 but got %1$",&args[0],1,NULL);
}
m_cpConsole->writeStdout("-> ERROR: value - 44 but got %1$",&args[0],1,NULL);
}
m_value++;
break;
case 10:
m_cpConsole->writeStdout("-> ERROR: value - %1$ but got %2$",&args[0],2,NULL);
}
m_cpConsole->writeStdout("-> ERROR: value - 6 but got %1$",&args[0],1,NULL);
}
err = m_cpStr->strncmp(
"100.34", pValue->
jstring.
pStart, 6, &iResult );
if (0 != iResult) {
m_cpConsole->writeStdout("-> Error: value - expected 0 but got %1$",&args[0],1,NULL);
}
if ((100.34) != pValue->
real) {
m_cpConsole->writeStdout("-> ERROR: value - 100.34 but got %1$",&args[0],1,NULL);
}
m_value++;
break;
case 11:
m_cpConsole->writeStdout("-> ERROR: value - %1$ but got %2$",&args[0],2,NULL);
}
m_cpConsole->writeStdout("-> ERROR: value - 5 but got %1$",&args[0],1,NULL);
}
err = m_cpStr->strncmp(
"3.5E4", pValue->
jstring.
pStart, 5, &iResult );
if (0 != iResult) {
m_cpConsole->writeStdout("-> Error: value - expected 0 but got %1$",&args[0],1,NULL);
}
if (35000 != pValue->
real) {
m_cpConsole->writeStdout("-> ERROR: value - 35000 but got %1$",&args[0],1,NULL);
}
m_value++;
break;
case 12:
m_cpConsole->writeStdout("-> ERROR: value - %1$ but got %2$",&args[0],2,NULL);
}
m_cpConsole->writeStdout("-> ERROR: value - 6 but got %1$",&args[0],1,NULL);
}
err = m_cpStr->strncmp(
"3.5e-4", pValue->
jstring.
pStart, 6, &iResult );
if (0 != iResult) {
m_cpConsole->writeStdout("-> Error: value - expected 0 but got %1$",&args[0],1,NULL);
}
if ((0.000350) != pValue->
real) {
m_cpConsole->writeStdout("-> ERROR: value - 0.000350 but got %1$",&args[0],1,NULL);
}
m_value++;
break;
case 13:
m_cpConsole->writeStdout("-> ERROR: value - %1$ but got %2$",&args[0],2,NULL);
}
m_cpConsole->writeStdout("-> ERROR: value - P6TRUE but got %1$",&args[0],1,NULL);
}
m_value++;
break;
case 14:
m_cpConsole->writeStdout( "-> ERROR: value14-1 - %1$ but got %2$\n",&args[0],2,NULL);
}
m_cpConsole->writeStdout("-> ERROR: value14-2 - 46 but got %1$\n",&args[0],1,NULL);
}
err = m_cpStr->strncmp(
"\"Now is \\\\ the time \\u00D8 for all \\fgood men\"", pValue->
jstring.
pStart, 46, &iResult );
if (0 != iResult) {
m_cpConsole->writeStdout("-> Error: value - expected 0 but got %1$",&args[0],1,NULL);
}
if (!m_cpLoc) m_cpConsole->writeStdout("-> ERROR: value14-4 p6IJSONLocator not set\n",NULL,0,NULL);
length = 0;
err = m_cpLoc->convertToWideString( &jstring, NULL, &length );
if (eOk != err || 47 != length) {
m_cpConsole->writeStdout("-> ERROR: value14-5 - 47 but got %1$\n",&args[0],1,NULL);
}
length = 100;
err = m_cpLoc->convertToWideString( &jstring, wideString, &length );
m_cpConsole->writeStdout("-> decocded string %1$ [%2$]\n",&args[0],2,NULL);
if (eOk != err) {
m_cpConsole->writeStdout("-> ERROR: value14-6 - eOk but got %1$\n",&args[0],1,NULL);
}
if (39 != length) {
m_cpConsole->writeStdout("-> ERROR: value14-7 - 39 but got %1$\n",&args[0],1,NULL);
}
m_cpConsole->writeStdout("-> ERROR: value14-8 - 12 but got %1$\n",&args[0],1,NULL);
}
m_cpConsole->writeStdout("-> ERROR: value14-9 - 216 but got %1$d\n",&args[0],1,NULL);
}
m_value++;
break;
default:
m_cpConsole->writeStdout("Error: value() startPair out of range got [ %1$ ]\n",&args[0],1,NULL);
break;
}
return eOk;
}
}