uri: add minimal copy and move operators

This commit is contained in:
Danny Robson 2021-12-14 11:31:20 +10:00
parent 5685f1ebb1
commit a1460a240f
2 changed files with 26 additions and 0 deletions

20
uri.cpp
View File

@ -23,6 +23,26 @@ uri::uri (const std::string &_value):
{ ; }
//-----------------------------------------------------------------------------
uri::uri (uri const &rhs)
: m_views (rhs.m_views)
, m_value (rhs.m_value)
{
auto const offset = rhs.m_value.data () - m_value.data ();
for (auto &i: m_views)
i = { i.begin () - offset, i.end () - offset };
}
//-----------------------------------------------------------------------------
uri& uri::operator= (uri &&rhs) noexcept
{
m_views = std::move (rhs.m_views);
m_value = std::move (rhs.m_value);
return *this;
}
///////////////////////////////////////////////////////////////////////////////
static uint8_t
hex_to_uint (char c)

View File

@ -33,10 +33,16 @@ namespace cruft {
class uri {
public:
uri (std::string &&);
uri& operator= (uri &&) noexcept;
uri (uri const&);
uri& operator= (uri const&);
uri (const std::string&);
uri (const char *);
uri (view<const char *>);
class parse_error : public std::runtime_error
{ using runtime_error::runtime_error; };