fs/{,Allocated}Path: add typedef Traits
This commit is contained in:
parent
641447bf9b
commit
2b1d6ad396
@ -36,10 +36,11 @@
|
|||||||
* stored.
|
* stored.
|
||||||
*/
|
*/
|
||||||
class AllocatedPath {
|
class AllocatedPath {
|
||||||
typedef PathTraitsFS::string string;
|
using Traits = PathTraitsFS;
|
||||||
typedef PathTraitsFS::value_type value_type;
|
typedef Traits::string string;
|
||||||
typedef PathTraitsFS::pointer_type pointer_type;
|
typedef Traits::value_type value_type;
|
||||||
typedef PathTraitsFS::const_pointer_type const_pointer_type;
|
typedef Traits::pointer_type pointer_type;
|
||||||
|
typedef Traits::const_pointer_type const_pointer_type;
|
||||||
|
|
||||||
string value;
|
string value;
|
||||||
|
|
||||||
@ -52,7 +53,7 @@ class AllocatedPath {
|
|||||||
|
|
||||||
static AllocatedPath Build(const_pointer_type a, size_t a_size,
|
static AllocatedPath Build(const_pointer_type a, size_t a_size,
|
||||||
const_pointer_type b, size_t b_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:
|
public:
|
||||||
/**
|
/**
|
||||||
@ -88,8 +89,8 @@ public:
|
|||||||
gcc_pure gcc_nonnull_all
|
gcc_pure gcc_nonnull_all
|
||||||
static AllocatedPath Build(const_pointer_type a,
|
static AllocatedPath Build(const_pointer_type a,
|
||||||
const_pointer_type b) noexcept {
|
const_pointer_type b) noexcept {
|
||||||
return Build(a, PathTraitsFS::GetLength(a),
|
return Build(a, Traits::GetLength(a),
|
||||||
b, PathTraitsFS::GetLength(b));
|
b, Traits::GetLength(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
gcc_pure gcc_nonnull_all
|
gcc_pure gcc_nonnull_all
|
||||||
@ -105,7 +106,7 @@ public:
|
|||||||
gcc_pure gcc_nonnull_all
|
gcc_pure gcc_nonnull_all
|
||||||
static AllocatedPath Build(const_pointer_type a,
|
static AllocatedPath Build(const_pointer_type a,
|
||||||
const AllocatedPath &b) noexcept {
|
const AllocatedPath &b) noexcept {
|
||||||
return Build(a, PathTraitsFS::GetLength(a),
|
return Build(a, Traits::GetLength(a),
|
||||||
b.value.c_str(), b.value.size());
|
b.value.c_str(), b.value.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +114,7 @@ public:
|
|||||||
static AllocatedPath Build(const AllocatedPath &a,
|
static AllocatedPath Build(const AllocatedPath &a,
|
||||||
const_pointer_type b) noexcept {
|
const_pointer_type b) noexcept {
|
||||||
return Build(a.value.c_str(), a.value.size(),
|
return Build(a.value.c_str(), a.value.size(),
|
||||||
b, PathTraitsFS::GetLength(b));
|
b, Traits::GetLength(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
gcc_pure
|
gcc_pure
|
||||||
@ -260,7 +261,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
gcc_pure
|
gcc_pure
|
||||||
const_pointer_type Relative(Path other_fs) const noexcept {
|
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
|
gcc_pure
|
||||||
bool IsAbsolute() const noexcept {
|
bool IsAbsolute() const noexcept {
|
||||||
return PathTraitsFS::IsAbsolute(c_str());
|
return Traits::IsAbsolute(c_str());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -37,7 +37,8 @@ class AllocatedPath;
|
|||||||
* instance lives, the string must not be invalidated.
|
* instance lives, the string must not be invalidated.
|
||||||
*/
|
*/
|
||||||
class Path : public PathTraitsFS::Pointer {
|
class Path : public PathTraitsFS::Pointer {
|
||||||
typedef PathTraitsFS::Pointer Base;
|
using Traits = PathTraitsFS;
|
||||||
|
typedef Traits::Pointer Base;
|
||||||
|
|
||||||
constexpr Path(const_pointer_type _value):Base(_value) {}
|
constexpr Path(const_pointer_type _value):Base(_value) {}
|
||||||
|
|
||||||
@ -93,7 +94,7 @@ public:
|
|||||||
size_t length() const noexcept {
|
size_t length() const noexcept {
|
||||||
assert(!IsNull());
|
assert(!IsNull());
|
||||||
|
|
||||||
return PathTraitsFS::GetLength(c_str());
|
return Traits::GetLength(c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -122,7 +123,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
gcc_pure
|
gcc_pure
|
||||||
bool HasNewline() const noexcept {
|
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
|
gcc_pure
|
||||||
Path GetBase() const noexcept {
|
Path GetBase() const noexcept {
|
||||||
return FromFS(PathTraitsFS::GetBase(c_str()));
|
return FromFS(Traits::GetBase(c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -157,12 +158,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
gcc_pure
|
gcc_pure
|
||||||
const_pointer_type Relative(Path other_fs) const noexcept {
|
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
|
gcc_pure
|
||||||
bool IsAbsolute() const noexcept {
|
bool IsAbsolute() const noexcept {
|
||||||
return PathTraitsFS::IsAbsolute(c_str());
|
return Traits::IsAbsolute(c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
gcc_pure
|
gcc_pure
|
||||||
|
Loading…
Reference in New Issue
Block a user