From 2b1d6ad396f516899e7f3152c1c00a45aadd85bd Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 18 Jul 2018 13:05:23 +0200 Subject: [PATCH] fs/{,Allocated}Path: add typedef Traits --- src/fs/AllocatedPath.hxx | 23 ++++++++++++----------- src/fs/Path.hxx | 13 +++++++------ 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/fs/AllocatedPath.hxx b/src/fs/AllocatedPath.hxx index c7e68ee45..2a6277e40 100644 --- a/src/fs/AllocatedPath.hxx +++ b/src/fs/AllocatedPath.hxx @@ -36,10 +36,11 @@ * stored. */ class AllocatedPath { - typedef PathTraitsFS::string string; - typedef PathTraitsFS::value_type value_type; - typedef PathTraitsFS::pointer_type pointer_type; - typedef PathTraitsFS::const_pointer_type const_pointer_type; + using Traits = PathTraitsFS; + typedef Traits::string string; + typedef Traits::value_type value_type; + typedef Traits::pointer_type pointer_type; + typedef Traits::const_pointer_type const_pointer_type; string value; @@ -52,7 +53,7 @@ class AllocatedPath { static AllocatedPath Build(const_pointer_type a, size_t a_size, const_pointer_type b, size_t b_size) { - return AllocatedPath(PathTraitsFS::Build(a, a_size, b, b_size)); + return AllocatedPath(Traits::Build(a, a_size, b, b_size)); } public: /** @@ -88,8 +89,8 @@ public: gcc_pure gcc_nonnull_all static AllocatedPath Build(const_pointer_type a, const_pointer_type b) noexcept { - return Build(a, PathTraitsFS::GetLength(a), - b, PathTraitsFS::GetLength(b)); + return Build(a, Traits::GetLength(a), + b, Traits::GetLength(b)); } gcc_pure gcc_nonnull_all @@ -105,7 +106,7 @@ public: gcc_pure gcc_nonnull_all static AllocatedPath Build(const_pointer_type a, const AllocatedPath &b) noexcept { - return Build(a, PathTraitsFS::GetLength(a), + return Build(a, Traits::GetLength(a), b.value.c_str(), b.value.size()); } @@ -113,7 +114,7 @@ public: static AllocatedPath Build(const AllocatedPath &a, const_pointer_type b) noexcept { return Build(a.value.c_str(), a.value.size(), - b, PathTraitsFS::GetLength(b)); + b, Traits::GetLength(b)); } gcc_pure @@ -260,7 +261,7 @@ public: */ gcc_pure const_pointer_type Relative(Path other_fs) const noexcept { - return PathTraitsFS::Relative(c_str(), other_fs.c_str()); + return Traits::Relative(c_str(), other_fs.c_str()); } /** @@ -270,7 +271,7 @@ public: gcc_pure bool IsAbsolute() const noexcept { - return PathTraitsFS::IsAbsolute(c_str()); + return Traits::IsAbsolute(c_str()); } }; diff --git a/src/fs/Path.hxx b/src/fs/Path.hxx index 2415923d0..d43527254 100644 --- a/src/fs/Path.hxx +++ b/src/fs/Path.hxx @@ -37,7 +37,8 @@ class AllocatedPath; * instance lives, the string must not be invalidated. */ class Path : public PathTraitsFS::Pointer { - typedef PathTraitsFS::Pointer Base; + using Traits = PathTraitsFS; + typedef Traits::Pointer Base; constexpr Path(const_pointer_type _value):Base(_value) {} @@ -93,7 +94,7 @@ public: size_t length() const noexcept { assert(!IsNull()); - return PathTraitsFS::GetLength(c_str()); + return Traits::GetLength(c_str()); } /** @@ -122,7 +123,7 @@ public: */ gcc_pure bool HasNewline() const noexcept { - return PathTraitsFS::Find(c_str(), '\n') != nullptr; + return Traits::Find(c_str(), '\n') != nullptr; } /** @@ -139,7 +140,7 @@ public: */ gcc_pure Path GetBase() const noexcept { - return FromFS(PathTraitsFS::GetBase(c_str())); + return FromFS(Traits::GetBase(c_str())); } /** @@ -157,12 +158,12 @@ public: */ gcc_pure const_pointer_type Relative(Path other_fs) const noexcept { - return PathTraitsFS::Relative(c_str(), other_fs.c_str()); + return Traits::Relative(c_str(), other_fs.c_str()); } gcc_pure bool IsAbsolute() const noexcept { - return PathTraitsFS::IsAbsolute(c_str()); + return Traits::IsAbsolute(c_str()); } gcc_pure