Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

File.h

00001 /*
00002   File: File.h
00003 
00004   Copyright(C) C. Kotterink, Computed Graphics
00005 */
00006 #ifndef FILE_H
00007 #define FILE_H
00008 
00009 #include<base.h>
00010 #include<stdio.h>
00011 #include<string>
00012 
00018 class File
00019 {
00020 public:
00022     File() : f(0), endianShip(BigEndian) {}
00023 
00025     File(const string &name) : f(0), endianShip(BigEndian) {
00026         open(name);
00027     }
00028 
00030     ~File() {
00031         close();
00032     }
00033 
00035     FILE *handle() {
00036         return f;
00037     }
00038 
00047     unsigned int tell() {
00048         return ftell(f);
00049     }
00050 
00071     int seek(long offset, int whence = SEEK_SET) {
00072         return fseek(f, offset, whence);
00073     }
00074 
00076     void open(const string &name);
00077 
00079     void create(const string &name);
00080 
00082     void close();
00083 
00085     int readAsciiInteger();
00086 
00088     void readString(string &name);
00089 
00091     uint16 readChar();
00092 
00094     uint16 readShort();
00095 
00097     uint32 readInt();
00098 
00100     float readFloat();
00101 
00103     void writeString(const string &name);
00104 
00106     void writeChar(uint16 ch);
00107 
00109     void writeShort(uint16 i);
00110 
00112     void writeInt(uint32 i);
00113 
00115     void writeFloat(float fl);
00116 
00117 protected:
00119     FILE *f;
00120 
00122     EndianShip endianShip;
00123 };
00124 #endif

This documentation was generated using doxygen. If you have any comments or additions please mail me.