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

BxBinaryFile.h

00001 // ##################################################################
00002 // Binx
00003 // $Id: BxBinaryFile_8h-source.html,v 1.1.1.1 2006/04/19 14:19:02 edikt2 Exp $
00004 //
00005 // Super class for binary file reading
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 __BxBinaryFile__
00018 #define __BxBinaryFile__
00019 
00020 #include <stdio.h>
00021 #include "BxObject.h"
00022 #include "BxDataTypes.h"
00023 #include "BxBinxSchema.h"
00024 
00025 enum BxByteOrder {
00026     BX_UNSPECIFIED,
00027     BX_BIG_ENDIAN,
00028     BX_LITTLE_ENDIAN
00029 };
00030 
00031 class BxDataset;
00032 
00053 class DECLSPEC BxBinaryFile : public BxObject
00054 {
00055 public:
00056     BxBinaryFile();
00057     virtual ~BxBinaryFile();
00058 
00059     virtual char* className() const { return "BxBinaryFile"; } //<Returns the null-terminated string "BxBinaryFile".
00060 
00061     char * getFilename() const { return filename_; }
00062     long getFileSize();   //file size in bytes
00063     long getFilePos();
00064     BxDataset * getDataset() { return datasetptr_; }
00065 
00066     bool isOpen() const { return f_!=NULL; }
00067     bool isReadOnly() const { return readonly_; }
00068 
00069     void setFilename(char * filename);
00070     void copyFilename(const char * filename);
00071 
00072     FILE * open(const char * filename); //open an existing file
00073     FILE * create(const char * filename); //create a new file
00074     FILE * getFile() const { return f_; } //Return file handle of FILE *.
00075     void close();      //close this file
00076     int seek(long pos); //seek to a file position
00077     int readBuffer(void *, int);
00078     int writeBuffer(void *, int);
00079 
00080     static BxByteOrder calcMemoryByteOrder();  //calculate byte order in memory
00081     static void reverseBytes(byte * buffer, int numBytes);
00082 
00083     BxByteOrder getMemByteOrder() const { return memByteOrder_; }
00084 
00085     void setDatasetPointer(BxDataset * pset) { datasetptr_ = pset; }
00086 
00087 protected:
00088     FILE * f_;  //<file pointer
00089     bool    readonly_;  //<indicate a read only or writable file
00090     BxByteOrder memByteOrder_; //<indicates whether the file stores big endian or little endian representation
00091 
00092 private:
00093     char * filename_;   //<filename with path name
00094     BxDataset * datasetptr_;  //<list of binary files, used only when creating a BinX document
00095 };
00096 
00097 #endif
00098 

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