7 #ifndef PODOFO_BASE_TYPES_H
8 #define PODOFO_BASE_TYPES_H
36 template <
typename =
void>
45 std::string::resize(size);
48 : std::string(std::move(str)) { }
50 : std::string(str, size) { }
52 : std::string(view.data(), view.size()) { }
53 explicit charbuff_t(
const std::string_view& view)
54 : std::string(view) { }
56 : std::string(str) { }
60 charbuff_t& operator=(
const std::string_view & view)
62 std::string::assign(view.data(), view.size());
67 std::string::assign(str.data(), str.size());
72 std::string::assign(view.data(), view.size());
75 charbuff_t& operator=(std::string&& str) noexcept
77 std::string::operator=(std::move(str));
82 return static_cast<const std::string&
>(*this) ==
static_cast<const std::string&
>(rhs);
85 size_t length()
const =
delete;
88 template <
typename =
void>
89 bool operator==(
const charbuff_t<>& lhs,
const char* rhs)
91 return static_cast<const std::string&
>(lhs) == rhs;
94 template <
typename =
void>
95 bool operator==(
const char* lhs,
const charbuff_t<>& rhs)
97 return lhs ==
static_cast<const std::string&
>(rhs);
100 template <
typename =
void>
101 bool operator==(
const charbuff_t<>& lhs,
const bufferview& rhs)
103 return static_cast<const std::string&
>(lhs) == std::string_view(rhs.data(), rhs.size());
106 template <
typename =
void>
107 bool operator==(
const bufferview& lhs,
const charbuff_t<>& rhs)
109 return std::string_view(lhs.data(), lhs.size()) ==
static_cast<const std::string&
>(rhs);
112 template <
typename =
void>
113 bool operator==(
const charbuff_t<>& lhs,
const std::string_view& rhs) noexcept
115 return std::string_view(lhs) == rhs;
118 template <
typename =
void>
119 bool operator==(
const std::string_view& lhs,
const charbuff_t<>& rhs) noexcept
121 return lhs == std::string_view(rhs);
124 template <
typename =
void>
125 bool operator==(
const charbuff_t<>& lhs,
const std::string& rhs) noexcept
127 return static_cast<const std::string&
>(lhs) == rhs;
130 template <
typename =
void>
131 bool operator==(
const std::string& lhs,
const charbuff_t<>& rhs) noexcept
133 return lhs ==
static_cast<const std::string&
>(rhs);
136 using charbuff = charbuff_t<>;
142 template <
typename =
void>
150 : m_buff(
new charbuff_t<>(std::move(buff))), m_view(*m_buff) { }
152 : m_buff(std::move(buff)), m_view(*m_buff) { }
154 : m_buff(std::move(buff)), m_view(*m_buff) { }
156 : m_buff(buff), m_view(*m_buff) { }
158 : m_buff(buff), m_view(*m_buff) { }
160 const bufferview& view()
const {
return m_view; }
162 std::shared_ptr<const charbuff_t<>> m_buff;
169 template <
class... T>
170 constexpr
bool always_false =
false;
Convenient type for char array storage and/or buffer with std::string compatibility.
Definition: basetypes.h:38
A const data provider that can hold a view to a static segments or a shared buffer.
Definition: basetypes.h:144
SPDX-FileCopyrightText: (C) 2022 Francesco Pretto ceztko@gmail.com SPDX-License-Identifier: LGPL-2....
Definition: basetypes.h:16
cspan< char32_t > unicodeview
Unicode code point view.
Definition: basetypes.h:27
tcb::span< const T, Extent > cspan
Constant span.
Definition: span.h:13
mspan< char > bufferspan
Convenient writable char buffer span.
Definition: basetypes.h:23
tcb::span< T, Extent > mspan
Mutable span.
Definition: span.h:18
cspan< char > bufferview
Convenient read-only char buffer span.
Definition: basetypes.h:19