Main Page | Class Hierarchy | Compound List | File List | Compound Members

BxDataBinxParser.h

00001 // ##################################################################
00002 // Binx
00003 // $Id: BxDataBinxParser_8h-source.html,v 1.1.1.1 2006/04/19 14:19:02 edikt2 Exp $
00004 //
00005 // Class for splitting a DataBinx document into SchemaBinx + binary
00006 // ##################################################################
00007 /*
00008 
00009 //  edikt::BinX
00010 //  www.edikt.org
00011 //  support@edikt.org
00012 
00013 // Copyright (c) 2003 The University of Edinburgh.
00014 
00015 */
00016 
00017 #ifndef __BxDataBinxParser__
00018 #define __BxDataBinxParser__
00019 
00020 #include "BxDataset.h"
00021 #include "BxSaxHandler.h"
00022 #include "BxDataObjectStack.h"
00023 
00024 /*
00025  * Parsing a DataBinx document through SAX engine.
00026  * This module relies on Xerces C++ SAX parser.  Because a DataBinx
00027  * document may be very large in size, it is better to use a SAX parser
00028  * rather than a DOM parser as the BinX document parser uses.
00029  * The result of parsing a DataBinx document is an in-memory dataset
00030  * structure which can be saved to a SchemaBinx document, and a binary
00031  * data file automatically generated while parsing.  The binary file
00032  * is then associated with the SchemaBinx dataset.  The filename of the
00033  * binary file consists of two parts, the first part is the DataBinx
00034  * filename without extension, and the second part is a sequence number
00035  * and the extension is .bin.  For example, databinx1.bin.
00036  */
00037 class DECLSPEC BxDataBinxParser : public BxObject
00038 {
00039 public:
00040     BxDataBinxParser();
00041     virtual ~BxDataBinxParser();
00042 
00043     // event handlers for SaxHandler
00044     void startElement(const char* name);
00045     void endElement(const char* name);
00046     void startAttribute(const char* name, const char* value);
00047     void startText(const char* text);
00048 
00049     virtual char* className() const { return "BxDataBinxParser"; }
00050 
00051     bool parse(const char* databinx);
00052     void saveSchemaBinx(const char* filename, const char* binfilename = NULL);
00053 
00054     void print();   //internal testing use
00055     
00056 private:
00057     void dispatchDataObject();
00058     void expandDimCountBuffer();
00059     void clearDimCounts();
00060 
00061     //member variables
00062     BxSaxHandler* pSaxHandler_;    //SAX parser object
00063     BxDataset* pDataset_;          //the root element object pointer
00064     PointerStack stack_;            //stack object
00065     bool bDataBinxFound_;           //whether databinx element found
00066     bool bArrayFirstLoop_;      //whether a new array in processing
00067     int* pDimCounts_;      //collection of ints to hold number of elements
00068     int nMaxDims_;          //max allowed elements in the collection
00069     int nDimUpperBound_;    //real number of elements - 1
00070     int nDimIndex_;         //current index to the collection
00071     char* sDiscriminantValue_; //temporary string for discriminantValue attribute
00072     BxBinaryFile* bfile_;          //binary file handle to save data content
00073 };
00074 
00075 #endif
00076 

Generated on Fri May 6 13:36:17 2005 for edikt::BinX by doxygen 1.3.3