From 32d66d6fd1ac7f90512a573991de4940b5063374 Mon Sep 17 00:00:00 2001 From: Vsevolod Kvachev Date: Tue, 6 Dec 2016 18:22:10 +0300 Subject: Upgrade amalgamate --- include/crow/routing.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/crow/routing.h b/include/crow/routing.h index a8aa233..fe65ac4 100644 --- a/include/crow/routing.h +++ b/include/crow/routing.h @@ -156,7 +156,7 @@ namespace crow struct Wrapped { template - void set(Func f, typename std::enable_if< + void set_(Func f, typename std::enable_if< !std::is_same>::type, const request&>::value , int>::type = 0) { @@ -190,7 +190,7 @@ namespace crow }; template - void set(Func f, typename std::enable_if< + void set_(Func f, typename std::enable_if< std::is_same>::type, const request&>::value && !std::is_same>::type, response&>::value , int>::type = 0) @@ -205,7 +205,7 @@ namespace crow } template - void set(Func f, typename std::enable_if< + void set_(Func f, typename std::enable_if< std::is_same>::type, const request&>::value && std::is_same>::type, response&>::value , int>::type = 0) @@ -410,7 +410,7 @@ namespace crow throw std::runtime_error("route_dynamic: Handler type is mismatched with URL parameters: " + rule_); } auto ret = detail::routing_handler_call_helper::Wrapped...>(); - ret.template set< + ret.template set_< typename function_t::template arg... >(std::move(f)); return ret; -- cgit v1.2.3-54-g00ecf From 01b21296bcd855cc851417ab704081c49c1b7c90 Mon Sep 17 00:00:00 2001 From: Rasie1 Date: Thu, 16 Mar 2017 19:25:27 +0300 Subject: Add get_dict method --- include/crow/query_string.h | 60 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'include') diff --git a/include/crow/query_string.h b/include/crow/query_string.h index 3f8bffe..2740441 100644 --- a/include/crow/query_string.h +++ b/include/crow/query_string.h @@ -5,6 +5,7 @@ #include #include #include +#include namespace crow { @@ -197,6 +198,50 @@ inline char * qs_k2v(const char * key, char * const * qs_kv, int qs_kv_size, int return NULL; } +inline boost::optional> qs_dict_name2kv(const char * dict_name, char * const * qs_kv, int qs_kv_size, int nth = 0) +{ + int i; + size_t name_len, skip_to_eq, skip_to_brace_open, skip_to_brace_close; + + name_len = strlen(dict_name); + +#ifdef _qsSORTING +// TODO: binary search for key in the sorted qs_kv +#else // _qsSORTING + for(i=0; i 0 && + skip_to_brace_close > 0 && + nth == 0 ) + { + auto key = std::string(qs_kv[i] + skip_to_brace_open, skip_to_brace_close - skip_to_brace_open); + auto value = std::string(qs_kv[i] + skip_to_eq); + return boost::make_optional(std::make_pair(key, value)); + } + else + { + --nth; + } + } + } +#endif // _qsSORTING + + return boost::none; +} + inline char * qs_scanvalue(const char * key, const char * qs, char * val, size_t val_len) { @@ -336,6 +381,21 @@ namespace crow return ret; } + std::vector> get_dict (const std::string& name) const + { + std::vector> ret; + std::string plus = name; + + int count = 0; + while(1) + { + if (auto element = qs_dict_name2kv(plus.c_str(), key_value_pairs_.data(), key_value_pairs_.size(), count++)) + ret.push_back(*element); + else + break; + } + return ret; + } private: std::string url_; -- cgit v1.2.3-54-g00ecf