Classes | Namespaces | Defines

AbstractInputStream.h File Reference

#include <zeusbase/System/Interfaces/IInputStream.hpp>
#include <zeusbase/System/ZObject.h>

Go to the source code of this file.

Classes

class  zeus::TAbstractInputStream

Namespaces

namespace  zeus

Defines

#define READ_PRIMITIVE_DATA(datatype)
 reading data depending on the primitive data type
#define READ_ARRAY_DATA(array)
 reading an array
#define READ_STRING_DATA(rstrData)
 Reading a string.
#define SKIP_READING_DATA(iBytes)
 Skipping data.

Define Documentation

#define READ_ARRAY_DATA (   array )
Value:
Retval retValue = RET_NOERROR; \
  bool bError = false; \
  Int iSize = readInt32(&bError); \
  if (bError) \
  { \
    retValue = RET_REQUEST_FAILED; \
  } \
  else if (iSize > 0) \
  { \
    TArrayPtr<char> ptrBuffer(new char[iSize], iSize); \
    ptrBuffer.clean(); \
    Int iTotalReceived = 0; \
    while(iSize > iTotalReceived && retValue == RET_NOERROR) \
    { \
      Int iReceived = 0; \
      Int iSizeToRead = iSize-iTotalReceived; \
      char* pHead = static_cast<char*>(ptrBuffer.getPointer() + iTotalReceived); \
      retValue = this->read(pHead, iSizeToRead, iReceived); \
      iTotalReceived += iReceived; \
    } \
    array.setArray(ptrBuffer, iSize); \
  } \
  return retValue;

reading an array

#define READ_PRIMITIVE_DATA (   datatype )
Value:
Retval retError = RET_REQUEST_FAILED; \
  datatype tValue  = 0; \
  Int iSize       = sizeof(datatype); \
  Int iValidSize  = 0; \
  char* pBuffer   = (char*)&tValue; \
  if (this->read(pBuffer, iSize, iValidSize) == RET_NOERROR && iSize == iValidSize) \
  { \
    retError = RET_NOERROR; \
  } \
  \
  if (pError != NULL) \
  { \
    *pError = (retError != RET_NOERROR); \
  } \
  return tValue;

reading data depending on the primitive data type

#define READ_STRING_DATA (   rstrData )
Value:
rstrData.clear(); \
  Retval retValue = RET_NOERROR; \
  bool bError = false; \
  Int iStringSize = readInt32(&bError); \
  if (bError) \
  { \
    retValue = RET_REQUEST_FAILED; \
  } \
  else if (iStringSize > 0) \
  { \
    TArrayPtr<wchar_t> ptrWcBuffer(new wchar_t[iStringSize + 1], iStringSize + 1); \
    ptrWcBuffer.clean(); \
    Int iBufferSize = iStringSize * 2; \
    TArrayPtr<char> ptrCBuffer(new char[iBufferSize+1], iBufferSize + 1); \
    ptrCBuffer.clean(); \
    Int iValidSize = 0; \
    retValue = this->read(ptrCBuffer, iBufferSize, iValidSize); \
    for(Int i = 0, j = 0; i < iValidSize; i += 2, j++) \
    { \
      char c1 = ptrCBuffer[i]; \
      char c2 = ptrCBuffer[i+1]; \
      wchar_t wc1 = (wchar_t)(c1 | (c2 << 8)); \
      ptrWcBuffer[j] = wc1; \
    } \
    rstrData.assign(ptrWcBuffer); \
  } \
  return retValue;

Reading a string.

#define SKIP_READING_DATA (   iBytes )
Value:
bool bRetval = false; \
  if (iBytes > 0) \
  { \
    TArrayPtr<char> ptrBuffer = new char[iBytes]; \
    Int iValidSize = 0; \
    if (this->read(ptrBuffer.getPointer(), iBytes, iValidSize) == RET_NOERROR) \
    { \
      bRetval = true; \
    } \
  } \
  return bRetval;

Skipping data.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


Written by Benjamin Hadorn http://www.xatlantis.ch.
Last change made on Sun Jan 22 2012 15:28:17