aboutsummaryrefslogtreecommitdiffstats
path: root/src/fs/AllocatedPath.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/AllocatedPath.hxx')
-rw-r--r--src/fs/AllocatedPath.hxx31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/fs/AllocatedPath.hxx b/src/fs/AllocatedPath.hxx
index c345470c8..e733c00a9 100644
--- a/src/fs/AllocatedPath.hxx
+++ b/src/fs/AllocatedPath.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -25,6 +25,7 @@
#include "Traits.hxx"
#include "Path.hxx"
+#include <cstddef>
#include <utility>
#include <string>
@@ -44,13 +45,7 @@ class AllocatedPath {
string value;
- struct Donate {};
-
- /**
- * Donate the allocated pointer to a new #AllocatedPath object.
- */
- AllocatedPath(Donate, pointer _value);
-
+ AllocatedPath(std::nullptr_t):value() {}
AllocatedPath(const_pointer _value):value(_value) {}
AllocatedPath(string &&_value):value(std::move(_value)) {}
@@ -82,7 +77,7 @@ public:
*/
gcc_const
static AllocatedPath Null() {
- return AllocatedPath("");
+ return AllocatedPath(nullptr);
}
gcc_pure
@@ -169,11 +164,21 @@ public:
return *this;
}
+ gcc_pure
+ bool operator==(const AllocatedPath &other) const {
+ return value == other.value;
+ }
+
+ gcc_pure
+ bool operator!=(const AllocatedPath &other) const {
+ return value != other.value;
+ }
+
/**
* Allows the caller to "steal" the internal value by
* providing a rvalue reference to the std::string attribute.
*/
- std::string &&Steal() {
+ string &&Steal() {
return std::move(value);
}
@@ -244,7 +249,9 @@ public:
* nullptr on mismatch.
*/
gcc_pure
- const char *RelativeFS(const char *other_fs) const;
+ const_pointer Relative(Path other_fs) const {
+ return PathTraitsFS::Relative(c_str(), other_fs.c_str());
+ }
/**
* Chop trailing directory separators.
@@ -252,7 +259,7 @@ public:
void ChopSeparators();
gcc_pure
- bool IsAbsolute() {
+ bool IsAbsolute() const {
return PathTraitsFS::IsAbsolute(c_str());
}
};