Disk ARchive  2.4.2
mask_list.hpp
Go to the documentation of this file.
00001 /*********************************************************************/
00002 // dar - disk archive - a backup/restoration program
00003 // Copyright (C) 2002-2052 Denis Corbin
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 //
00019 // to contact the author : http://dar.linux.free.fr/email.html
00020 /*********************************************************************/
00021 // $Id: mask_list.hpp,v 1.8 2011/01/09 17:25:58 edrusb Rel $
00022 //
00023 /*********************************************************************/
00024 
00031 
00032 #ifndef MASK_LIST_HPP
00033 #define MASK_LIST_HPP
00034 
00035 #include "../my_config.h"
00036 
00037 #include "mask.hpp"
00038 
00039 namespace libdar
00040 {
00041 
00044 
00050 
00051     class mask_list : public mask
00052     {
00053     public:
00054 
00056 
00064         mask_list(const std::string & filename_list_st, bool case_sensit, const path & prefix, bool include);
00065 
00067         bool is_covered(const std::string & expression) const;
00069         mask *clone() const { return new mask_list(*this); };
00070 
00072         U_I size() const { return contenu.size(); };
00073 
00074     private:
00075 
00076             // we need to change to lexicographical order relationship for the '/' character be the most lower of all. This way
00077             // the first entry listed from a set a file sharing the same first characters will be the one corresponding
00078             // to the directory with this common prefix.
00079 
00080         class my_char
00081         {
00082         public:
00083             my_char() { val = 0; };
00084             my_char(const char x) : val(x) {};
00085             bool operator < (const my_char & x) const
00086             {
00087                 if(val == '/')
00088                     if(x.val == '/')
00089                         return false;
00090                     else
00091                         return true;
00092                 else
00093                     if(x.val == '/')
00094                         return false;
00095                     else
00096                         return val < x.val;
00097             };
00098 
00099             operator char() const
00100             {
00101                 return val;
00102             };
00103 
00104         private:
00105             char val;
00106         };
00107 
00108         std::vector <std::basic_string<my_char> > contenu;
00109         U_I taille;
00110         bool case_s;
00111         bool including;   // mask is used for including files (not for excluding files)
00112 
00113         static std::list<std::basic_string<my_char> > convert_list_string_char(const std::list<std::string> & src);
00114         static std::basic_string<my_char> convert_string_char(const std::string & src);
00115         static std::string convert_string_my_char(const std::basic_string<my_char> & src);
00116     };
00117 
00119 
00120 } // end of namespace
00121 
00122 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines