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

BxBinxFileWriter Class Reference

Class for creating a BinX document file. More...

#include <BxBinxFileWriter.h>

Inheritance diagram for BxBinxFileWriter:

BxBinxFile BxObject List of all members.

Public Member Functions

 BxBinxFileWriter ()
 BxBinxFileWriter (const char *filename)
bool save ()
bool save (const char *filename)
bool saveDataBinx (FILE *)
bool createBinxFile (const char *filename)
bool addTypeDefinition (BxDataObject *)

Detailed Description

Use BxBinxFileWriter to create a new BinX file from scratch. The base class BxBinxFile implements services for building and holding a memory-resident set of objects containing a BinX document. These objects are stored in the attributes of the base class instance. The base class initialises its attributes by reading from a BinX document file or by direct invocation of base class methods to update its attributes.
This class creates only local files, but the caller must specify a name for the BinX document file being created.
Use Example:
To create a BinX object, use
         BxBinxFileWriter * pbfw = new BxBinxFileWriter("filename.xml");
   

The ".xml" file name suffix is optional, but the resulting BinX document file will always include the ".xml" suffix as part of the file name.
Since: BinX version 1.0.


Constructor & Destructor Documentation

BxBinxFileWriter::BxBinxFileWriter  ) 
 

Default constructor.

Constructs an instance of the class BxBinxFilewriter. The newly constructed instance encapsulates the root of a BinX dataset (as an instance of the class BxDataSet) Default attribute values assigned by this class and inherited from the base class BxBinxFile are as follows:

        fileptr_ = NULL;
        path_ = NULL;
        bfile_ = NULL;
        dom_ = NULL;
   
Note that no external Binx document file is associated with this object. Use the constructor BxBinxFileWriter(const char * filename) to construct an object to write a BinX document to a specific file.

BxBinxFileWriter::BxBinxFileWriter const char *  filename  ) 
 

Construct a BxBinxFileWriter object associated with a specified BinX file.

The specified file name is used to create and open a local file for writing in text mode. The file name and open file pointer are maintained as attribute values of this newly constructed object. The specified file name may or may not include a file type suffix. Regardless, the resulting file name will include the suffix ".xml" indicating that the file will contain an XML document.

Parameters:
filename A pointer to a valid path name and file name for the BinX document file.


Member Function Documentation

bool BxBinxFileWriter::addTypeDefinition BxDataObject dataobj  ) 
 

Add an instance of BxDataObject to the definitions_ attribute of this BxBinxFileWriter object.

To form a valid memory-resident representation of a BinX document tree, the input parameter should contain a well-formed representation of a type definition element in a BinX XML document. The type definition is represented by an instance of class BxDataObject or one of its derived classes, BxDataSet, BxArray, BxInteger, BxFloat.
Upon completion of this method, the input BxDataObject object describing a user defined type to be added to the BinX document, is tightly related to this array instance. Destruction of the BxDataObject instance will be managed by BxBinxFileWriter. The caller must not destruct the input object.

Parameters:
dataobj A pointer to a data object of class BxDataObject or a derived class.
Returns:
true If the type definition is added to the definitions attribute
false If an error occurs.

bool BxBinxFileWriter::createBinxFile const char *  filename  ) 
 

Create a new BinX file having a specified file name.

Is a local file of the specified name already exists, then that file is opened for writing in text mode, the file pointer is positioned to the beginning of the file and the current file contents will be overwritten.
The specified file name may include a path name. The file name may or may not include a file type suffix. Regardless, the resulting file name will include the suffix ".xml" indicating that the file will contain an XML document.

Parameters:
filename A pointer to a file name with optional suffix and path name.
Returns:
true If not file I/O error occurs,
false If any file I/O errors occur.

bool BxBinxFileWriter::save const char *  filename  ) 
 

Write all sections of the BinX document to a specified BinX document file.

The sections of the BinX document are written in order to a specified BinX document file. The BinX header is written first, followed by the type definitions section, followed by the data set specification section, and the closing BinX XML tag is written last.
The specified file name may include a path name. The file name may or may not include a file type suffix. Regardless, the resulting file name will include the suffix ".xml" indicating that the file will contain an XML document.
If a file is already associated with this instance of BxBinxFileWriter, then that file is closed and disassociated with this object. The specified file name is open for writing in text mode. If the specified file existed previously, it will be overwritten by this method.

Parameters:
filename A pointer to the file name for the file that will be written to.
Returns:
true If no file I/O error occurs,
false If any file I/O errors occur.

bool BxBinxFileWriter::save  ) 
 

Write all sections of the BinX document to the associated BinX document file.

The sections of the BinX document are written in order to the associated BinX document file. The BinX header is written first, followed by the type definitions section, followed by the data set specification section, and the closing BinX XML tag is written last.

Returns:
true If no file I/O error occurs,
false If any file I/O errors occur.

bool BxBinxFileWriter::saveDataBinx FILE *  stream  ) 
 

Write a DataBinX file from a BinX document and a specified binary file.

This method generates and writes a BinX document with embedded data values taken from the binary data file. This file is called "DataBinX" in comparison with "SchemaBinX" which describes the data schema only leaving the data values in the separate binary file. The output file may be too large if the BinX document defines a large array. A standard BinX header is added to the output, but user-defined types are expanded, or repeated, in the data set section so that data values can be embedded.
This method calls the toStream method of each data object to produce a text representation of each binary data value for output to the DataBinX file.

Parameters:
stream A file pointerto the file to hold the DataBinX output.
Returns:
A file pointer if no file I/O error occurs,
A NULL pointer if any file I/O errors occur.


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