From b3611524f45c2a478f9decd6d22ecd1dbbbb64b9 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 17 Oct 2013 23:23:25 +0200 Subject: fs/Path: move definitions to struct PathTraits --- src/fs/Path.hxx | 57 +++++---------------------------------------------------- 1 file changed, 5 insertions(+), 52 deletions(-) (limited to 'src/fs/Path.hxx') 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 @@ -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()); } }; -- cgit v1.2.3