Disk ARchive  2.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
mask_list.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2052 Denis Corbin
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 //
19 // to contact the author : http://dar.linux.free.fr/email.html
20 /*********************************************************************/
21 // $Id: mask_list.hpp,v 1.8 2011/01/09 17:25:58 edrusb Rel $
22 //
23 /*********************************************************************/
24 
31 
32 #ifndef MASK_LIST_HPP
33 #define MASK_LIST_HPP
34 
35 #include "../my_config.h"
36 
37 #include "mask.hpp"
38 
39 namespace libdar
40 {
41 
44 
50 
51  class mask_list : public mask
52  {
53  public:
54 
56 
64  mask_list(const std::string & filename_list_st, bool case_sensit, const path & prefix, bool include);
65 
67  bool is_covered(const std::string & expression) const;
69  mask *clone() const { return new mask_list(*this); };
70 
72  U_I size() const { return contenu.size(); };
73 
74  private:
75 
76  // we need to change to lexicographical order relationship for the '/' character be the most lower of all. This way
77  // the first entry listed from a set a file sharing the same first characters will be the one corresponding
78  // to the directory with this common prefix.
79 
80  class my_char
81  {
82  public:
83  my_char() { val = 0; };
84  my_char(const char x) : val(x) {};
85  bool operator < (const my_char & x) const
86  {
87  if(val == '/')
88  if(x.val == '/')
89  return false;
90  else
91  return true;
92  else
93  if(x.val == '/')
94  return false;
95  else
96  return val < x.val;
97  };
98 
99  operator char() const
100  {
101  return val;
102  };
103 
104  private:
105  char val;
106  };
107 
108  std::vector <std::basic_string<my_char> > contenu;
109  U_I taille;
110  bool case_s;
111  bool including; // mask is used for including files (not for excluding files)
112 
113  static std::list<std::basic_string<my_char> > convert_list_string_char(const std::list<std::string> & src);
114  static std::basic_string<my_char> convert_string_char(const std::string & src);
115  static std::string convert_string_my_char(const std::basic_string<my_char> & src);
116  };
117 
119 
120 } // end of namespace
121 
122 #endif