32 #include "../my_config.h" 66 mask(
mask && ref) noexcept =
default;
67 mask & operator = (
const mask & ref) =
default;
68 mask & operator = (
mask && ref) noexcept =
default;
69 virtual ~
mask() =
default;
76 virtual bool is_covered(
const std::string &expression)
const = 0;
89 virtual std::string
dump(
const std::string & prefix =
"")
const = 0;
116 bool is_covered(
const std::string & expression)
const override {
return val; };
118 std::string
dump(
const std::string & prefix)
const override {
return prefix + (val ? gettext(
"TRUE") : gettext(
"FALSE")); };
138 simple_mask(
const std::string & wilde_card_expression,
bool case_sensit);
157 bool is_covered(
const std::string &expression)
const override;
160 std::string
dump(
const std::string & prefix)
const override;
166 std::string the_mask;
200 bool is_covered(
const std::string & expression)
const override;
203 std::string
dump(
const std::string & prefix)
const override;
213 void set_preg(
const std::string & wilde_card_expression,
218 void detruit() noexcept { regfree(&preg); };
252 bool is_covered(
const std::string &expression)
const override {
return !ref->is_covered(expression); };
253 bool is_covered(
const path & chemin)
const override {
return !ref->is_covered(chemin); };
254 std::string
dump(
const std::string & prefix)
const override;
262 void nullifyptr() noexcept { ref =
nullptr; };
264 void copy_from(
const mask &m);
265 void move_from(
not_mask && ref) noexcept;
293 et_mask & operator = (
et_mask && m) noexcept { mask::operator = (std::move(m)); move_from(std::move(m));
return *
this; };
304 void add_mask(
const mask & toadd);
307 bool is_covered(
const std::string & expression)
const override {
return t_is_covered(expression); };
308 bool is_covered(
const path & chemin)
const override {
return t_is_covered(chemin); };
309 std::string
dump(
const std::string & prefix)
const override {
return dump_logical(prefix, gettext(
"AND")); };
318 U_I
size()
const {
return lst.size(); };
328 std::deque<mask *> lst;
330 std::string dump_logical(
const std::string & prefix,
const std::string & boolop)
const;
333 void copy_from(
const et_mask & m);
334 void move_from(
et_mask && m) noexcept;
337 template<
class T>
bool t_is_covered(
const T & expression)
const 339 std::deque<mask *>::const_iterator it = lst.begin();
342 throw Erange(
"et_mask::is_covered",
dar_gettext(
"No mask in the list of mask to operate on"));
344 while(it != lst.end() && (*it)->is_covered(expression))
347 return it == lst.end();
370 bool is_covered(
const std::string & expression)
const override {
return t_is_covered(expression); };
371 bool is_covered(
const path & chemin)
const override {
return t_is_covered(chemin); };
372 std::string
dump(
const std::string & prefix)
const override {
return dump_logical(prefix, gettext(
"OR")); };
377 template<
class T>
bool t_is_covered(
const T & expression)
const 379 std::deque<mask *>::const_iterator it = lst.begin();
382 throw Erange(
"et_mask::is_covered",
dar_gettext(
"No mask to operate on in the list of mask"));
384 while(it != lst.end() && ! (*it)->is_covered(expression))
387 return it != lst.end();
411 bool is_covered(
const std::string & expression)
const override {
throw SRC_BUG; };
413 std::string
dump(
const std::string & prefix)
const override;
433 same_path_mask(
const std::string &p,
bool case_sensit) { chemin = p; case_s = case_sensit; };
441 bool is_covered(
const std::string &chemin)
const override;
444 std::string
dump(
const std::string & prefix)
const override;
464 exclude_dir_mask(
const std::string &p,
bool case_sensit) { chemin = p; case_s = case_sensit;};
472 bool is_covered(
const std::string &expression)
const override {
throw SRC_BUG; }
474 std::string
dump(
const std::string & prefix)
const override;
et_mask(et_mask &&m) noexcept
move constructor
same_path_mask(const std::string &p, bool case_sensit)
the constructor to be used by libdar external programs
std::string dump(const std::string &prefix) const override
dump in human readable form the nature of the mask
the generic class, parent of all masks
makes the OR operator between two or more masks
void clear()
clear the mask
makes an AND operator between two or more masks
exclude_dir_mask(const std::string &p, bool case_sensit)
the constructor to be used by libdar external programs
bool is_covered(const std::string &expression) const override
inherited from the mask class
const char * dar_gettext(const char *)
a routine to change NLS domaine forth and back for inline routines
bool is_covered(const path &chemin) const override
check whether the given path is covered by the mask
std::string dump(const std::string &prefix) const override
dump in human readable form the nature of the mask
mask * clone() const override
inherited from the mask class
bool case_sensit
used only by the copy constructor
not_mask(not_mask &&m) noexcept
move constructor
matches regular expressions (see "man 7 regex")
bool is_covered(const path &chemin) const override
check whether the given path is covered by the mask
std::string mask_exp
used only by the copy constructor
regular_mask(const regular_mask &ref)
the copy constructor
bool is_covered(const path &chemin) const override
check whether the given path is covered by the mask
not_mask(const mask &m)
the constructor to be used by libdar external programs
boolean mask, either always true or false
string matches if it is subdir of mask or mask is a subdir of expression
matches if string is exactly the given mask (no wilde card expression)
U_I size() const
the number of mask on which is done the AND operator
mask * clone() const override
inherited from the mask class
bool is_covered(const std::string &expression) const override
inherited from the mask class
virtual bool is_covered(const path &chemin) const
check whether the given path is covered by the mask
virtual ~regular_mask()
destructor
et_mask(const et_mask &m)
copy constructor
matches as done on shell command lines (see "man 7 glob")
here is the definition of the path classthe path class handle path and provide several operation on t...
bool is_covered(const std::string &expression) const override
inherited from the mask class
virtual mask * clone() const =0
bool is_covered(const std::string &expression) const override
inherited from the mask class
bool is_covered(const std::string &expression) const override
inherited from the mask class
matches if string is the given constructor string or a sub directory of it
mask * clone() const override
inherited from the mask class
contains all the excetion class thrown by libdar
std::string dump(const std::string &prefix) const override
dump in human readable form the nature of the mask
simple_path_mask(const path &p, bool case_sensit)
the constructor to be used by libdar external programs
bool_mask(bool always)
the constructor
mask * clone() const override
inherited from the mask class
exception used to signal range error
not_mask(const not_mask &m)
copy constructor
bool is_covered(const path &chemin) const override
check whether the given path is covered by the mask
mask * clone() const override
inherited from the mask class
mask * clone() const override
inherited from the mask class
mask * clone() const override
inherited from the mask class
bool is_subdir_of(const path &p, bool case_sensit) const
test whether the current object is a subdir of the method's argument
mask * clone() const override
inherited from the mask class
virtual std::string dump(const std::string &prefix="") const =0
dump in human readable form the nature of the mask
virtual bool is_covered(const std::string &expression) const =0
check wether the given string is covered by the mask
bool is_covered(const path &chemin) const override
check whether the given path is covered by the mask
libdar namespace encapsulate all libdar symbols
mask * clone() const override
inherited from the mask class
bool is_covered(const std::string &expression) const override
inherited from the mask class
regular_mask(regular_mask &&ref) noexcept
the move constructor
std::string display() const
convert back a path to a string
the class path is here to manipulate paths in the Unix notation: using'/'