00001 /******************************************************************** 00002 * Binx 00003 * $Id: BxBinxDomParser_8h-source.html,v 1.1.1.1 2006/04/19 14:19:02 edikt2 Exp $ 00004 * 00005 * Class for parsing the BinX document using the DOM engine 00006 * 00007 * 00008 * edikt::BinX 00009 * www.edikt.org 00010 * support@edikt.org 00011 * 00012 * Copyright (c) 2005 The University of Edinburgh. 00013 * 00014 ********************************************************************/ 00015 00016 #ifndef BXBINXDOMPARSER_H 00017 #define BXBINXDOMPARSER_H 00018 00019 #include "BxDataset.h" 00020 #include "BxUnion.h" 00021 #include "BxBinaryFile.h" 00022 #include "BxArray.h" 00023 #include "BxArrayFixed.h" 00024 #include "BxArrayVariable.h" 00025 #include "BxArrayStreamed.h" 00026 #include "BxBinxParser.h" 00027 #include "BxDomParser.h" 00028 00029 class BxDomParser; 00030 class BxDomNodeList; 00031 00032 /* 00033 * - Base class to manage objects from BinX XML document files. 00034 * This class invokes methods in the class BxDomParser to access the BinX document file 00035 * and to parse the XML statements contained in the document file. 00036 * When processing an existing BinX document file, 00037 * this class creates a set of relationed objects that record 00038 * the intermediate, parsed XML representation returned by the BxDomParser class. 00039 * Objects of type BxDataset, BxArray, and BxUnion are used to hold these parsed results. 00040 * <BR> 00041 * This class should also be used to create a new BinX document file. 00042 * A caller must create a empty BxBinxFile object, 00043 * create approriate objects to contain the memory-resident representation of 00044 * a BinX document specification, and then use the BxDomParser class 00045 * to save the entire specification in a BinX document file. 00046 * <BR> 00047 * More than one binary application data file may be associated with the dataset. 00048 * So this object maintains a list of binary file pointers which will be assigned 00049 * to the particular data elements in the dataset. 00050 *<BR> 00051 * When reading from a BinX file, create an instance of this class 00052 * and call the method parseBinxFile() to initialize the BxBinxFile object with 00053 * the schema definition from the document file, 00054 * and then invoke the method getDataset to obtain a pointer to the dataset. 00055 * <BR> 00056 * When writing a new BinX document file, create an instance of this class 00057 * and call BxDataSet::addDataObject() method to add a number of data objects 00058 * describing the XMl schema elements to be added to the BinX document file. 00059 * After the specification has been constructed, use the BxBinxFileWriter class 00060 * to save the BinX document to a specified local file. 00061 * <BR> 00062 * The BxDomParser used by this class is a wrapper for a third party DOM parser. 00063 * The BxDomParser class implements the mapping between the implementation 00064 * data structures used by the third party DOM parser and the object structures 00065 * used by this class to represent the BinX XML document file. 00066 * This allows one DOM parser to be more easily replaced by another. 00067 * <BR><B>Since:</B> BinX version 1.1. 00068 */ 00069 class DECLSPEC BxBinxDomParser : public BxBinxParser 00070 { 00071 public: 00072 BxBinxDomParser(); 00073 virtual ~BxBinxDomParser(); 00074 00075 virtual char* className() const { return "BxBinxDomParser"; } 00076 virtual bool parse(const char* xmlFile); 00077 00078 protected: 00079 BxDomParser* dom_; //<holds the parsed DOM tree 00080 00081 private: 00082 void parseArrayDimensions(BxArray*, BxDomNodeList*); 00083 void parseDataAttributes(BxDomNodeList* , BxDataObject* ); 00084 void parseDatasetAttributes(BxDomParser&); 00085 bool parseDefinitions(BxDomParser& bp); 00086 bool parseDataInstances(BxDomParser& bp); 00087 bool parseDefinedElements(BxDomNodeList*, const char*); 00088 bool parseUsedElements(BxDomNodeList*, BxDataset*, BxBinaryFile*); 00089 bool parseUnionElements(BxDomNodeList*, BxUnion*); 00090 bool parseArrayElements(BxArray*, BxDomNodeList*); 00091 BxDataObject* createPrimitiveDataObject(BxBinxTagNumber tagNum); 00092 BxDataset* createStruct(const char* typeName, BxByteOrder bo, BxDomNodeList* pNode); 00093 BxUnion* createUnion(const char* typeName, BxByteOrder bo, BxDomNodeList* pNode); 00094 BxArray* createArray(BxBinxTagNumber tag, const char* typeName, BxByteOrder bo, BxDomNodeList* pNode); 00095 }; 00096 00097 #endif
1.3.3