From: Dean M. B. <mik...@gm...> - 2010-02-11 16:51:23
|
On Fri, Feb 12, 2010 at 12:27 AM, Jeroen Habraken <vex...@gm...> wrote: > Hi guys, > > On Thu, Feb 11, 2010 at 15:25, Dean Michael Berris > <mik...@gm...> wrote: >> I was thinking about this a little and thought it would be cool to >> have a collection of utilities of commonly-performed actions that >> others might find useful in the library. Off the top of my head I find >> that these would be cool functions/mini-libraries to have: > > This would be very nice indeed. Also, in my opinion, we need a few > more code examples as I've generally found them to be a good way to > familiarize yourself with a library. Something like a simple HTTP > proxy might even fall in both categories, showing off both the client > and server side of the library. > Code examples are definitely good to have. I'm a little afraid though that we'd ruffle a few feathers if we implemented something like this. I've been meaning to do a wicked fast static HTTP server that competes with lighttpd/nginx in simplicity and performance. My worry would be that it would be a project that would have its own demons. ;) > > The query parser is indeed one of the things currently on the TODO > list for the URI part of the library. Design-wise I was thinking of > something like: > > template <class Tag> > bool parse_query(basic_uri<Tag> const & uri, typename query_list<Tag>::type &) { > // TODO Parse using Spirit > > return true; // Return whether it was successful. > } > > with > > template <class Tag> > struct query_list { > typedef typename string<Tag>::type string_type; > > typedef typename std::list<std::pair<string_type, string_type> > type; > } > > and something along the same lines for query_map for a std::map. This > is off the top of my head, and your thoughts would be very much > appreciated. As I've said before, most of the grunt work has already > been done by Hartmunt in this brilliant article: > http://boost-spirit.com/home/articles/qi-example/parsing-a-list-of-key-value-pairs-using-spirit-qi/ > thus with some luck this is actually rather easy. > Sure, but it just assumes the "canonical" form of "key=value&foo=bar". There's a lot more to query strings than just this form (some use different delimeters, instead of &, some use |, there's also list and multi-form notation like "form1[field]=value&form2[field]=value" and all sorts of funky things). That in itself sounds like a pretty useful/powerful set of parsers that would definitely make for an interesting project. Now I'm seriously considering applying for a Google Summer of Code thing to get support for the project. :D Maybe after BoostCon and once more people get to use the library more. ;) > Secondly, I have the basis of a dispatcher I wrote for libevent > bindings some time ago, which I've attached. There seem to be a few > things which need to be abstracted from though: > - The comparison function > - The type you're comparing to > and quite probably a few more things, as ultimately I'd be very useful > if you could stick in boost::starts_with, something from the regex > library or from the xpressive library to find a match. If anyone finds > this code is of any use for cpp-netlib, I'll stick a boost license on > it. > I haven't looked at it yet, but I have a somewhat dormant header-only library on SourceForge that does pretty much something similar (It's called the Runtime Dynamic Dispatch Library). I'm looking for something more flexible though, something that allows me to map a boost::regex string that contains sub-groups (or named groups) to a function that has the signature: void(request const &, response &). Does your implementation do roughly that? I might come up with a simple implementation and place it in boost/network/utils -- when I get time to do so that is. ;) >> Any takers? It would be cool if we had these in the library before May >> where I will be presenting the library and the techniques used in the >> library at a high level. ;) > > This is where things get tricky, considering I've just got an > apartment this month and will be moving, I'm quite limited when it > comes to free time unfortunately. > I can understand that completely, having been in that situation before. May is still a ways away -- you've got time in between now and then. :D >> Hope this helps and I hope to hear from you guys soon too! >> > > Hope this is of any use, I'll take a look and I encourage others in the list to do the same. :) -- Dean Michael Berris cplusplus-soup.com | twitter.com/deanberris linkedin.com/in/mikhailberis | facebook.com/dean.berris | deanberris.com |