StdFile.h

Go to the documentation of this file.
00001 #ifndef __LDK_STDFILE_H__
00002 #define __LDK_STDFILE_H__
00003 
00005 //   Copyright (C) 2003-2006 Lorien Dunn.
00006 //
00007 //   Contact: loriendunn AT users DOT sourceforge DOT net
00008 //
00009 //   This software is provided 'as-is', without any express or implied warranty.
00010 //   In no event will the authors be held liable for any damages arising from
00011 //   the use of this software.
00012 //
00013 //   Permission is granted to anyone to use this software for any purpose,
00014 //   including commercial applications, and to alter it and redistribute it
00015 //   freely, subject to the following restrictions:
00016 //
00017 //   1. The origin of this software must not be misrepresented; you must not
00018 //   claim that you wrote the original software. If you use this software in a
00019 //   product, an acknowledgment in the product documentation would be
00020 //   appreciated but is not required.
00021 //
00022 //   2. Altered source versions must be plainly marked as such, and must not be
00023 //   misrepresented as being the original software.
00024 //
00025 //   3. This notice may not be removed or altered from any source distribution.
00026 //
00028 
00033 
00034 #include "LDK/VFile.h"
00035 #include <stdio.h>
00036 
00037 #ifdef putc
00038 #undef putc
00039 #endif
00040 
00041 #ifdef puts
00042 #undef puts
00043 #endif
00044 
00045 #ifdef getc
00046 #undef getc
00047 #endif
00048 
00049 namespace LDK
00050 {
00067 class LDK_API StdFile : public VFile
00068 {
00069 protected:
00070 
00071     FILE *mFile;
00072     inline StdFile(const StdFile&) {}
00073     inline void operator=(const StdFile&) {}
00074 
00075 public:
00076 
00077     StdFile(FILE* f=NULL);
00078     virtual ~StdFile() throw() ;
00079 
00080     virtual void openRead(const char* fileName, bool text=false);
00081     virtual void openWrite(const char* fileName, bool text=false);
00082     virtual void openAppend(const char* fileName, bool text=false);
00083     virtual int64 length();
00084     virtual void close();
00085 
00086     virtual bool eof();
00087     virtual int64 tell();
00088     virtual int64 seek(int64 offset, int whence);
00089     virtual void flush();
00090     inline FILE* handle() { return mFile; }
00091 
00092     virtual int64 read(void *buffer, uint32 objCount, uint32 objSize=1);
00093     virtual int32 getc();
00094     virtual int32 ungetc(char c);
00095     //like fgets
00096     virtual const char* gets(char* buffer, uint32 size);
00097 
00098     virtual int64 write(const void *buffer, uint32 objCount, uint32 objSize=1);
00099     virtual int32 putc(char c);
00100     virtual int32 puts(const char* str); //like fputs i.e. no \n appended
00101     virtual int32 printf(const char* format, ...);
00102     virtual int32 vprintf(const char *format, va_list ap);
00103 };
00104 
00105 }//namespace LDK
00106 #endif //__LDK_STDFILE_H__

Generated on Fri Aug 17 18:32:26 2007 for LDK by  doxygen 1.5.1