<< Return to Main Index

< Return to Class Index

CGXExcelHandler::ReadFromStream

virtual BOOL ReadFromStream(IStream* pStream, gxexpointer p, DWORD dwLength);

pStream

The stream pointer from which data is to be read.

p

Pointer that has the Objective Grid data structure to which the data that is read from the stream is to be applied.

dwLength

The length of data that can be read

Remarks

When read from stream is called the actual read normally takes place as a two phase operation. In phase one the data is read in. After this the base class is called. The base class based on the type of data that is passed in (of type gxexpointer) will decide the initialization funtion that needs to be called. Initialization functions exist for CGXData, CGXGridParam, CGXStyle and CGXGridCore.

gxexpointer is defined as shown below:

struct gxexpointer
{
// default is core pointer
   gxexpointer(void* pv):vt(nullPtr)
   gxexpointer():vt(corePtr)
   gxexpointer(CGXGridCore* p)
   virtual ~gxexpointer()
   gxexType vt;

   union
   {
      CGXGridCore* pCore;
      CGXGridParam* pParam;
      CGXStyle* pStyle;
      CGXData* pData;
      };
   };

It holds the type of pointer and the actual pointer (very similar to a VARIANT data structure)

Another point is that the data length that is passed in includes the fixed header length for each record. The fixed header length is not be read by the object. So the actual number of bytes that the object will read will be this value minus 4. If there are trailing bytes that the object wishes to ignore then it can leave these unread. The calling code from CGXExcelReader knows the offsets and will correctly do a seek so that errors when reading following fields are prevented. This mechanism also ensures that errors in the read of one field are not propagated. If you read more bytes than you should then this will not help and the read operation will most likely fail.

See Also

CGXExcelHandler::WriteToStream CGXExcelHandler::InitializeCore CGXExcelHandler::InitializeParam CGXExcelHandler::InitializeStyle CGXExcelHandler::InitializeData

CGXExcelHandler

Class Overview | Class Members