Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

fileio.h

Go to the documentation of this file.
00001 #pragma once
00002 
00027 #ifndef __FILEIO_H__
00028 #define __FILEIO_H__
00029 
00030 // USINGS
00031 using std::string;
00032 using std::streamsize;
00033 using std::streamoff;
00034 using std::fstream;
00035 using std::exception;
00036 using std::ios_base::open_mode;
00037 
00039 class fileio
00040 {
00041         // Member functions.
00042 public:
00043         fileio(const string& FileName, open_mode OpenMode);
00044         ~fileio(void);
00045     fileio& operator<<(const string& String);
00046         void ReadFull(void) const;
00047         void ReadBlock(streamoff FileOffset, streamsize BlockSize) const;
00048     char* GetCurrentBlock(void) const;
00049     streamsize GetCurrentBlockSize(void) const;
00050         streamsize GetSize(void) const;
00051 private:
00052         void ReadContent(streamoff FileOffset) const;
00053     void WriteContent(const char* pContent, streamsize ContentSize, streamoff FileOffset);
00054     void DeleteContent(void) const;
00055 
00056         // Attributes.
00057 private:
00058     mutable fstream m_FStream;          
00059     mutable char* m_pContent;           
00060     mutable streamsize m_BlockSize;     
00061 };
00062 
00063 // Fileio exceptions.
00064 namespace except
00065 {
00067     class fileio_except: public exception
00068     {
00069         // Member functions.
00070     public:
00072         fileio_except(void) throw(): exception() {};
00074         virtual ~fileio_except(void) throw() {};
00076             virtual const char *what(void) const throw()=0;
00077     };
00078 
00080         class open_file_failed: public fileio_except
00081         {
00082                 // Member functions.
00083         public:
00084                 open_file_failed(const string& OpenFileFailed) throw();
00085         virtual ~open_file_failed(void) throw();
00086                 virtual const char *what(void) const throw();
00087 
00088         // Attributes.
00089     private:
00090         string m_OpenFileFailed;    
00091         };
00092 
00094     class create_file_failed: public fileio_except
00095     {
00096         // Member functions.
00097     public:
00098         create_file_failed(const string& CreateFileFailed) throw();
00099         virtual ~create_file_failed(void) throw();
00100         virtual const char *what(void) const throw();
00101 
00102         // Attributes.
00103     private:
00104         string m_CreateFileFailed;    
00105     };
00106 
00108         class out_of_content: public fileio_except
00109         {
00110                 // Member functions.
00111         public:
00112                 out_of_content(void) throw();
00113         virtual ~out_of_content(void) throw();
00114                 virtual const char *what(void) const throw();
00115         };
00116 };
00117 
00118 #endif // __FILEIO_H__

doxygen sourceforge id3lib