aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbutl/filesystem.cxx2
-rw-r--r--libbutl/path.mxx57
-rw-r--r--libbutl/process.cxx5
-rw-r--r--libbutl/string-table.mxx2
-rw-r--r--libbutl/url.mxx2
5 files changed, 61 insertions, 7 deletions
diff --git a/libbutl/filesystem.cxx b/libbutl/filesystem.cxx
index b0991b2..40b4304 100644
--- a/libbutl/filesystem.cxx
+++ b/libbutl/filesystem.cxx
@@ -200,7 +200,7 @@ namespace butl
// case.
//
string d;
- if (path::traits::root (p, string::traits_type::length (p)))
+ if (path::traits::root (p))
{
d = p;
d += path::traits::directory_separator;
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>;
diff --git a/libbutl/process.cxx b/libbutl/process.cxx
index 174e4ae..618c2aa 100644
--- a/libbutl/process.cxx
+++ b/libbutl/process.cxx
@@ -1073,8 +1073,7 @@ namespace butl
// Windows.
//
const char* d (__argv[0]);
- size_t n (strlen (d));
- if (const char* p = traits::rfind_separator (d, n))
+ if (const char* p = traits::rfind_separator (d))
{
string s (d, p - d + 1); // Include trailing slash.
s.append (f, fn);
@@ -1421,7 +1420,7 @@ namespace butl
optional<string> batch;
{
const char* p (pp.effect_string ());
- const char* e (path::traits::find_extension (p, strlen (p)));
+ const char* e (path::traits::find_extension (p));
if (e != nullptr && (casecmp (e, ".bat") == 0 ||
casecmp (e, ".cmd") == 0))
{
diff --git a/libbutl/string-table.mxx b/libbutl/string-table.mxx
index 201fb11..e684567 100644
--- a/libbutl/string-table.mxx
+++ b/libbutl/string-table.mxx
@@ -104,7 +104,7 @@ LIBBUTL_MODEXPORT namespace butl
using key_type = butl::map_key<std::string>;
using value_type = string_table_element<I, D>;
using map_type = std::unordered_map<key_type, value_type>;
- using traits = string_table_traits<D>;
+ using traits = string_table_traits<D>; // @@ TODO: rename traits_type;
map_type map_;
std::vector<typename map_type::const_iterator> vec_;
diff --git a/libbutl/url.mxx b/libbutl/url.mxx
index 90f1cc2..d2360f0 100644
--- a/libbutl/url.mxx
+++ b/libbutl/url.mxx
@@ -255,7 +255,7 @@ LIBBUTL_MODEXPORT namespace butl
class basic_url
{
public:
- using traits = T;
+ using traits = T; //@@ TODO: rename traits_type.
using string_type = typename traits::string_type;
using char_type = typename string_type::value_type;