AsciiFile.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // Maintainer: fehr@suse.de
00003 
00004 #ifndef _AsciiFile_h
00005 #define _AsciiFile_h
00006 
00007 #include <vector>
00008 #include <list>
00009 
00010 using std::string;
00011 
00012 namespace storage
00013 {
00014 
00015 class Regex;
00016 
00017 #define DBG(x)
00018 
00020 //
00021 //      CLASS NAME : AsciiFile
00022 //
00023 //      DESCRIPTION :
00024 //
00025 class AsciiFile
00026     {
00027     public:
00028         AsciiFile( bool CreateBackup_bv=false, 
00029                    const char* BackupExt_Cv=".orig" );
00030         AsciiFile( const string& Name_Cv, bool CreateBackup_bv=false, 
00031                    const char* BackupExt_Cv=".orig" );
00032         AsciiFile( const char* Name_Cv, bool CreateBackup_bv=false, 
00033                    const char* BackupExt_Cv=".orig" );
00034         ~AsciiFile();
00035         bool insertFile( AsciiFile& File_Cv, unsigned int BeforeLine_iv=0 );
00036         bool appendFile( AsciiFile& File_Cv );
00037         bool insertFile( const string& Name_Cv, unsigned int BeforeLine_iv=0 );
00038         bool appendFile( const string& Name_Cv );
00039         bool loadFile( const string& Name_Cv );
00040         bool updateFile();
00041         bool saveToFile( const string& Name_Cv );
00042         void append( const string& Line_Cv );
00043         void append( const std::list<string>& Lines_Cv );
00044         void insert( unsigned int Before_iv, const string& Line_Cv );
00045         void remove( unsigned int Start_iv, unsigned int Cnt_iv );
00046         void replace( unsigned int Start_iv, unsigned int Cnt_iv,
00047                       const string& Line_Cv );
00048         void replace( unsigned int Start_iv, unsigned int Cnt_iv,
00049                       const std::list<string>& Line_Cv );
00050         const string& operator []( unsigned int Index_iv ) const;
00051         string& operator []( unsigned int Index_iv );
00052         int find( unsigned int Start_iv, const string& Pat_Cv );
00053         int find( unsigned int Start_iv, Regex& Pat_Cv );
00054         unsigned numLines() const; 
00055         const string& fileName();
00056         unsigned differentLine( const AsciiFile& File_Cv ) const;
00057 
00058     protected:
00059         bool appendFile( const string&  Name_Cv, std::vector<string>& Lines_Cr );
00060         bool appendFile( AsciiFile& File_Cv, std::vector<string>& Lines_Cr );
00061 
00062         bool BackupCreated_b;
00063         string BackupExtension_C;
00064         std::vector<string> Lines_C;
00065         string Name_C;
00066     };
00067 
00068 }
00069 
00070 #endif

Generated on Thu Jul 6 00:40:24 2006 for yast2-storage by  doxygen 1.4.6