diff --git a/uri.cpp.rl b/uri.cpp.rl index ad188a3c..8ea4c7ff 100644 --- a/uri.cpp.rl +++ b/uri.cpp.rl @@ -132,15 +132,6 @@ util::uri::uri (std::string &&_value): } -//----------------------------------------------------------------------------- -util::view -util::uri::get (util::uri::component c) const -{ - CHECK_NEQ (c, NUM_COMPONENTS); - return m_views[c]; -} - - //----------------------------------------------------------------------------- static uint8_t hex_to_uint (char c) diff --git a/uri.hpp b/uri.hpp index dc12910e..cb3af52c 100644 --- a/uri.hpp +++ b/uri.hpp @@ -74,21 +74,26 @@ namespace util { NUM_COMPONENTS }; - view get (component) const; + view + get (component c) const& + { + CHECK_LIMIT (c, 0, NUM_COMPONENTS); + return m_views[c]; + } - auto all (void) const { return util::make_view (m_value); } + util::view all (void) const& { return util::make_view (m_value); } - auto scheme (void) const { return get (SCHEME); } - auto heirarchical (void) const { return get (HIERARCHICAL); } - auto authority (void) const { return get (AUTHORITY); } - auto user (void) const { return get (USER); } - auto host (void) const { return get (HOST); } - auto port (void) const { return get (PORT); } - auto path (void) const { return get (PATH); } - auto query (void) const { return get (QUERY); } - auto fragment (void) const { return get (FRAGMENT); } + util::view scheme (void) const& { return get (SCHEME); } + util::view heirarchical (void) const& { return get (HIERARCHICAL); } + util::view authority (void) const& { return get (AUTHORITY); } + util::view user (void) const& { return get (USER); } + util::view host (void) const& { return get (HOST); } + util::view port (void) const& { return get (PORT); } + util::view path (void) const& { return get (PATH); } + util::view query (void) const& { return get (QUERY); } + util::view fragment (void) const& { return get (FRAGMENT); } - auto components (void) const noexcept { return m_views; } + auto components (void) const& noexcept { return m_views; } static std::string percent_decode (view);