Commit 9b854468 authored by Max Kellermann's avatar Max Kellermann

util/StringPointer: rename typedef pointer to pointer_type

parent fd5d4283
...@@ -280,7 +280,7 @@ class ConfigLoader ...@@ -280,7 +280,7 @@ class ConfigLoader
public: public:
bool TryFile(const Path path); bool TryFile(const Path path);
bool TryFile(const AllocatedPath &base_path, bool TryFile(const AllocatedPath &base_path,
PathTraitsFS::const_pointer path); PathTraitsFS::const_pointer_type path);
}; };
bool ConfigLoader::TryFile(Path path) bool ConfigLoader::TryFile(Path path)
...@@ -293,7 +293,7 @@ bool ConfigLoader::TryFile(Path path) ...@@ -293,7 +293,7 @@ bool ConfigLoader::TryFile(Path path)
} }
bool ConfigLoader::TryFile(const AllocatedPath &base_path, bool ConfigLoader::TryFile(const AllocatedPath &base_path,
PathTraitsFS::const_pointer path) PathTraitsFS::const_pointer_type path)
{ {
if (base_path.IsNull()) if (base_path.IsNull())
return false; return false;
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
gcc_pure gcc_pure
static bool static bool
SkipNameFS(PathTraitsFS::const_pointer name_fs) SkipNameFS(PathTraitsFS::const_pointer_type name_fs)
{ {
return name_fs[0] == '.' && return name_fs[0] == '.' &&
(name_fs[1] == 0 || (name_fs[1] == 0 ||
......
...@@ -40,18 +40,18 @@ class Error; ...@@ -40,18 +40,18 @@ class Error;
class AllocatedPath { class AllocatedPath {
typedef PathTraitsFS::string string; typedef PathTraitsFS::string string;
typedef PathTraitsFS::value_type value_type; typedef PathTraitsFS::value_type value_type;
typedef PathTraitsFS::pointer pointer; typedef PathTraitsFS::pointer_type pointer_type;
typedef PathTraitsFS::const_pointer const_pointer; typedef PathTraitsFS::const_pointer_type const_pointer_type;
string value; string value;
AllocatedPath(std::nullptr_t):value() {} AllocatedPath(std::nullptr_t):value() {}
AllocatedPath(const_pointer _value):value(_value) {} AllocatedPath(const_pointer_type _value):value(_value) {}
AllocatedPath(string &&_value):value(std::move(_value)) {} AllocatedPath(string &&_value):value(std::move(_value)) {}
static AllocatedPath Build(const_pointer a, size_t a_size, static AllocatedPath Build(const_pointer_type a, size_t a_size,
const_pointer 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(PathTraitsFS::Build(a, a_size, b, b_size));
} }
public: public:
...@@ -89,13 +89,13 @@ public: ...@@ -89,13 +89,13 @@ public:
* Join two path components with the path separator. * Join two path components with the path separator.
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static AllocatedPath Build(const_pointer a, const_pointer b) { static AllocatedPath Build(const_pointer_type a, const_pointer_type b) {
return Build(a, PathTraitsFS::GetLength(a), return Build(a, PathTraitsFS::GetLength(a),
b, PathTraitsFS::GetLength(b)); b, PathTraitsFS::GetLength(b));
} }
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static AllocatedPath Build(Path a, const_pointer b) { static AllocatedPath Build(Path a, const_pointer_type b) {
return Build(a.c_str(), b); return Build(a.c_str(), b);
} }
...@@ -105,13 +105,13 @@ public: ...@@ -105,13 +105,13 @@ public:
} }
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static AllocatedPath Build(const_pointer a, const AllocatedPath &b) { static AllocatedPath Build(const_pointer_type a, const AllocatedPath &b) {
return Build(a, PathTraitsFS::GetLength(a), return Build(a, PathTraitsFS::GetLength(a),
b.value.c_str(), b.value.size()); b.value.c_str(), b.value.size());
} }
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static AllocatedPath Build(const AllocatedPath &a, const_pointer b) { static AllocatedPath Build(const AllocatedPath &a, const_pointer_type b) {
return Build(a.value.c_str(), a.value.size(), return Build(a.value.c_str(), a.value.size(),
b, PathTraitsFS::GetLength(b)); b, PathTraitsFS::GetLength(b));
} }
...@@ -128,7 +128,7 @@ public: ...@@ -128,7 +128,7 @@ public:
* character set to a #Path instance. * character set to a #Path instance.
*/ */
gcc_pure gcc_pure
static AllocatedPath FromFS(const_pointer fs) { static AllocatedPath FromFS(const_pointer_type fs) {
return AllocatedPath(fs); return AllocatedPath(fs);
} }
...@@ -214,7 +214,7 @@ public: ...@@ -214,7 +214,7 @@ public:
* instance ends. * instance ends.
*/ */
gcc_pure gcc_pure
const_pointer c_str() const { const_pointer_type c_str() const {
return value.c_str(); return value.c_str();
} }
...@@ -223,7 +223,7 @@ public: ...@@ -223,7 +223,7 @@ public:
* null-terminated. * null-terminated.
*/ */
gcc_pure gcc_pure
const_pointer data() const { const_pointer_type data() const {
return value.data(); return value.data();
} }
...@@ -249,7 +249,7 @@ public: ...@@ -249,7 +249,7 @@ public:
* nullptr on mismatch. * nullptr on mismatch.
*/ */
gcc_pure gcc_pure
const_pointer Relative(Path other_fs) const { const_pointer_type Relative(Path other_fs) const {
return PathTraitsFS::Relative(c_str(), other_fs.c_str()); return PathTraitsFS::Relative(c_str(), other_fs.c_str());
} }
......
...@@ -94,7 +94,7 @@ FixSeparators(PathTraitsUTF8::string &&s) ...@@ -94,7 +94,7 @@ FixSeparators(PathTraitsUTF8::string &&s)
} }
PathTraitsUTF8::string PathTraitsUTF8::string
PathToUTF8(PathTraitsFS::const_pointer path_fs) PathToUTF8(PathTraitsFS::const_pointer_type path_fs)
{ {
#if !CLANG_CHECK_VERSION(3,6) #if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */ /* disabled on clang due to -Wtautological-pointer-compare */
...@@ -126,7 +126,7 @@ PathToUTF8(PathTraitsFS::const_pointer path_fs) ...@@ -126,7 +126,7 @@ PathToUTF8(PathTraitsFS::const_pointer path_fs)
#if defined(HAVE_FS_CHARSET) || defined(WIN32) #if defined(HAVE_FS_CHARSET) || defined(WIN32)
PathTraitsFS::string PathTraitsFS::string
PathFromUTF8(PathTraitsUTF8::const_pointer path_utf8) PathFromUTF8(PathTraitsUTF8::const_pointer_type path_utf8)
{ {
#if !CLANG_CHECK_VERSION(3,6) #if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */ /* disabled on clang due to -Wtautological-pointer-compare */
......
...@@ -49,7 +49,7 @@ DeinitFSCharset(); ...@@ -49,7 +49,7 @@ DeinitFSCharset();
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
PathTraitsUTF8::string PathTraitsUTF8::string
PathToUTF8(PathTraitsFS::const_pointer path_fs); PathToUTF8(PathTraitsFS::const_pointer_type path_fs);
/** /**
* Convert the path from UTF-8. * Convert the path from UTF-8.
...@@ -57,6 +57,6 @@ PathToUTF8(PathTraitsFS::const_pointer path_fs); ...@@ -57,6 +57,6 @@ PathToUTF8(PathTraitsFS::const_pointer path_fs);
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
PathTraitsFS::string PathTraitsFS::string
PathFromUTF8(PathTraitsUTF8::const_pointer path_utf8); PathFromUTF8(PathTraitsUTF8::const_pointer_type path_utf8);
#endif #endif
...@@ -37,10 +37,10 @@ class DirectoryReader { ...@@ -37,10 +37,10 @@ class DirectoryReader {
bool first = true; bool first = true;
class MakeWildcardPath { class MakeWildcardPath {
PathTraitsFS::pointer path; PathTraitsFS::pointer_type path;
public: public:
MakeWildcardPath(PathTraitsFS::const_pointer _path) { MakeWildcardPath(PathTraitsFS::const_pointer_type _path) {
auto l = _tcslen(_path); auto l = _tcslen(_path);
path = new PathTraitsFS::value_type[l + 3]; path = new PathTraitsFS::value_type[l + 3];
_tcscpy(path, _path); _tcscpy(path, _path);
...@@ -53,7 +53,7 @@ class DirectoryReader { ...@@ -53,7 +53,7 @@ class DirectoryReader {
delete[] path; delete[] path;
} }
operator PathTraitsFS::const_pointer() const { operator PathTraitsFS::const_pointer_type() const {
return path; return path;
} }
}; };
......
...@@ -41,19 +41,19 @@ namespace FOpenMode { ...@@ -41,19 +41,19 @@ namespace FOpenMode {
/** /**
* Open mode for writing text files. * Open mode for writing text files.
*/ */
constexpr PathTraitsFS::const_pointer WriteText = PATH_LITERAL("w"); constexpr PathTraitsFS::const_pointer_type WriteText = PATH_LITERAL("w");
/** /**
* Open mode for appending text files. * Open mode for appending text files.
*/ */
constexpr PathTraitsFS::const_pointer AppendText = PATH_LITERAL("a"); constexpr PathTraitsFS::const_pointer_type AppendText = PATH_LITERAL("a");
} }
/** /**
* Wrapper for fopen() that uses #Path names. * Wrapper for fopen() that uses #Path names.
*/ */
static inline FILE * static inline FILE *
FOpen(Path file, PathTraitsFS::const_pointer mode) FOpen(Path file, PathTraitsFS::const_pointer_type mode)
{ {
#ifdef WIN32 #ifdef WIN32
return _tfopen(file.c_str(), mode); return _tfopen(file.c_str(), mode);
......
...@@ -43,7 +43,7 @@ class NarrowPath { ...@@ -43,7 +43,7 @@ class NarrowPath {
#else #else
typedef StringPointer<> Value; typedef StringPointer<> Value;
#endif #endif
typedef typename Value::const_pointer const_pointer; typedef typename Value::const_pointer_type const_pointer_type;
Value value; Value value;
...@@ -59,11 +59,11 @@ public: ...@@ -59,11 +59,11 @@ public:
explicit NarrowPath(Path _path):value(_path.c_str()) {} explicit NarrowPath(Path _path):value(_path.c_str()) {}
#endif #endif
operator const_pointer() const { operator const_pointer_type() const {
return c_str(); return c_str();
} }
const_pointer c_str() const { const_pointer_type c_str() const {
return value.c_str(); return value.c_str();
} }
}; };
......
...@@ -27,7 +27,7 @@ Path::ToUTF8() const ...@@ -27,7 +27,7 @@ Path::ToUTF8() const
return ::PathToUTF8(c_str()); return ::PathToUTF8(c_str());
} }
Path::const_pointer Path::const_pointer_type
Path::GetSuffix() const Path::GetSuffix() const
{ {
const auto base = GetBase().c_str(); const auto base = GetBase().c_str();
......
...@@ -39,7 +39,7 @@ class AllocatedPath; ...@@ -39,7 +39,7 @@ class AllocatedPath;
class Path : public PathTraitsFS::Pointer { class Path : public PathTraitsFS::Pointer {
typedef PathTraitsFS::Pointer Base; typedef PathTraitsFS::Pointer Base;
constexpr Path(const_pointer _value):Base(_value) {} constexpr Path(const_pointer_type _value):Base(_value) {}
public: public:
/** /**
...@@ -61,7 +61,7 @@ public: ...@@ -61,7 +61,7 @@ public:
* Create a new instance pointing to the specified path * Create a new instance pointing to the specified path
* string. * string.
*/ */
static constexpr Path FromFS(const_pointer fs) { static constexpr Path FromFS(const_pointer_type fs) {
return Path(fs); return Path(fs);
} }
...@@ -104,7 +104,7 @@ public: ...@@ -104,7 +104,7 @@ public:
* instance ends. * instance ends.
*/ */
gcc_pure gcc_pure
const_pointer c_str() const { const_pointer_type c_str() const {
return Base::c_str(); return Base::c_str();
} }
...@@ -113,7 +113,7 @@ public: ...@@ -113,7 +113,7 @@ public:
* null-terminated. * null-terminated.
*/ */
gcc_pure gcc_pure
const_pointer data() const { const_pointer_type data() const {
return c_str(); return c_str();
} }
...@@ -158,7 +158,7 @@ public: ...@@ -158,7 +158,7 @@ public:
* nullptr on mismatch. * nullptr on mismatch.
*/ */
gcc_pure gcc_pure
const_pointer Relative(Path other_fs) const { const_pointer_type Relative(Path other_fs) const {
return PathTraitsFS::Relative(c_str(), other_fs.c_str()); return PathTraitsFS::Relative(c_str(), other_fs.c_str());
} }
...@@ -168,7 +168,7 @@ public: ...@@ -168,7 +168,7 @@ public:
} }
gcc_pure gcc_pure
const_pointer GetSuffix() const; const_pointer_type GetSuffix() const;
}; };
#endif #endif
...@@ -91,18 +91,21 @@ public: ...@@ -91,18 +91,21 @@ public:
}; };
#endif #endif
static inline bool IsValidPathString(PathTraitsFS::const_pointer path) static inline bool
IsValidPathString(PathTraitsFS::const_pointer_type path)
{ {
return path != nullptr && *path != '\0'; return path != nullptr && *path != '\0';
} }
static inline bool IsValidDir(PathTraitsFS::const_pointer dir) static inline bool
IsValidDir(PathTraitsFS::const_pointer_type dir)
{ {
return PathTraitsFS::IsAbsolute(dir) && return PathTraitsFS::IsAbsolute(dir) &&
DirectoryExists(Path::FromFS(dir)); DirectoryExists(Path::FromFS(dir));
} }
static inline AllocatedPath SafePathFromFS(PathTraitsFS::const_pointer dir) static inline AllocatedPath
SafePathFromFS(PathTraitsFS::const_pointer_type dir)
{ {
if (IsValidPathString(dir) && IsValidDir(dir)) if (IsValidPathString(dir) && IsValidDir(dir))
return AllocatedPath::FromFS(dir); return AllocatedPath::FromFS(dir);
......
...@@ -25,8 +25,8 @@ ...@@ -25,8 +25,8 @@
template<typename Traits> template<typename Traits>
typename Traits::string typename Traits::string
BuildPathImpl(typename Traits::const_pointer a, size_t a_size, BuildPathImpl(typename Traits::const_pointer_type a, size_t a_size,
typename Traits::const_pointer b, size_t b_size) typename Traits::const_pointer_type b, size_t b_size)
{ {
assert(a != nullptr); assert(a != nullptr);
assert(b != nullptr); assert(b != nullptr);
...@@ -50,15 +50,15 @@ BuildPathImpl(typename Traits::const_pointer a, size_t a_size, ...@@ -50,15 +50,15 @@ BuildPathImpl(typename Traits::const_pointer a, size_t a_size,
} }
template<typename Traits> template<typename Traits>
typename Traits::const_pointer typename Traits::const_pointer_type
GetBasePathImpl(typename Traits::const_pointer p) GetBasePathImpl(typename Traits::const_pointer_type p)
{ {
#if !CLANG_CHECK_VERSION(3,6) #if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */ /* disabled on clang due to -Wtautological-pointer-compare */
assert(p != nullptr); assert(p != nullptr);
#endif #endif
typename Traits::const_pointer sep = Traits::FindLastSeparator(p); typename Traits::const_pointer_type sep = Traits::FindLastSeparator(p);
return sep != nullptr return sep != nullptr
? sep + 1 ? sep + 1
: p; : p;
...@@ -66,14 +66,14 @@ GetBasePathImpl(typename Traits::const_pointer p) ...@@ -66,14 +66,14 @@ GetBasePathImpl(typename Traits::const_pointer p)
template<typename Traits> template<typename Traits>
typename Traits::string typename Traits::string
GetParentPathImpl(typename Traits::const_pointer p) GetParentPathImpl(typename Traits::const_pointer_type p)
{ {
#if !CLANG_CHECK_VERSION(3,6) #if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */ /* disabled on clang due to -Wtautological-pointer-compare */
assert(p != nullptr); assert(p != nullptr);
#endif #endif
typename Traits::const_pointer sep = Traits::FindLastSeparator(p); typename Traits::const_pointer_type sep = Traits::FindLastSeparator(p);
if (sep == nullptr) if (sep == nullptr)
return typename Traits::string(Traits::CURRENT_DIRECTORY); return typename Traits::string(Traits::CURRENT_DIRECTORY);
if (sep == p) if (sep == p)
...@@ -86,9 +86,9 @@ GetParentPathImpl(typename Traits::const_pointer p) ...@@ -86,9 +86,9 @@ GetParentPathImpl(typename Traits::const_pointer p)
} }
template<typename Traits> template<typename Traits>
typename Traits::const_pointer typename Traits::const_pointer_type
RelativePathImpl(typename Traits::const_pointer base, RelativePathImpl(typename Traits::const_pointer_type base,
typename Traits::const_pointer other) typename Traits::const_pointer_type other)
{ {
assert(base != nullptr); assert(base != nullptr);
assert(other != nullptr); assert(other != nullptr);
...@@ -113,51 +113,51 @@ RelativePathImpl(typename Traits::const_pointer base, ...@@ -113,51 +113,51 @@ RelativePathImpl(typename Traits::const_pointer base,
} }
PathTraitsFS::string PathTraitsFS::string
PathTraitsFS::Build(PathTraitsFS::const_pointer a, size_t a_size, PathTraitsFS::Build(const_pointer_type a, size_t a_size,
PathTraitsFS::const_pointer b, size_t b_size) const_pointer_type b, size_t b_size)
{ {
return BuildPathImpl<PathTraitsFS>(a, a_size, b, b_size); return BuildPathImpl<PathTraitsFS>(a, a_size, b, b_size);
} }
PathTraitsFS::const_pointer PathTraitsFS::const_pointer_type
PathTraitsFS::GetBase(PathTraitsFS::const_pointer p) PathTraitsFS::GetBase(PathTraitsFS::const_pointer_type p)
{ {
return GetBasePathImpl<PathTraitsFS>(p); return GetBasePathImpl<PathTraitsFS>(p);
} }
PathTraitsFS::string PathTraitsFS::string
PathTraitsFS::GetParent(PathTraitsFS::const_pointer p) PathTraitsFS::GetParent(PathTraitsFS::const_pointer_type p)
{ {
return GetParentPathImpl<PathTraitsFS>(p); return GetParentPathImpl<PathTraitsFS>(p);
} }
PathTraitsFS::const_pointer PathTraitsFS::const_pointer_type
PathTraitsFS::Relative(const_pointer base, const_pointer other) PathTraitsFS::Relative(const_pointer_type base, const_pointer_type other)
{ {
return RelativePathImpl<PathTraitsFS>(base, other); return RelativePathImpl<PathTraitsFS>(base, other);
} }
PathTraitsUTF8::string PathTraitsUTF8::string
PathTraitsUTF8::Build(PathTraitsUTF8::const_pointer a, size_t a_size, PathTraitsUTF8::Build(const_pointer_type a, size_t a_size,
PathTraitsUTF8::const_pointer b, size_t b_size) const_pointer_type b, size_t b_size)
{ {
return BuildPathImpl<PathTraitsUTF8>(a, a_size, b, b_size); return BuildPathImpl<PathTraitsUTF8>(a, a_size, b, b_size);
} }
PathTraitsUTF8::const_pointer PathTraitsUTF8::const_pointer_type
PathTraitsUTF8::GetBase(PathTraitsUTF8::const_pointer p) PathTraitsUTF8::GetBase(const_pointer_type p)
{ {
return GetBasePathImpl<PathTraitsUTF8>(p); return GetBasePathImpl<PathTraitsUTF8>(p);
} }
PathTraitsUTF8::string PathTraitsUTF8::string
PathTraitsUTF8::GetParent(PathTraitsUTF8::const_pointer p) PathTraitsUTF8::GetParent(const_pointer_type p)
{ {
return GetParentPathImpl<PathTraitsUTF8>(p); return GetParentPathImpl<PathTraitsUTF8>(p);
} }
PathTraitsUTF8::const_pointer PathTraitsUTF8::const_pointer_type
PathTraitsUTF8::Relative(const_pointer base, const_pointer other) PathTraitsUTF8::Relative(const_pointer_type base, const_pointer_type other)
{ {
return RelativePathImpl<PathTraitsUTF8>(base, other); return RelativePathImpl<PathTraitsUTF8>(base, other);
} }
...@@ -52,8 +52,8 @@ struct PathTraitsFS { ...@@ -52,8 +52,8 @@ struct PathTraitsFS {
typedef string::traits_type char_traits; typedef string::traits_type char_traits;
typedef char_traits::char_type value_type; typedef char_traits::char_type value_type;
typedef StringPointer<value_type> Pointer; typedef StringPointer<value_type> Pointer;
typedef Pointer::pointer pointer; typedef Pointer::pointer_type pointer_type;
typedef Pointer::const_pointer const_pointer; typedef Pointer::const_pointer_type const_pointer_type;
#ifdef WIN32 #ifdef WIN32
static constexpr value_type SEPARATOR = '\\'; static constexpr value_type SEPARATOR = '\\';
...@@ -61,7 +61,7 @@ struct PathTraitsFS { ...@@ -61,7 +61,7 @@ struct PathTraitsFS {
static constexpr value_type SEPARATOR = '/'; static constexpr value_type SEPARATOR = '/';
#endif #endif
static constexpr const_pointer CURRENT_DIRECTORY = PATH_LITERAL("."); static constexpr const_pointer_type CURRENT_DIRECTORY = PATH_LITERAL(".");
static constexpr bool IsSeparator(value_type ch) { static constexpr bool IsSeparator(value_type ch) {
return return
...@@ -72,14 +72,14 @@ struct PathTraitsFS { ...@@ -72,14 +72,14 @@ struct PathTraitsFS {
} }
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static const_pointer FindLastSeparator(const_pointer p) { static const_pointer_type FindLastSeparator(const_pointer_type p) {
#if !CLANG_CHECK_VERSION(3,6) #if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */ /* disabled on clang due to -Wtautological-pointer-compare */
assert(p != nullptr); assert(p != nullptr);
#endif #endif
#ifdef WIN32 #ifdef WIN32
const_pointer pos = p + GetLength(p); const_pointer_type pos = p + GetLength(p);
while (p != pos && !IsSeparator(*pos)) while (p != pos && !IsSeparator(*pos))
--pos; --pos;
return IsSeparator(*pos) ? pos : nullptr; return IsSeparator(*pos) ? pos : nullptr;
...@@ -90,13 +90,13 @@ struct PathTraitsFS { ...@@ -90,13 +90,13 @@ struct PathTraitsFS {
#ifdef WIN32 #ifdef WIN32
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static constexpr bool IsDrive(const_pointer p) { static constexpr bool IsDrive(const_pointer_type p) {
return IsAlphaASCII(p[0]) && p[1] == ':'; return IsAlphaASCII(p[0]) && p[1] == ':';
} }
#endif #endif
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static bool IsAbsolute(const_pointer p) { static bool IsAbsolute(const_pointer_type p) {
#if !CLANG_CHECK_VERSION(3,6) #if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */ /* disabled on clang due to -Wtautological-pointer-compare */
assert(p != nullptr); assert(p != nullptr);
...@@ -110,12 +110,12 @@ struct PathTraitsFS { ...@@ -110,12 +110,12 @@ struct PathTraitsFS {
} }
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static size_t GetLength(const_pointer p) { static size_t GetLength(const_pointer_type p) {
return StringLength(p); return StringLength(p);
} }
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static const_pointer Find(const_pointer p, value_type ch) { static const_pointer_type Find(const_pointer_type p, value_type ch) {
return StringFind(p, ch); return StringFind(p, ch);
} }
...@@ -124,7 +124,7 @@ struct PathTraitsFS { ...@@ -124,7 +124,7 @@ struct PathTraitsFS {
* The return value points inside the given string. * The return value points inside the given string.
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static const_pointer GetBase(const_pointer p); static const_pointer_type GetBase(const_pointer_type p);
/** /**
* Determine the "parent" file name of the given native path. * Determine the "parent" file name of the given native path.
...@@ -132,7 +132,7 @@ struct PathTraitsFS { ...@@ -132,7 +132,7 @@ struct PathTraitsFS {
* separator in the given input string. * separator in the given input string.
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static string GetParent(const_pointer p); static string GetParent(const_pointer_type p);
/** /**
* Determine the relative part of the given path to this * Determine the relative part of the given path to this
...@@ -141,7 +141,8 @@ struct PathTraitsFS { ...@@ -141,7 +141,8 @@ struct PathTraitsFS {
* nullptr on mismatch. * nullptr on mismatch.
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static const_pointer Relative(const_pointer base, const_pointer other); static const_pointer_type Relative(const_pointer_type base,
const_pointer_type other);
/** /**
* Constructs the path from the given components. * Constructs the path from the given components.
...@@ -150,11 +151,11 @@ struct PathTraitsFS { ...@@ -150,11 +151,11 @@ struct PathTraitsFS {
* If both components are empty strings, empty string is returned. * If both components are empty strings, empty string is returned.
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static string Build(const_pointer a, size_t a_size, static string Build(const_pointer_type a, size_t a_size,
const_pointer b, size_t b_size); const_pointer_type b, size_t b_size);
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static string Build(const_pointer a, const_pointer b) { static string Build(const_pointer_type a, const_pointer_type b) {
return Build(a, GetLength(a), b, GetLength(b)); return Build(a, GetLength(a), b, GetLength(b));
} }
}; };
...@@ -166,19 +167,19 @@ struct PathTraitsUTF8 { ...@@ -166,19 +167,19 @@ struct PathTraitsUTF8 {
typedef std::string string; typedef std::string string;
typedef string::traits_type char_traits; typedef string::traits_type char_traits;
typedef char_traits::char_type value_type; typedef char_traits::char_type value_type;
typedef value_type *pointer; typedef value_type *pointer_type;
typedef const value_type *const_pointer; typedef const value_type *const_pointer_type;
static constexpr value_type SEPARATOR = '/'; static constexpr value_type SEPARATOR = '/';
static constexpr const_pointer CURRENT_DIRECTORY = "."; static constexpr const_pointer_type CURRENT_DIRECTORY = ".";
static constexpr bool IsSeparator(value_type ch) { static constexpr bool IsSeparator(value_type ch) {
return ch == SEPARATOR; return ch == SEPARATOR;
} }
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static const_pointer FindLastSeparator(const_pointer p) { static const_pointer_type FindLastSeparator(const_pointer_type p) {
#if !CLANG_CHECK_VERSION(3,6) #if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */ /* disabled on clang due to -Wtautological-pointer-compare */
assert(p != nullptr); assert(p != nullptr);
...@@ -189,13 +190,13 @@ struct PathTraitsUTF8 { ...@@ -189,13 +190,13 @@ struct PathTraitsUTF8 {
#ifdef WIN32 #ifdef WIN32
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static constexpr bool IsDrive(const_pointer p) { static constexpr bool IsDrive(const_pointer_type p) {
return IsAlphaASCII(p[0]) && p[1] == ':'; return IsAlphaASCII(p[0]) && p[1] == ':';
} }
#endif #endif
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static bool IsAbsolute(const_pointer p) { static bool IsAbsolute(const_pointer_type p) {
#if !CLANG_CHECK_VERSION(3,6) #if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */ /* disabled on clang due to -Wtautological-pointer-compare */
assert(p != nullptr); assert(p != nullptr);
...@@ -209,12 +210,12 @@ struct PathTraitsUTF8 { ...@@ -209,12 +210,12 @@ struct PathTraitsUTF8 {
} }
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static size_t GetLength(const_pointer p) { static size_t GetLength(const_pointer_type p) {
return StringLength(p); return StringLength(p);
} }
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static const_pointer Find(const_pointer p, value_type ch) { static const_pointer_type Find(const_pointer_type p, value_type ch) {
return StringFind(p, ch); return StringFind(p, ch);
} }
...@@ -223,7 +224,7 @@ struct PathTraitsUTF8 { ...@@ -223,7 +224,7 @@ struct PathTraitsUTF8 {
* The return value points inside the given string. * The return value points inside the given string.
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static const_pointer GetBase(const_pointer p); static const_pointer_type GetBase(const_pointer_type p);
/** /**
* Determine the "parent" file name of the given UTF-8 path. * Determine the "parent" file name of the given UTF-8 path.
...@@ -231,7 +232,7 @@ struct PathTraitsUTF8 { ...@@ -231,7 +232,7 @@ struct PathTraitsUTF8 {
* separator in the given input string. * separator in the given input string.
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static string GetParent(const_pointer p); static string GetParent(const_pointer_type p);
/** /**
* Determine the relative part of the given path to this * Determine the relative part of the given path to this
...@@ -240,7 +241,8 @@ struct PathTraitsUTF8 { ...@@ -240,7 +241,8 @@ struct PathTraitsUTF8 {
* nullptr on mismatch. * nullptr on mismatch.
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static const_pointer Relative(const_pointer base, const_pointer other); static const_pointer_type Relative(const_pointer_type base,
const_pointer_type other);
/** /**
* Constructs the path from the given components. * Constructs the path from the given components.
...@@ -249,11 +251,11 @@ struct PathTraitsUTF8 { ...@@ -249,11 +251,11 @@ struct PathTraitsUTF8 {
* If both components are empty strings, empty string is returned. * If both components are empty strings, empty string is returned.
*/ */
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static string Build(const_pointer a, size_t a_size, static string Build(const_pointer_type a, size_t a_size,
const_pointer b, size_t b_size); const_pointer_type b, size_t b_size);
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static string Build(const_pointer a, const_pointer b) { static string Build(const_pointer_type a, const_pointer_type b) {
return Build(a, GetLength(a), b, GetLength(b)); return Build(a, GetLength(a), b, GetLength(b));
} }
}; };
......
...@@ -161,7 +161,7 @@ LocalStorage::OpenDirectory(const char *uri_utf8, Error &error) ...@@ -161,7 +161,7 @@ LocalStorage::OpenDirectory(const char *uri_utf8, Error &error)
gcc_pure gcc_pure
static bool static bool
SkipNameFS(PathTraitsFS::const_pointer name_fs) SkipNameFS(PathTraitsFS::const_pointer_type name_fs)
{ {
return name_fs[0] == '.' && return name_fs[0] == '.' &&
(name_fs[1] == 0 || (name_fs[1] == 0 ||
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
template<> template<>
AllocatedString<char> AllocatedString<char>
AllocatedString<char>::Duplicate(const_pointer src) AllocatedString<char>::Duplicate(const_pointer_type src)
{ {
return Duplicate(src, StringLength(src)); return Duplicate(src, StringLength(src));
} }
...@@ -44,15 +44,15 @@ template<typename T=char> ...@@ -44,15 +44,15 @@ template<typename T=char>
class AllocatedString { class AllocatedString {
public: public:
typedef typename StringPointer<T>::value_type value_type; typedef typename StringPointer<T>::value_type value_type;
typedef typename StringPointer<T>::pointer pointer; typedef typename StringPointer<T>::pointer_type pointer_type;
typedef typename StringPointer<T>::const_pointer const_pointer; typedef typename StringPointer<T>::const_pointer_type const_pointer_type;
static constexpr value_type SENTINEL = '\0'; static constexpr value_type SENTINEL = '\0';
private: private:
pointer value; pointer_type value;
explicit AllocatedString(pointer _value) explicit AllocatedString(pointer_type _value)
:value(_value) {} :value(_value) {}
public: public:
...@@ -65,7 +65,7 @@ public: ...@@ -65,7 +65,7 @@ public:
delete[] value; delete[] value;
} }
static AllocatedString Donate(pointer value) { static AllocatedString Donate(pointer_type value) {
return AllocatedString(value); return AllocatedString(value);
} }
...@@ -79,16 +79,16 @@ public: ...@@ -79,16 +79,16 @@ public:
return Donate(p); return Donate(p);
} }
static AllocatedString Duplicate(const_pointer src); static AllocatedString Duplicate(const_pointer_type src);
static AllocatedString Duplicate(const_pointer begin, static AllocatedString Duplicate(const_pointer_type begin,
const_pointer end) { const_pointer_type end) {
auto p = new value_type[end - begin + 1]; auto p = new value_type[end - begin + 1];
*std::copy(begin, end, p) = SENTINEL; *std::copy(begin, end, p) = SENTINEL;
return Donate(p); return Donate(p);
} }
static AllocatedString Duplicate(const_pointer begin, static AllocatedString Duplicate(const_pointer_type begin,
size_t length) { size_t length) {
auto p = new value_type[length + 1]; auto p = new value_type[length + 1];
*std::copy_n(begin, length, p) = SENTINEL; *std::copy_n(begin, length, p) = SENTINEL;
...@@ -104,7 +104,7 @@ public: ...@@ -104,7 +104,7 @@ public:
return value == nullptr; return value == nullptr;
} }
constexpr const_pointer c_str() const { constexpr const_pointer_type c_str() const {
return value; return value;
} }
...@@ -112,8 +112,8 @@ public: ...@@ -112,8 +112,8 @@ public:
return *value == SENTINEL; return *value == SENTINEL;
} }
pointer Steal() { pointer_type Steal() {
pointer result = value; pointer_type result = value;
value = nullptr; value = nullptr;
return result; return result;
} }
......
...@@ -37,17 +37,17 @@ template<typename T=char> ...@@ -37,17 +37,17 @@ template<typename T=char>
class StringPointer { class StringPointer {
public: public:
typedef T value_type; typedef T value_type;
typedef T *pointer; typedef T *pointer_type;
typedef const T *const_pointer; typedef const T *const_pointer_type;
static constexpr value_type SENTINEL = '\0'; static constexpr value_type SENTINEL = '\0';
private: private:
const_pointer value; const_pointer_type value;
public: public:
StringPointer() = default; StringPointer() = default;
constexpr StringPointer(const_pointer _value) constexpr StringPointer(const_pointer_type _value)
:value(_value) {} :value(_value) {}
/** /**
...@@ -58,7 +58,7 @@ public: ...@@ -58,7 +58,7 @@ public:
return value == nullptr; return value == nullptr;
} }
constexpr const_pointer c_str() const { constexpr const_pointer_type c_str() const {
return value; return value;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment