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

BxBinxFile Class Reference

Base class to manage objects from BinX XML document files. More...

#include <BxBinxFile.h>

Inheritance diagram for BxBinxFile:

BxObject BxBinxFileReader BxBinxFileWriter List of all members.

Public Member Functions

 BxBinxFile ()
BxDatasetgetDataset () const
void setBinaryFilePtr (BxBinaryFile *bfile)
bool parseBinxFile (const char *xmlFile)

Detailed Description

This class invokes methods in the class BxDomParser to access the BinX document file and to parse the XML statements contained in the document file. When processing an existing BinX document file, this class creates a set of relationed objects that record the intermediate, parsed XML representation returned by the BxDomParser class. Objects of type BxDataset, BxArray, and BxUnion are used to hold these parsed results.
This class should also be used to create a new BinX document file. A caller must create a empty BxBinxFile object, create appropriate objects to contain the memory-resident representation of a BinX document specification, and then use the BxDomParser class to save the entire specification in a BinX document file.
When reading from a BinX file, create an instance of this class and call the method parseBinxFile() to initialize the BxBinxFile object with the schema definition from the document file, and then invoke the method getDataset to obtain a pointer to the dataset.
When writing a new BinX document file, create an instance of this class and call BxDataSet::addDataObject() method to add a number of data objects describing the XML schema elements to be added to the BinX document file. After the specification has been constructed, use the BxBinxFileWriter class to save the BinX document to a specified local file.
The BxDomParser used by this class is a wrapper for a third party DOM parser. The BxDomParser class implements the mapping between the implementation data structures used by the third party DOM parser and the object structures used by this class to represent the BinX XML document file. This allows one DOM parser to be more easily replaced by another.
Since: BinX version 1.0.


Constructor & Destructor Documentation

BxBinxFile::BxBinxFile  ) 
 

Default constructor.

Constructs an instance of the class BxBinxFile. The newly constructed instance encapsulates the root of a BinX dataset (as an instance of the class BxDataSet) The constructed BinX dataset instance is empty. Default attribute values are assigned as follows:

	parser_ = NULL;
	datasetRoot_ = NULL;
	bfile_ = NULL;
   


Member Function Documentation

BxDataset * BxBinxFile::getDataset  )  const
 

Get a pointer to the dataset attribute.

Returns the dataset_ attribute value. If the attribute value has not been initialized at construction of by reading from an external BinX document file, then the returned value will be NULL.

Returns:
A pointer to the dataset attribute value for this object.

bool BxBinxFile::parseBinxFile const char *  binxFile  ) 
 

Initialize the dataset attribute by reading and parsing an external BinX document file.

The input parameter specifies the local pathname of the BinX file. The BinX document file contains an XML schema definition for a binary file of application data. The BinX document file is opened. The XML schema definition is read from the file and parsed using methods implemented by the class BxDomParser. The current implementation of class BxDomParser, uses the Xerces XML parser. This results in some restrictions and limitations (as listed below).
The XML schema definition contained in the BinX document file consists of three sections. The second and third sections are nested within the first section. The sections are:

  1. The root section describing the BinX dataset.
  2. The type definition section, where user-defined types are specified
  3. The data set section, where the location and structure of the file containing the binary application data is defined
The root section and the data set sections are required for in a valid BinX document. The type definition section is optional.
An example of the contents of a BinX document file is as follows:
    <binx byteOrder="bigEndian">
        <definitions>
            <defineType typeName="myIdea">
                <arrayFixed>
                    <character-8/>
                    <dim indexTo ="11"/>
                </arrayFixed>
            </defineType>
        </definitions>
        <dataset scr="myfile.bin">
            <useType typeName="myIdea"/>
            <integer-32 varName="X"/>
        </dataset>
    </binx>
   
The BinX document defines one abstract data type named "myIdea". The binary application data file is named "myfile.bin". The structure of the data in the binary file is a fixed-length array of type "myIdea" followed by a 32-bit integer value named "X".
The parsing operation is performed sequentially over each section, using specialised parsing methods. The parsed results are stored in the dataset attribute of this BxBinxFile object.
When parsing the BinX dataset attributes in the XML schema, the binary file name specified in the src="" attribute should not have a path specified as part of the filename. The default path for the binary file containing application data is the same as the path for the BinX schema file. That is, the binary file is regarded as residing in the same directory as the BinX file.
Current Restrictions and Limitations:
All files must be local. When parsing with Xerces, the file:/// is prefixed to the filename, and the binary file associated with the BinX file is also local and the file:/// tag is removed when parsing the binary filename.
Parameters:
binxFile The name of the BinX XML schema file to parse.
Returns:
true If parsing was successful and the dataset attribute was initialised,
false If the BinX file could not be parsed and the dataset attribute was not initialised.

void BxBinxFile::setBinaryFilePtr BxBinaryFile bfile  ) 
 

Assign a Binary file pointer.

A BxBinaryFile ojbect created outside this instance is attached here and will be deleted by the destructor. One use case of this is when creating a binary file for a ready-made BinX file. After BxBinxFile is parsed without a binary file, create and assign a new BxBinaryFileWriter object to it, so that binary data can be written to the binary file later via the BinX object.

Parameters:
bfile points to an instance of BxBinaryFile.


The documentation for this class was generated from the following files:
Generated on Fri May 6 13:36:18 2005 for edikt::BinX by doxygen 1.3.3