From 9b854468087a620e8fd442a5e764858f5454f48e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 12 Apr 2016 22:49:03 +0200 Subject: util/StringPointer: rename typedef pointer to pointer_type --- src/fs/AllocatedPath.hxx | 26 +++++++++---------- src/fs/Charset.cxx | 4 +-- src/fs/Charset.hxx | 4 +-- src/fs/DirectoryReader.hxx | 6 ++--- src/fs/FileSystem.hxx | 6 ++--- src/fs/NarrowPath.hxx | 6 ++--- src/fs/Path.cxx | 2 +- src/fs/Path.hxx | 12 ++++----- src/fs/StandardDirectory.cxx | 9 ++++--- src/fs/Traits.cxx | 48 +++++++++++++++++------------------ src/fs/Traits.hxx | 60 +++++++++++++++++++++++--------------------- 11 files changed, 94 insertions(+), 89 deletions(-) (limited to 'src/fs') diff --git a/src/fs/AllocatedPath.hxx b/src/fs/AllocatedPath.hxx index a950908fc..2aa2fc2a9 100644 --- a/src/fs/AllocatedPath.hxx +++ b/src/fs/AllocatedPath.hxx @@ -40,18 +40,18 @@ class Error; class AllocatedPath { typedef PathTraitsFS::string string; typedef PathTraitsFS::value_type value_type; - typedef PathTraitsFS::pointer pointer; - typedef PathTraitsFS::const_pointer const_pointer; + typedef PathTraitsFS::pointer_type pointer_type; + typedef PathTraitsFS::const_pointer_type const_pointer_type; string 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)) {} - static AllocatedPath Build(const_pointer a, size_t a_size, - const_pointer b, size_t b_size) { + 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)); } public: @@ -89,13 +89,13 @@ public: * Join two path components with the path separator. */ 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), b, PathTraitsFS::GetLength(b)); } 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); } @@ -105,13 +105,13 @@ public: } 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), b.value.c_str(), b.value.size()); } 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(), b, PathTraitsFS::GetLength(b)); } @@ -128,7 +128,7 @@ public: * character set to a #Path instance. */ gcc_pure - static AllocatedPath FromFS(const_pointer fs) { + static AllocatedPath FromFS(const_pointer_type fs) { return AllocatedPath(fs); } @@ -214,7 +214,7 @@ public: * instance ends. */ gcc_pure - const_pointer c_str() const { + const_pointer_type c_str() const { return value.c_str(); } @@ -223,7 +223,7 @@ public: * null-terminated. */ gcc_pure - const_pointer data() const { + const_pointer_type data() const { return value.data(); } @@ -249,7 +249,7 @@ public: * nullptr on mismatch. */ 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()); } diff --git a/src/fs/Charset.cxx b/src/fs/Charset.cxx index ea98d6a9d..f4e9d65d3 100644 --- a/src/fs/Charset.cxx +++ b/src/fs/Charset.cxx @@ -94,7 +94,7 @@ FixSeparators(PathTraitsUTF8::string &&s) } PathTraitsUTF8::string -PathToUTF8(PathTraitsFS::const_pointer path_fs) +PathToUTF8(PathTraitsFS::const_pointer_type path_fs) { #if !CLANG_CHECK_VERSION(3,6) /* disabled on clang due to -Wtautological-pointer-compare */ @@ -126,7 +126,7 @@ PathToUTF8(PathTraitsFS::const_pointer path_fs) #if defined(HAVE_FS_CHARSET) || defined(WIN32) PathTraitsFS::string -PathFromUTF8(PathTraitsUTF8::const_pointer path_utf8) +PathFromUTF8(PathTraitsUTF8::const_pointer_type path_utf8) { #if !CLANG_CHECK_VERSION(3,6) /* disabled on clang due to -Wtautological-pointer-compare */ diff --git a/src/fs/Charset.hxx b/src/fs/Charset.hxx index 6ec800dc3..721a41cd4 100644 --- a/src/fs/Charset.hxx +++ b/src/fs/Charset.hxx @@ -49,7 +49,7 @@ DeinitFSCharset(); */ gcc_pure gcc_nonnull_all PathTraitsUTF8::string -PathToUTF8(PathTraitsFS::const_pointer path_fs); +PathToUTF8(PathTraitsFS::const_pointer_type path_fs); /** * Convert the path from UTF-8. @@ -57,6 +57,6 @@ PathToUTF8(PathTraitsFS::const_pointer path_fs); */ gcc_pure gcc_nonnull_all PathTraitsFS::string -PathFromUTF8(PathTraitsUTF8::const_pointer path_utf8); +PathFromUTF8(PathTraitsUTF8::const_pointer_type path_utf8); #endif diff --git a/src/fs/DirectoryReader.hxx b/src/fs/DirectoryReader.hxx index b8b6e1db5..a07595cb1 100644 --- a/src/fs/DirectoryReader.hxx +++ b/src/fs/DirectoryReader.hxx @@ -37,10 +37,10 @@ class DirectoryReader { bool first = true; class MakeWildcardPath { - PathTraitsFS::pointer path; + PathTraitsFS::pointer_type path; public: - MakeWildcardPath(PathTraitsFS::const_pointer _path) { + MakeWildcardPath(PathTraitsFS::const_pointer_type _path) { auto l = _tcslen(_path); path = new PathTraitsFS::value_type[l + 3]; _tcscpy(path, _path); @@ -53,7 +53,7 @@ class DirectoryReader { delete[] path; } - operator PathTraitsFS::const_pointer() const { + operator PathTraitsFS::const_pointer_type() const { return path; } }; diff --git a/src/fs/FileSystem.hxx b/src/fs/FileSystem.hxx index 650bae281..d76c159fb 100644 --- a/src/fs/FileSystem.hxx +++ b/src/fs/FileSystem.hxx @@ -41,19 +41,19 @@ namespace FOpenMode { /** * 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. */ - constexpr PathTraitsFS::const_pointer AppendText = PATH_LITERAL("a"); + constexpr PathTraitsFS::const_pointer_type AppendText = PATH_LITERAL("a"); } /** * Wrapper for fopen() that uses #Path names. */ static inline FILE * -FOpen(Path file, PathTraitsFS::const_pointer mode) +FOpen(Path file, PathTraitsFS::const_pointer_type mode) { #ifdef WIN32 return _tfopen(file.c_str(), mode); diff --git a/src/fs/NarrowPath.hxx b/src/fs/NarrowPath.hxx index 53a945c7a..800e00324 100644 --- a/src/fs/NarrowPath.hxx +++ b/src/fs/NarrowPath.hxx @@ -43,7 +43,7 @@ class NarrowPath { #else typedef StringPointer<> Value; #endif - typedef typename Value::const_pointer const_pointer; + typedef typename Value::const_pointer_type const_pointer_type; Value value; @@ -59,11 +59,11 @@ public: explicit NarrowPath(Path _path):value(_path.c_str()) {} #endif - operator const_pointer() const { + operator const_pointer_type() const { return c_str(); } - const_pointer c_str() const { + const_pointer_type c_str() const { return value.c_str(); } }; diff --git a/src/fs/Path.cxx b/src/fs/Path.cxx index 0a7fe3072..cb8acd3fe 100644 --- a/src/fs/Path.cxx +++ b/src/fs/Path.cxx @@ -27,7 +27,7 @@ Path::ToUTF8() const return ::PathToUTF8(c_str()); } -Path::const_pointer +Path::const_pointer_type Path::GetSuffix() const { const auto base = GetBase().c_str(); diff --git a/src/fs/Path.hxx b/src/fs/Path.hxx index 2694353ed..235cbedd4 100644 --- a/src/fs/Path.hxx +++ b/src/fs/Path.hxx @@ -39,7 +39,7 @@ class AllocatedPath; class Path : public PathTraitsFS::Pointer { typedef PathTraitsFS::Pointer Base; - constexpr Path(const_pointer _value):Base(_value) {} + constexpr Path(const_pointer_type _value):Base(_value) {} public: /** @@ -61,7 +61,7 @@ public: * Create a new instance pointing to the specified path * string. */ - static constexpr Path FromFS(const_pointer fs) { + static constexpr Path FromFS(const_pointer_type fs) { return Path(fs); } @@ -104,7 +104,7 @@ public: * instance ends. */ gcc_pure - const_pointer c_str() const { + const_pointer_type c_str() const { return Base::c_str(); } @@ -113,7 +113,7 @@ public: * null-terminated. */ gcc_pure - const_pointer data() const { + const_pointer_type data() const { return c_str(); } @@ -158,7 +158,7 @@ public: * nullptr on mismatch. */ 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()); } @@ -168,7 +168,7 @@ public: } gcc_pure - const_pointer GetSuffix() const; + const_pointer_type GetSuffix() const; }; #endif diff --git a/src/fs/StandardDirectory.cxx b/src/fs/StandardDirectory.cxx index 5d9fc37fb..66f4c74bf 100644 --- a/src/fs/StandardDirectory.cxx +++ b/src/fs/StandardDirectory.cxx @@ -91,18 +91,21 @@ public: }; #endif -static inline bool IsValidPathString(PathTraitsFS::const_pointer path) +static inline bool +IsValidPathString(PathTraitsFS::const_pointer_type path) { 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) && 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)) return AllocatedPath::FromFS(dir); diff --git a/src/fs/Traits.cxx b/src/fs/Traits.cxx index a3670acd6..7e6db184a 100644 --- a/src/fs/Traits.cxx +++ b/src/fs/Traits.cxx @@ -25,8 +25,8 @@ template typename Traits::string -BuildPathImpl(typename Traits::const_pointer a, size_t a_size, - typename Traits::const_pointer b, size_t b_size) +BuildPathImpl(typename Traits::const_pointer_type a, size_t a_size, + typename Traits::const_pointer_type b, size_t b_size) { assert(a != nullptr); assert(b != nullptr); @@ -50,15 +50,15 @@ BuildPathImpl(typename Traits::const_pointer a, size_t a_size, } template -typename Traits::const_pointer -GetBasePathImpl(typename Traits::const_pointer p) +typename Traits::const_pointer_type +GetBasePathImpl(typename Traits::const_pointer_type p) { #if !CLANG_CHECK_VERSION(3,6) /* disabled on clang due to -Wtautological-pointer-compare */ assert(p != nullptr); #endif - typename Traits::const_pointer sep = Traits::FindLastSeparator(p); + typename Traits::const_pointer_type sep = Traits::FindLastSeparator(p); return sep != nullptr ? sep + 1 : p; @@ -66,14 +66,14 @@ GetBasePathImpl(typename Traits::const_pointer p) template typename Traits::string -GetParentPathImpl(typename Traits::const_pointer p) +GetParentPathImpl(typename Traits::const_pointer_type p) { #if !CLANG_CHECK_VERSION(3,6) /* disabled on clang due to -Wtautological-pointer-compare */ assert(p != nullptr); #endif - typename Traits::const_pointer sep = Traits::FindLastSeparator(p); + typename Traits::const_pointer_type sep = Traits::FindLastSeparator(p); if (sep == nullptr) return typename Traits::string(Traits::CURRENT_DIRECTORY); if (sep == p) @@ -86,9 +86,9 @@ GetParentPathImpl(typename Traits::const_pointer p) } template -typename Traits::const_pointer -RelativePathImpl(typename Traits::const_pointer base, - typename Traits::const_pointer other) +typename Traits::const_pointer_type +RelativePathImpl(typename Traits::const_pointer_type base, + typename Traits::const_pointer_type other) { assert(base != nullptr); assert(other != nullptr); @@ -113,51 +113,51 @@ RelativePathImpl(typename Traits::const_pointer base, } PathTraitsFS::string -PathTraitsFS::Build(PathTraitsFS::const_pointer a, size_t a_size, - PathTraitsFS::const_pointer b, size_t b_size) +PathTraitsFS::Build(const_pointer_type a, size_t a_size, + const_pointer_type b, size_t b_size) { return BuildPathImpl(a, a_size, b, b_size); } -PathTraitsFS::const_pointer -PathTraitsFS::GetBase(PathTraitsFS::const_pointer p) +PathTraitsFS::const_pointer_type +PathTraitsFS::GetBase(PathTraitsFS::const_pointer_type p) { return GetBasePathImpl(p); } PathTraitsFS::string -PathTraitsFS::GetParent(PathTraitsFS::const_pointer p) +PathTraitsFS::GetParent(PathTraitsFS::const_pointer_type p) { return GetParentPathImpl(p); } -PathTraitsFS::const_pointer -PathTraitsFS::Relative(const_pointer base, const_pointer other) +PathTraitsFS::const_pointer_type +PathTraitsFS::Relative(const_pointer_type base, const_pointer_type other) { return RelativePathImpl(base, other); } PathTraitsUTF8::string -PathTraitsUTF8::Build(PathTraitsUTF8::const_pointer a, size_t a_size, - PathTraitsUTF8::const_pointer b, size_t b_size) +PathTraitsUTF8::Build(const_pointer_type a, size_t a_size, + const_pointer_type b, size_t b_size) { return BuildPathImpl(a, a_size, b, b_size); } -PathTraitsUTF8::const_pointer -PathTraitsUTF8::GetBase(PathTraitsUTF8::const_pointer p) +PathTraitsUTF8::const_pointer_type +PathTraitsUTF8::GetBase(const_pointer_type p) { return GetBasePathImpl(p); } PathTraitsUTF8::string -PathTraitsUTF8::GetParent(PathTraitsUTF8::const_pointer p) +PathTraitsUTF8::GetParent(const_pointer_type p) { return GetParentPathImpl(p); } -PathTraitsUTF8::const_pointer -PathTraitsUTF8::Relative(const_pointer base, const_pointer other) +PathTraitsUTF8::const_pointer_type +PathTraitsUTF8::Relative(const_pointer_type base, const_pointer_type other) { return RelativePathImpl(base, other); } diff --git a/src/fs/Traits.hxx b/src/fs/Traits.hxx index 4ba1a511f..ba49c5069 100644 --- a/src/fs/Traits.hxx +++ b/src/fs/Traits.hxx @@ -52,8 +52,8 @@ struct PathTraitsFS { typedef string::traits_type char_traits; typedef char_traits::char_type value_type; typedef StringPointer Pointer; - typedef Pointer::pointer pointer; - typedef Pointer::const_pointer const_pointer; + typedef Pointer::pointer_type pointer_type; + typedef Pointer::const_pointer_type const_pointer_type; #ifdef WIN32 static constexpr value_type SEPARATOR = '\\'; @@ -61,7 +61,7 @@ struct PathTraitsFS { static constexpr value_type SEPARATOR = '/'; #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) { return @@ -72,14 +72,14 @@ struct PathTraitsFS { } 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) /* disabled on clang due to -Wtautological-pointer-compare */ assert(p != nullptr); #endif #ifdef WIN32 - const_pointer pos = p + GetLength(p); + const_pointer_type pos = p + GetLength(p); while (p != pos && !IsSeparator(*pos)) --pos; return IsSeparator(*pos) ? pos : nullptr; @@ -90,13 +90,13 @@ struct PathTraitsFS { #ifdef WIN32 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] == ':'; } #endif gcc_pure gcc_nonnull_all - static bool IsAbsolute(const_pointer p) { + static bool IsAbsolute(const_pointer_type p) { #if !CLANG_CHECK_VERSION(3,6) /* disabled on clang due to -Wtautological-pointer-compare */ assert(p != nullptr); @@ -110,12 +110,12 @@ struct PathTraitsFS { } gcc_pure gcc_nonnull_all - static size_t GetLength(const_pointer p) { + static size_t GetLength(const_pointer_type p) { return StringLength(p); } 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); } @@ -124,7 +124,7 @@ struct PathTraitsFS { * The return value points inside the given string. */ 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. @@ -132,7 +132,7 @@ struct PathTraitsFS { * separator in the given input string. */ 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 @@ -141,7 +141,8 @@ struct PathTraitsFS { * nullptr on mismatch. */ 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. @@ -150,11 +151,11 @@ struct PathTraitsFS { * If both components are empty strings, empty string is returned. */ gcc_pure gcc_nonnull_all - static string Build(const_pointer a, size_t a_size, - const_pointer b, size_t b_size); + static string Build(const_pointer_type a, size_t a_size, + const_pointer_type b, size_t b_size); 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)); } }; @@ -166,19 +167,19 @@ struct PathTraitsUTF8 { typedef std::string string; typedef string::traits_type char_traits; typedef char_traits::char_type value_type; - typedef value_type *pointer; - typedef const value_type *const_pointer; + typedef value_type *pointer_type; + typedef const value_type *const_pointer_type; 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) { return ch == SEPARATOR; } 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) /* disabled on clang due to -Wtautological-pointer-compare */ assert(p != nullptr); @@ -189,13 +190,13 @@ struct PathTraitsUTF8 { #ifdef WIN32 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] == ':'; } #endif gcc_pure gcc_nonnull_all - static bool IsAbsolute(const_pointer p) { + static bool IsAbsolute(const_pointer_type p) { #if !CLANG_CHECK_VERSION(3,6) /* disabled on clang due to -Wtautological-pointer-compare */ assert(p != nullptr); @@ -209,12 +210,12 @@ struct PathTraitsUTF8 { } gcc_pure gcc_nonnull_all - static size_t GetLength(const_pointer p) { + static size_t GetLength(const_pointer_type p) { return StringLength(p); } 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); } @@ -223,7 +224,7 @@ struct PathTraitsUTF8 { * The return value points inside the given string. */ 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. @@ -231,7 +232,7 @@ struct PathTraitsUTF8 { * separator in the given input string. */ 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 @@ -240,7 +241,8 @@ struct PathTraitsUTF8 { * nullptr on mismatch. */ 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. @@ -249,11 +251,11 @@ struct PathTraitsUTF8 { * If both components are empty strings, empty string is returned. */ gcc_pure gcc_nonnull_all - static string Build(const_pointer a, size_t a_size, - const_pointer b, size_t b_size); + static string Build(const_pointer_type a, size_t a_size, + const_pointer_type b, size_t b_size); 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)); } }; -- cgit v1.2.3