aboutsummaryrefslogtreecommitdiff
path: root/libbutl/path.mxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-05-23 15:33:26 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-05-23 15:33:26 +0200
commit086f8b6e68228c9081c15bee03975db4024114ad (patch)
tree689a020229099bcf47835dc359953177b3c45b23 /libbutl/path.mxx
parent37b050707ef99735fab834063032ef9a2e775fab (diff)
Improve path_traits convenience overloads
Diffstat (limited to 'libbutl/path.mxx')
-rw-r--r--libbutl/path.mxx57
1 files changed, 56 insertions, 1 deletions
diff --git a/libbutl/path.mxx b/libbutl/path.mxx
index 3f3a844..1b1513a 100644
--- a/libbutl/path.mxx
+++ b/libbutl/path.mxx
@@ -81,6 +81,7 @@ LIBBUTL_MODEXPORT namespace butl
struct path_traits
{
using string_type = std::basic_string<C>;
+ using char_traits_type = typename string_type::traits_type;
using size_type = typename string_type::size_type;
// Canonical directory and path seperators.
@@ -135,6 +136,12 @@ LIBBUTL_MODEXPORT namespace butl
}
static bool
+ absolute (const C* s)
+ {
+ return absolute (s, char_traits_type::length (s));
+ }
+
+ static bool
absolute (const C* s, size_type n)
{
#ifdef _WIN32
@@ -151,6 +158,12 @@ LIBBUTL_MODEXPORT namespace butl
}
static bool
+ current (const C* s)
+ {
+ return current (s, char_traits_type::length (s));
+ }
+
+ static bool
current (const C* s, size_type n)
{
return n == 1 && s[0] == '.';
@@ -163,6 +176,12 @@ LIBBUTL_MODEXPORT namespace butl
}
static bool
+ parent (const C* s)
+ {
+ return parent (s, char_traits_type::length (s));
+ }
+
+ static bool
parent (const C* s, size_type n)
{
return n == 2 && s[0] == '.' && s[1] == '.';
@@ -175,6 +194,12 @@ LIBBUTL_MODEXPORT namespace butl
}
static bool
+ normalized (const C* s, bool sep)
+ {
+ return normalized (s, char_traits_type::length (s), sep);
+ }
+
+ static bool
normalized (const C* s, size_type n, bool sep)
{
size_t j (0); // Beginning of path component.
@@ -215,6 +240,12 @@ LIBBUTL_MODEXPORT namespace butl
}
static bool
+ root (const C* s)
+ {
+ return root (s, char_traits_type::length (s));
+ }
+
+ static bool
root (const C* s, size_type n)
{
#ifdef _WIN32
@@ -237,6 +268,12 @@ LIBBUTL_MODEXPORT namespace butl
}
static const C*
+ find_separator (const C* s)
+ {
+ return find_separator (s, char_traits_type::length (s));
+ }
+
+ static const C*
find_separator (const C* s, size_type n)
{
for (const C* e (s + n); s != e; ++s)
@@ -261,6 +298,12 @@ LIBBUTL_MODEXPORT namespace butl
}
static const C*
+ rfind_separator (const C* s)
+ {
+ return rfind_separator (s, char_traits_type::length (s));
+ }
+
+ static const C*
rfind_separator (const C* s, size_type n)
{
for (; n != 0; --n)
@@ -282,6 +325,12 @@ LIBBUTL_MODEXPORT namespace butl
}
static const C*
+ find_extension (const C* s)
+ {
+ return find_extension (s, char_traits_type::length (s));
+ }
+
+ static const C*
find_extension (const C* s, size_type n)
{
size_type i (n);
@@ -320,6 +369,12 @@ LIBBUTL_MODEXPORT namespace butl
}
static const C*
+ find_leaf (const C* s)
+ {
+ return find_leaf (s, char_traits_type::length (s));
+ }
+
+ static const C*
find_leaf (const C* s, size_type n)
{
const C* p;
@@ -600,7 +655,7 @@ LIBBUTL_MODEXPORT namespace butl
using string_type = std::basic_string<C>;
using size_type = typename string_type::size_type;
using difference_type = typename string_type::difference_type;
- using traits = path_traits<C>;
+ using traits = path_traits<C>; //@@ TODO: rename to traits_type.
struct iterator;
using reverse_iterator = std::reverse_iterator<iterator>;