MPD  0.20.23
ExcludeList.hxx
Go to the documentation of this file.
1 /*
2  * Copyright 2003-2017 The Music Player Daemon Project
3  * http://www.musicpd.org
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (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 along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 /*
21  * The .mpdignore backend code.
22  *
23  */
24 
25 #ifndef MPD_EXCLUDE_H
26 #define MPD_EXCLUDE_H
27 
28 #include "check.h"
29 #include "Compiler.h"
30 #include "fs/Glob.hxx"
31 #include "input/Ptr.hxx"
32 
33 #ifdef HAVE_CLASS_GLOB
34 #include <forward_list>
35 #endif
36 
37 class Path;
38 
39 class ExcludeList {
40  const ExcludeList *const parent;
41 
42 #ifdef HAVE_CLASS_GLOB
43  std::forward_list<Glob> patterns;
44 #endif
45 
46 public:
48  :parent(nullptr) {}
49 
50  ExcludeList(const ExcludeList &_parent)
51  :parent(&_parent) {}
52 
53  gcc_pure
54  bool IsEmpty() const noexcept {
55 #ifdef HAVE_CLASS_GLOB
56  return ((parent == nullptr) || parent->IsEmpty()) && patterns.empty();
57 #else
58  /* not implemented */
59  return true;
60 #endif
61  }
62 
66  bool Load(InputStreamPtr is);
67 
72  bool Check(Path name_fs) const noexcept;
73 
74 private:
75  void ParseLine(char *line) noexcept;
76 };
77 
78 
79 #endif
A path name in the native file system character set.
Definition: Path.hxx:39
bool Check(Path name_fs) const noexcept
Checks whether one of the patterns in the .mpdignore file matches the specified file name.
std::unique_ptr< InputStream > InputStreamPtr
Definition: Ptr.hxx:25
gcc_pure bool IsEmpty() const noexcept
Definition: ExcludeList.hxx:54
ExcludeList(const ExcludeList &_parent)
Definition: ExcludeList.hxx:50
bool Load(InputStreamPtr is)
Loads and parses a .mpdignore file.
#define gcc_pure
Definition: Compiler.h:116