aboutsummaryrefslogtreecommitdiffstats
path: root/src/fs/Path.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-17 23:23:25 +0200
committerMax Kellermann <max@duempel.org>2013-10-17 23:23:25 +0200
commitb3611524f45c2a478f9decd6d22ecd1dbbbb64b9 (patch)
treed15d0c161e24e5db7d77b768458aa11cb6650878 /src/fs/Path.hxx
parenta63613dba0374367907180be5e244db450ff234b (diff)
downloadmpd-b3611524f45c2a478f9decd6d22ecd1dbbbb64b9.tar.gz
mpd-b3611524f45c2a478f9decd6d22ecd1dbbbb64b9.tar.xz
mpd-b3611524f45c2a478f9decd6d22ecd1dbbbb64b9.zip
fs/Path: move definitions to struct PathTraits
Diffstat (limited to '')
-rw-r--r--src/fs/Path.hxx57
1 files changed, 5 insertions, 52 deletions
diff --git a/src/fs/Path.hxx b/src/fs/Path.hxx
index a6e74104e..558e2923f 100644
--- a/src/fs/Path.hxx
+++ b/src/fs/Path.hxx
@@ -22,6 +22,7 @@
#include "check.h"
#include "Compiler.h"
+#include "Traits.hxx"
#ifdef WIN32
#include <glib.h>
@@ -40,20 +41,10 @@ class Error;
class Path {
typedef std::string string;
-public:
- typedef string::value_type value_type;
- typedef string::pointer pointer;
- typedef string::const_pointer const_pointer;
-
-#ifdef WIN32
- static constexpr value_type SEPARATOR_FS = '\\';
- static constexpr char SEPARATOR_UTF8 = '/';
-#else
- static constexpr value_type SEPARATOR_FS = '/';
- static constexpr char SEPARATOR_UTF8 = '/';
-#endif
+ typedef PathTraits::value_type value_type;
+ typedef PathTraits::pointer pointer;
+ typedef PathTraits::const_pointer const_pointer;
-private:
string value;
struct Donate {};
@@ -216,47 +207,9 @@ public:
*/
void ChopSeparators();
- static constexpr bool IsSeparatorFS(value_type ch) {
- return
-#ifdef WIN32
- ch == '/' ||
-#endif
- ch == SEPARATOR_FS;
- }
-
- static constexpr bool IsSeparatorUTF8(char ch) {
- return
-#ifdef WIN32
- ch == '/' ||
-#endif
- ch == SEPARATOR_UTF8;
- }
-
- gcc_pure
- static bool IsAbsoluteFS(const_pointer p) {
- assert(p != nullptr);
-
-#ifdef WIN32
- return g_path_is_absolute(p);
-#else
- return IsSeparatorFS(*p);
-#endif
- }
-
- gcc_pure
- static bool IsAbsoluteUTF8(const char *p) {
- assert(p != nullptr);
-
-#ifdef WIN32
- return g_path_is_absolute(p);
-#else
- return IsSeparatorUTF8(*p);
-#endif
- }
-
gcc_pure
bool IsAbsolute() {
- return IsAbsoluteFS(c_str());
+ return PathTraits::IsAbsoluteFS(c_str());
}
};