Disk ARchive  2.4.8
 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 
28 
29 #ifndef MASK_LIST_HPP
30 #define MASK_LIST_HPP
31 
32 #include "../my_config.h"
33 
34 #include "mask.hpp"
35 
36 namespace libdar
37 {
38 
41 
47 
48  class mask_list : public mask
49  {
50  public:
51 
53 
61  mask_list(const std::string & filename_list_st, bool case_sensit, const path & prefix, bool include);
62 
64  bool is_covered(const std::string & expression) const;
66  mask *clone() const { return new (std::nothrow) mask_list(*this); };
67 
69  U_I size() const { return contenu.size(); };
70 
71  private:
72 
73  // we need to change to lexicographical order relationship for the '/' character be the most lower of all. This way
74  // the first entry listed from a set a file sharing the same first characters will be the one corresponding
75  // to the directory with this common prefix.
76 
77  class my_char
78  {
79  public:
80  my_char() { val = 0; };
81  my_char(const char x) : val(x) {};
82  bool operator < (const my_char & x) const
83  {
84  if(val == '/')
85  if(x.val == '/')
86  return false;
87  else
88  return true;
89  else
90  if(x.val == '/')
91  return false;
92  else
93  return val < x.val;
94  };
95 
96  operator char() const
97  {
98  return val;
99  };
100 
101  private:
102  char val;
103  };
104 
105  std::vector <std::basic_string<my_char> > contenu;
106  U_I taille;
107  bool case_s;
108  bool including; // mask is used for including files (not for excluding files)
109 
110  static std::list<std::basic_string<my_char> > convert_list_string_char(const std::list<std::string> & src);
111  static std::basic_string<my_char> convert_string_char(const std::string & src);
112  static std::string convert_string_my_char(const std::basic_string<my_char> & src);
113  };
114 
116 
117 } // end of namespace
118 
119 #endif
the generic class, parent of all masks
Definition: mask.hpp:61
U_I size() const
routing only necessary for doing some testing
Definition: mask_list.hpp:69
mask_list(const std::string &filename_list_st, bool case_sensit, const path &prefix, bool include)
the constructor
bool is_covered(const std::string &expression) const
inherited from the mask class
here lies a collection of mask classes
mask * clone() const
inherited from the mask class
Definition: mask_list.hpp:66
the class path is here to manipulate paths in the Unix notation: using'/'
Definition: path.hpp:50