diff options
| author | martin-s <webmaster@macside.net> | 2017-10-15 02:00:19 +0200 |
|---|---|---|
| committer | martin-s <webmaster@macside.net> | 2017-10-15 02:00:19 +0200 |
| commit | 9c2fa042ee451f5ec1e5781c8daccd9fd6875de0 (patch) | |
| tree | 250b18fea62d58e2138de12f78e25d0ed8c69678 /toolsrc/include/CStringView.h | |
| parent | 630bcd84b8325217c440def11681e375f5ef4652 (diff) | |
| parent | 561cfe89e653aef903488f7af7d4d17cfb11a26c (diff) | |
| download | vcpkg-9c2fa042ee451f5ec1e5781c8daccd9fd6875de0.tar.gz vcpkg-9c2fa042ee451f5ec1e5781c8daccd9fd6875de0.zip | |
Merge branch 'master' of https://github.com/Microsoft/vcpkg into patch-vs2013
# Conflicts:
# toolsrc/include/vcpkg/vcpkgpaths.h
# toolsrc/src/vcpkg/vcpkgpaths.cpp
Diffstat (limited to 'toolsrc/include/CStringView.h')
| -rw-r--r-- | toolsrc/include/CStringView.h | 96 |
1 files changed, 0 insertions, 96 deletions
diff --git a/toolsrc/include/CStringView.h b/toolsrc/include/CStringView.h deleted file mode 100644 index c1810b4f1..000000000 --- a/toolsrc/include/CStringView.h +++ /dev/null @@ -1,96 +0,0 @@ -#pragma once -#include <string> - -namespace vcpkg -{ - template<class CharType> - struct BasicCStringView - { - constexpr BasicCStringView() : cstr(nullptr) {} - constexpr BasicCStringView(const CharType* cstr) : cstr(cstr) {} - constexpr BasicCStringView(const BasicCStringView&) = default; - BasicCStringView(const std::basic_string<CharType>& str) : cstr(str.c_str()) {} - - constexpr const CharType* c_str() const { return cstr; } - - private: - const CharType* cstr; - }; - - namespace details - { - inline bool vcpkg_strcmp(const char* l, const char* r) { return strcmp(l, r) == 0; } - inline bool vcpkg_strcmp(const wchar_t* l, const wchar_t* r) { return wcscmp(l, r) == 0; } - } - - template<class CharType> - bool operator==(const BasicCStringView<CharType>& l, const BasicCStringView<CharType>& r) - { - return details::vcpkg_strcmp(l.c_str(), r.c_str()); - } - - template<class CharType> - bool operator==(const CharType* l, const BasicCStringView<CharType>& r) - { - return details::vcpkg_strcmp(l, r.c_str()); - } - - template<class CharType> - bool operator==(const BasicCStringView<CharType>& r, const CharType* l) - { - return details::vcpkg_strcmp(l, r.c_str()); - } - - template<class CharType> - bool operator==(const std::basic_string<CharType>& l, const BasicCStringView<CharType>& r) - { - return l == r.c_str(); - } - - template<class CharType> - bool operator==(const BasicCStringView<CharType>& r, const std::basic_string<CharType>& l) - { - return l == r.c_str(); - } - - // notequals - template<class CharType> - bool operator!=(const BasicCStringView<CharType>& l, const BasicCStringView<CharType>& r) - { - return !details::vcpkg_strcmp(l.c_str(), r.c_str()); - } - - template<class CharType> - bool operator!=(const CharType* l, const BasicCStringView<CharType>& r) - { - return !details::vcpkg_strcmp(l, r.c_str()); - } - - template<class CharType> - bool operator!=(const BasicCStringView<CharType>& r, const CharType* l) - { - return !details::vcpkg_strcmp(l, r.c_str()); - } - - template<class CharType> - bool operator!=(const BasicCStringView<CharType>& r, const std::basic_string<CharType>& l) - { - return l != r.c_str(); - } - - template<class CharType> - bool operator!=(const std::basic_string<CharType>& l, const BasicCStringView<CharType>& r) - { - return l != r.c_str(); - } - - using CStringView = BasicCStringView<char>; - using CWStringView = BasicCStringView<wchar_t>; - - inline const char* to_printf_arg(const CStringView string_view) { return string_view.c_str(); } - - inline const wchar_t* to_wprintf_arg(const CWStringView string_view) { return string_view.c_str(); } - - static_assert(sizeof(CStringView) == sizeof(void*), "CStringView must be a simple wrapper around char*"); - static_assert(sizeof(CWStringView) == sizeof(void*), "CWStringView must be a simple wrapper around wchar_t*"); -} |
