Alo Sarv
lead developer

Donate via
MoneyBookers

Latest Builds

version 0.3
tar.gz tar.bz2
Boost 1.33.1 Headers
MLDonkey Downloads Import Module Development
Payment completed
Development in progress.
Developer's Diary
irc.hydranode.com/#hydranode

Friday, August 19, 2005

Getting the feeling...

As I mentioned in yesterday's blog post, Boost.Spirit is a completely new topic, and requires a new kind of thinking / looking at it to make it work to our advantage. Today, I believe I'm starting to understand it, at least a bit better. The key is that you can create small, light-weight, in-place parsers with it. For example, parsing an ed2k:// link using Boost.Spirit looks like this:
uint64_t filesize;
std::string filename;
std::string hash;
std::string link("ed2k://|file|slackware.iso|35623456|def4256fba|/");
rule<> parseLink = "ed2k://|file|"
>> *(ch_p[push_back_a(filename)])
>> '|' >> uint_p[assign_a(filesize)]
>> '|' >> *(ch_p[push_back_a(hash)])
>> "|/"
;
parse(link.c_str(), parseLink);
And that's it, the variables contain the contents. Similar "in-place" parses can be created for all kinds of parsing, for example config file, or in current active topic, .torrent file.

Now, some might argue that Spirit is too complex, and the time spent learning it is not worth it, but I disagree - Spirit gives us yet another very valuable tool for current and future tasks. Just as Boost.MultiIndex, Boost.Signals, and many other Boost libraries, which were initially complex to master have now become our daily tools, without which we'd be helpless, will Boost.Spirit be soon enough.

Anyway, the .torrent parser saw progress today, but the parsing stops mid-way in the chunk-hashes for some reason. Also, as I discovered it doesn't handle unrecognized data very well yet; I'm thinking about re-structuring the parser, have the base as recursive parser which just handles the structure (nested dictionaries and lists), and call sub-parsers for actual values extraction.

On other news, however, I have some news on the GUI design topic. Below's a teaser, see this thread for more information and discussion.

* Notice: this is just an image created in photoshop, it's not a real screenshot :). Also, as you noticed some parts are still borrowed (e.g. the progressbars, some icons) - those will be replaced shortly as well.

Madcat, ZzZz



Comments:
Hey kitty. Long time no see. Just to notice you thre's a news post on http://www.amule.org where you're mentioned ;) aMule is just 2 years old! So I had to thank everyone for their work, and of course you, even when you don't love me anymore ;)

c'ya!
 
Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?