compressed.h

Go to the documentation of this file.
00001 /* -*- Mode: c++ -*- */
00002 /*
00003  *  this is part of Spm
00004  *
00005  *  Copyright (c) 2005 Guillaume Chevallereau
00006  *
00007  *  This program is free software. You can redistribute it and/or modify it 
00008  *  under the terms of the GNU General Public License as published by the 
00009  *  Free Software Foundation. Either version 2 of the license or (at your 
00010  *  option) any later version.
00011  *
00012  *  This program is distributed in the hope that it will be usefull but WITHOUT
00013  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
00014  *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
00015  *  more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License along 
00018  *  with this program; if not, write to the Free Software Foundation, Inc., 
00019  *  59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
00020  */
00021 #ifndef __COMPRESSED_H__
00022 #define __COMPRESSED_H__
00023 
00024 #include <vector>
00025 #include <algorithm>
00026 #include "utilException.h"
00027 #include <boost/filesystem/path.hpp>
00028 #include <miniXml/ustring.h>
00029 
00030 namespace Spm
00031 {
00032   namespace Util
00033   {
00034     class FileNotFoundException : public Exception
00035     {
00036     public :
00037       FileNotFoundException (const miniXml::ustring & fileName);
00038     };
00039     
00044     class Compressed
00045     {
00046     public:
00047       typedef std::vector<miniXml::ustring>::iterator iterator;
00048       typedef std::vector<miniXml::ustring>::const_iterator const_iterator;
00049       typedef std::vector<miniXml::ustring>::reverse_iterator reverse_iterator;
00050       typedef std::vector<miniXml::ustring>::const_reverse_iterator const_reverse_iterator;
00051     protected:
00052       boost::filesystem::path file_;
00053       std::vector<miniXml::ustring> files_;
00054       Compressed (){};
00055       Compressed (const boost::filesystem::path & fileName);
00056       virtual void listFiles () = 0;
00057 
00058     public:
00064       static Compressed * create (const boost::filesystem::path & file);
00065       virtual ~Compressed (){};
00066 
00072       virtual bool uncompress (const boost::filesystem::path & dest) = 0;
00073 
00077       const boost::filesystem::path & getName ();
00078 
00084       bool have (const miniXml::ustring & file);
00085       
00090       virtual bool extract (const miniXml::ustring & file,
00091                             const boost::filesystem::path & to) = 0;
00092 
00096       miniXml::ustring getSubDir ();
00097 
00102       const miniXml::ustring & getExactName (const miniXml::ustring & file);
00103 
00109       std::vector<miniXml::ustring> all (const miniXml::ustring & file);
00110 
00111       iterator begin ()
00112       {
00113         return files_.begin ();
00114       }
00115 
00116       iterator end ()
00117       {
00118         return files_.end ();
00119       }
00120 
00121       reverse_iterator rbegin ()
00122       {
00123         return files_.rbegin ();
00124       }
00125 
00126       reverse_iterator rend ()
00127       {
00128         return files_.rend ();
00129       }
00130 
00131       const_iterator begin () const
00132       {
00133         return files_.begin ();
00134       }
00135 
00136       const_iterator end () const
00137       {
00138         return files_.end ();
00139       }
00140 
00141       const_reverse_iterator rbegin () const
00142       {
00143         return files_.rbegin ();
00144       }
00145 
00146       const_reverse_iterator rend () const
00147       {
00148         return files_.rend ();
00149       }
00150 
00156       iterator find (const miniXml::ustring & file);
00157 
00163       const_iterator find (const miniXml::ustring & file) const;
00164     };
00165   }
00166 }
00167 #endif

Generated on Sat Mar 21 17:00:14 2009 for libSpm by  doxygen 1.5.2