uri: move component queries entirely into header

This commit is contained in:
Danny Robson 2017-12-26 17:33:24 +11:00
parent d86c8b5b2b
commit d8f3469987
2 changed files with 17 additions and 21 deletions

View File

@ -132,15 +132,6 @@ util::uri::uri (std::string &&_value):
}
//-----------------------------------------------------------------------------
util::view<const char*>
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)

29
uri.hpp
View File

@ -74,21 +74,26 @@ namespace util {
NUM_COMPONENTS
};
view<const char*> get (component) const;
view<const char*>
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<const char*> 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<const char*> scheme (void) const& { return get (SCHEME); }
util::view<const char*> heirarchical (void) const& { return get (HIERARCHICAL); }
util::view<const char*> authority (void) const& { return get (AUTHORITY); }
util::view<const char*> user (void) const& { return get (USER); }
util::view<const char*> host (void) const& { return get (HOST); }
util::view<const char*> port (void) const& { return get (PORT); }
util::view<const char*> path (void) const& { return get (PATH); }
util::view<const char*> query (void) const& { return get (QUERY); }
util::view<const char*> 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<const char*>);