diff options
author | VladiMihaylenko <vxmihaylenko@gmail.com> | 2016-07-27 12:02:55 +0300 |
---|---|---|
committer | VladiMihaylenko <vxmihaylenko@gmail.com> | 2016-08-08 11:39:34 +0300 |
commit | 96eadf606e3426aa857630e1806c444a8e1a7bc5 (patch) | |
tree | b1f8cdfb61664b2c063ea2af952d1863960ec6ae /coding | |
parent | d6877910b56295f4792a3884ee2ceb1eefea26af (diff) |
[api] Routing api.
Diffstat (limited to 'coding')
-rw-r--r-- | coding/uri.cpp | 6 | ||||
-rw-r--r-- | coding/uri.hpp | 5 |
2 files changed, 6 insertions, 5 deletions
diff --git a/coding/uri.cpp b/coding/uri.cpp index 57242042ac..f3b9d9f577 100644 --- a/coding/uri.cpp +++ b/coding/uri.cpp @@ -47,7 +47,7 @@ bool Uri::Parse() return true; } -void Uri::ForEachKeyValue(CallbackT const & callback) const +bool Uri::ForEachKeyValue(CallbackT const & callback) const { // parse query for keys and values size_t const count = m_url.size(); @@ -71,11 +71,13 @@ void Uri::ForEachKeyValue(CallbackT const & callback) const else key = UrlDecode(m_url.substr(start, end - start)); - callback(key, value); + if (!callback(key, value)) + return false; } start = end + 1; } + return true; } } diff --git a/coding/uri.hpp b/coding/uri.hpp index e1ee611000..f0ea0a7824 100644 --- a/coding/uri.hpp +++ b/coding/uri.hpp @@ -13,7 +13,7 @@ namespace url_scheme class Uri { public: - typedef function<void (string const &, string const &)> CallbackT; + typedef function<bool(string const &, string const &)> CallbackT; explicit Uri(string const & uri) : m_url(uri) { Init(); } Uri(char const * uri, size_t size) : m_url(uri, uri + size) { Init(); } @@ -21,8 +21,7 @@ public: string const & GetScheme() const { return m_scheme; } string const & GetPath() const { return m_path; } bool IsValid() const { return !m_scheme.empty(); } - - void ForEachKeyValue(CallbackT const & callback) const; + bool ForEachKeyValue(CallbackT const & callback) const; private: void Init(); |