aboutsummaryrefslogtreecommitdiffstats
path: root/src/ExcludeList.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-03 10:01:34 +0100
committerMax Kellermann <max@duempel.org>2013-01-03 10:02:43 +0100
commit93f0bb8307ea26cc9ef96cf368110e8f6f0caead (patch)
treedfaa8e6be0fe0f4868acf34018b39d6bf9427f09 /src/ExcludeList.hxx
parent47fc08bffe94d33c88caafd084fa24e31e902798 (diff)
downloadmpd-93f0bb8307ea26cc9ef96cf368110e8f6f0caead.tar.gz
mpd-93f0bb8307ea26cc9ef96cf368110e8f6f0caead.tar.xz
mpd-93f0bb8307ea26cc9ef96cf368110e8f6f0caead.zip
ExcludeList: convert to a class
Diffstat (limited to '')
-rw-r--r--src/ExcludeList.hxx61
1 files changed, 45 insertions, 16 deletions
diff --git a/src/ExcludeList.hxx b/src/ExcludeList.hxx
index 52ba377b5..4d678b085 100644
--- a/src/ExcludeList.hxx
+++ b/src/ExcludeList.hxx
@@ -25,25 +25,54 @@
#ifndef MPD_EXCLUDE_H
#define MPD_EXCLUDE_H
+#include "gcc.h"
+
+#include <forward_list>
+
#include <glib.h>
-/**
- * Loads and parses a .mpdignore file.
- */
-GSList *
-exclude_list_load(const char *path_fs);
+class ExcludeList {
+ class Pattern {
+ GPatternSpec *pattern;
-/**
- * Frees a list returned by exclude_list_load().
- */
-void
-exclude_list_free(GSList *list);
+ public:
+ Pattern(const char *_pattern)
+ :pattern(g_pattern_spec_new(_pattern)) {}
+
+ Pattern(Pattern &&other)
+ :pattern(other.pattern) {
+ other.pattern = nullptr;
+ }
+
+ ~Pattern() {
+ g_pattern_spec_free(pattern);
+ }
+
+ gcc_pure
+ bool Check(const char *name_fs) const {
+ return g_pattern_match_string(pattern, name_fs);
+ }
+ };
+
+ std::forward_list<Pattern> patterns;
+
+public:
+ gcc_pure
+ bool IsEmpty() const {
+ return patterns.empty();
+ }
+
+ /**
+ * Loads and parses a .mpdignore file.
+ */
+ bool LoadFile(const char *path_fs);
+
+ /**
+ * Checks whether one of the patterns in the .mpdignore file matches
+ * the specified file name.
+ */
+ bool Check(const char *name_fs) const;
+};
-/**
- * Checks whether one of the patterns in the .mpdignore file matches
- * the specified file name.
- */
-bool
-exclude_list_check(GSList *list, const char *name_fs);
#endif