27 template <
class Byte,
class = std::enable_if_t<sizeof(Byte) == 1 && std::is_const_v<T>>>
29 : data_(
reinterpret_cast<T*
>(
data)), size_(
size) {}
32 template <
class Byte,
class = std::enable_if_t<sizeof(Byte) == 1 && !std::is_const_v<T>>>
34 : data_(
reinterpret_cast<T*
>(
data)), size_(
size) {}
36 constexpr T*
data() const noexcept {
return data_; }
37 constexpr std::size_t
size() const noexcept {
return size_; }
38 constexpr bool empty() const noexcept {
return size_ == 0; }
39 constexpr T&
operator[](std::size_t i)
const noexcept {
return data_[i]; }
40 constexpr T*
begin() const noexcept {
return data_; }
41 constexpr T*
end() const noexcept {
return data_ + size_; }
43 BasicByteSpan subspan(std::size_t offset, std::size_t count =
static_cast<std::size_t
>(-1)) const noexcept {
44 std::size_t n = (count ==
static_cast<std::size_t
>(-1)) ? (size_ - offset) : count;
50 std::size_t size_ = 0;
62 return {
reinterpret_cast<const char*
>(
data()),
size()};
82 const std::string&
str() const noexcept {
return path_; }
83 bool empty() const noexcept {
return path_.empty(); }
86 std::string result = path_;
87 if (!result.empty() && result.back() !=
'/' && !child.empty() && child.front() !=
'/') {
88 result.push_back(
'/');
95 return a.path_ == b.path_;
107struct ZeroingAllocator {
108 using value_type = T;
110 ZeroingAllocator() noexcept = default;
111 template <class U> ZeroingAllocator(const ZeroingAllocator<U>&) noexcept {}
113 T* allocate(std::size_t n) {
114 return static_cast<T*
>(::operator
new(n *
sizeof(T)));
116 void deallocate(T* p, std::size_t n)
noexcept {
117 if (p !=
nullptr && n != 0) {
118 volatile auto* vp =
reinterpret_cast<volatile unsigned char*
>(p);
119 for (std::size_t i = 0; i < n *
sizeof(T); ++i) vp[i] = 0;
121 ::operator
delete(p);
124 template <
class U>
bool operator==(
const ZeroingAllocator<U>&)
const noexcept {
return true; }
125 template <
class U>
bool operator!=(
const ZeroingAllocator<U>&)
const noexcept {
return false; }
134 using storage_type = std::basic_string<char, std::char_traits<char>, detail::ZeroingAllocator<char>>;
141 volatile auto* vp =
reinterpret_cast<volatile char*
>(s.data());
142 for (std::size_t i = 0; i < s.size(); ++i) vp[i] = 0;
145 const char*
c_str() const noexcept {
return data_.c_str(); }
146 std::size_t
size() const noexcept {
return data_.size(); }
147 bool empty() const noexcept {
return data_.empty(); }
148 std::string_view
view() const noexcept {
return {data_.data(), data_.size()}; }
A minimal span-like non-owning view over contiguous bytes (C++17 has no std::span).
Definition types.hpp:20
T element_type
Definition types.hpp:22
constexpr T * begin() const noexcept
Definition types.hpp:40
BasicByteSpan(const Byte *data, std::size_t size) noexcept
Definition types.hpp:28
constexpr bool empty() const noexcept
Definition types.hpp:38
BasicByteSpan subspan(std::size_t offset, std::size_t count=static_cast< std::size_t >(-1)) const noexcept
Definition types.hpp:43
constexpr BasicByteSpan() noexcept=default
constexpr T * end() const noexcept
Definition types.hpp:41
constexpr std::size_t size() const noexcept
Definition types.hpp:37
BasicByteSpan(Byte *data, std::size_t size) noexcept
Definition types.hpp:33
constexpr T & operator[](std::size_t i) const noexcept
Definition types.hpp:39
constexpr T * data() const noexcept
Definition types.hpp:36
Input byte range. Implicitly constructible from std::string_view / std::vector<std::byte>.
Definition types.hpp:54
ByteView(const std::vector< std::byte > &v) noexcept
Definition types.hpp:59
std::string_view as_string_view() const noexcept
Definition types.hpp:61
constexpr BasicByteSpan() noexcept=default
constexpr ByteView() noexcept=default
Output byte range (caller-owned, mutable buffer to write into).
Definition types.hpp:67
constexpr MutableByteView() noexcept=default
friend bool operator!=(const RemotePath &a, const RemotePath &b) noexcept
Definition types.hpp:97
RemotePath(std::string p)
Definition types.hpp:79
RemotePath operator/(std::string_view child) const
Definition types.hpp:85
bool empty() const noexcept
Definition types.hpp:83
const std::string & str() const noexcept
Definition types.hpp:82
RemotePath(const char *p)
Definition types.hpp:80
friend bool operator==(const RemotePath &a, const RemotePath &b) noexcept
Definition types.hpp:94
SecureString(const char *s)
Definition types.hpp:137
SecureString(std::string_view sv)
Definition types.hpp:138
SecureString(std::string s)
Definition types.hpp:139
std::string_view view() const noexcept
Definition types.hpp:148
std::basic_string< char, std::char_traits< char >, detail::ZeroingAllocator< char > > storage_type
Definition types.hpp:134
std::size_t size() const noexcept
Definition types.hpp:146
bool empty() const noexcept
Definition types.hpp:147
const char * c_str() const noexcept
Definition types.hpp:145
Ownership
Definition types.hpp:16