00001
00002
00003
00004 #ifndef _AsciiFile_h
00005 #define _AsciiFile_h
00006
00007 #include <vector>
00008
00009 using std::vector;
00010
00011
00012 #define DBG(x)
00013
00015
00016
00017
00018
00019
00020 class AsciiFile
00021 {
00022 public:
00023 AsciiFile( bool CreateBackup_bv=false,
00024 const char* BackupExt_Cv=".orig" );
00025 AsciiFile( const char* Name_Cv, bool CreateBackup_bv=false,
00026 const char* BackupExt_Cv=".orig" );
00027 ~AsciiFile();
00028 bool InsertFile( AsciiFile& File_Cv, unsigned int BeforeLine_iv=0 );
00029 bool AppendFile( AsciiFile& File_Cv );
00030 bool InsertFile( string Name_Cv, unsigned int BeforeLine_iv=0 );
00031 bool AppendFile( string Name_Cv );
00032 bool LoadFile( string Name_Cv );
00033 bool UpdateFile();
00034 bool SaveToFile( string Name_Cv );
00035 void Append( string Line_Cv );
00036 void Insert( unsigned int Before_iv, string Line_Cv );
00037 void Delete( unsigned int Start_iv, unsigned int Cnt_iv );
00038 void Replace( unsigned int Start_iv, unsigned int Cnt_iv,
00039 string Line_Cv );
00040 const string& operator []( unsigned int Index_iv ) const;
00041 string& operator []( unsigned int Index_iv );
00042 int Find( unsigned int Start_iv, string Pat_Cv );
00043 int NumLines() const;
00044 string FileName();
00045 int DifferentLine( const AsciiFile& File_Cv ) const;
00046
00047 protected:
00048 bool AppendFile( string Name_Cv, vector<string>& Lines_Cr );
00049 bool AppendFile( AsciiFile& File_Cv, vector<string>& Lines_Cr );
00050
00051 bool BackupCreated_b;
00052 string BackupExtension_C;
00053 vector<string> Lines_C;
00054 string Name_C;
00055 };
00057
00058 #endif