util/StringPointer: rename typedef pointer to pointer_type
This commit is contained in:
parent
fd5d42836f
commit
9b85446808
|
@ -280,7 +280,7 @@ class ConfigLoader
|
|||
public:
|
||||
bool TryFile(const Path path);
|
||||
bool TryFile(const AllocatedPath &base_path,
|
||||
PathTraitsFS::const_pointer path);
|
||||
PathTraitsFS::const_pointer_type path);
|
||||
};
|
||||
|
||||
bool ConfigLoader::TryFile(Path path)
|
||||
|
@ -293,7 +293,7 @@ bool ConfigLoader::TryFile(Path path)
|
|||
}
|
||||
|
||||
bool ConfigLoader::TryFile(const AllocatedPath &base_path,
|
||||
PathTraitsFS::const_pointer path)
|
||||
PathTraitsFS::const_pointer_type path)
|
||||
{
|
||||
if (base_path.IsNull())
|
||||
return false;
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
gcc_pure
|
||||
static bool
|
||||
SkipNameFS(PathTraitsFS::const_pointer name_fs)
|
||||
SkipNameFS(PathTraitsFS::const_pointer_type name_fs)
|
||||
{
|
||||
return name_fs[0] == '.' &&
|
||||
(name_fs[1] == 0 ||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
|
||||
template<typename Traits>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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<PathTraitsFS>(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<PathTraitsFS>(p);
|
||||
}
|
||||
|
||||
PathTraitsFS::string
|
||||
PathTraitsFS::GetParent(PathTraitsFS::const_pointer p)
|
||||
PathTraitsFS::GetParent(PathTraitsFS::const_pointer_type p)
|
||||
{
|
||||
return GetParentPathImpl<PathTraitsFS>(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<PathTraitsFS>(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<PathTraitsUTF8>(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<PathTraitsUTF8>(p);
|
||||
}
|
||||
|
||||
PathTraitsUTF8::string
|
||||
PathTraitsUTF8::GetParent(PathTraitsUTF8::const_pointer p)
|
||||
PathTraitsUTF8::GetParent(const_pointer_type p)
|
||||
{
|
||||
return GetParentPathImpl<PathTraitsUTF8>(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<PathTraitsUTF8>(base, other);
|
||||
}
|
||||
|
|
|
@ -52,8 +52,8 @@ struct PathTraitsFS {
|
|||
typedef string::traits_type char_traits;
|
||||
typedef char_traits::char_type value_type;
|
||||
typedef StringPointer<value_type> 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));
|
||||
}
|
||||
};
|
||||
|
|
|
@ -161,7 +161,7 @@ LocalStorage::OpenDirectory(const char *uri_utf8, Error &error)
|
|||
|
||||
gcc_pure
|
||||
static bool
|
||||
SkipNameFS(PathTraitsFS::const_pointer name_fs)
|
||||
SkipNameFS(PathTraitsFS::const_pointer_type name_fs)
|
||||
{
|
||||
return name_fs[0] == '.' &&
|
||||
(name_fs[1] == 0 ||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
template<>
|
||||
AllocatedString<char>
|
||||
AllocatedString<char>::Duplicate(const_pointer src)
|
||||
AllocatedString<char>::Duplicate(const_pointer_type src)
|
||||
{
|
||||
return Duplicate(src, StringLength(src));
|
||||
}
|
||||
|
|
|
@ -44,15 +44,15 @@ template<typename T=char>
|
|||
class AllocatedString {
|
||||
public:
|
||||
typedef typename StringPointer<T>::value_type value_type;
|
||||
typedef typename StringPointer<T>::pointer pointer;
|
||||
typedef typename StringPointer<T>::const_pointer const_pointer;
|
||||
typedef typename StringPointer<T>::pointer_type pointer_type;
|
||||
typedef typename StringPointer<T>::const_pointer_type const_pointer_type;
|
||||
|
||||
static constexpr value_type SENTINEL = '\0';
|
||||
|
||||
private:
|
||||
pointer value;
|
||||
pointer_type value;
|
||||
|
||||
explicit AllocatedString(pointer _value)
|
||||
explicit AllocatedString(pointer_type _value)
|
||||
:value(_value) {}
|
||||
|
||||
public:
|
||||
|
@ -65,7 +65,7 @@ public:
|
|||
delete[] value;
|
||||
}
|
||||
|
||||
static AllocatedString Donate(pointer value) {
|
||||
static AllocatedString Donate(pointer_type value) {
|
||||
return AllocatedString(value);
|
||||
}
|
||||
|
||||
|
@ -79,16 +79,16 @@ public:
|
|||
return Donate(p);
|
||||
}
|
||||
|
||||
static AllocatedString Duplicate(const_pointer src);
|
||||
static AllocatedString Duplicate(const_pointer_type src);
|
||||
|
||||
static AllocatedString Duplicate(const_pointer begin,
|
||||
const_pointer end) {
|
||||
static AllocatedString Duplicate(const_pointer_type begin,
|
||||
const_pointer_type end) {
|
||||
auto p = new value_type[end - begin + 1];
|
||||
*std::copy(begin, end, p) = SENTINEL;
|
||||
return Donate(p);
|
||||
}
|
||||
|
||||
static AllocatedString Duplicate(const_pointer begin,
|
||||
static AllocatedString Duplicate(const_pointer_type begin,
|
||||
size_t length) {
|
||||
auto p = new value_type[length + 1];
|
||||
*std::copy_n(begin, length, p) = SENTINEL;
|
||||
|
@ -104,7 +104,7 @@ public:
|
|||
return value == nullptr;
|
||||
}
|
||||
|
||||
constexpr const_pointer c_str() const {
|
||||
constexpr const_pointer_type c_str() const {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -112,8 +112,8 @@ public:
|
|||
return *value == SENTINEL;
|
||||
}
|
||||
|
||||
pointer Steal() {
|
||||
pointer result = value;
|
||||
pointer_type Steal() {
|
||||
pointer_type result = value;
|
||||
value = nullptr;
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -37,17 +37,17 @@ template<typename T=char>
|
|||
class StringPointer {
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef T *pointer;
|
||||
typedef const T *const_pointer;
|
||||
typedef T *pointer_type;
|
||||
typedef const T *const_pointer_type;
|
||||
|
||||
static constexpr value_type SENTINEL = '\0';
|
||||
|
||||
private:
|
||||
const_pointer value;
|
||||
const_pointer_type value;
|
||||
|
||||
public:
|
||||
StringPointer() = default;
|
||||
constexpr StringPointer(const_pointer _value)
|
||||
constexpr StringPointer(const_pointer_type _value)
|
||||
:value(_value) {}
|
||||
|
||||
/**
|
||||
|
@ -58,7 +58,7 @@ public:
|
|||
return value == nullptr;
|
||||
}
|
||||
|
||||
constexpr const_pointer c_str() const {
|
||||
constexpr const_pointer_type c_str() const {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue