Alo Sarv
lead developer

Donate via

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

Thursday, August 18, 2005

The spririt within...

Duh, spirit is unlike anything I'v worked so far before. C++ knowledge is of little use there, when you end up writing constructs like this:

btorrent =
'd'>> *( ("8:announce" >> bstr[var(self.res.announceUrl) = tmpStr])
| ("13:creation date" >> bint[assign_a(self.res.creationDate)])
>> 'e'
bint = 'i' >> int_p >> 'e';
bstr =
>> ':'
>> repeat_p(boost::ref(tmp))[anychar_p[push_back_a(tmpStr)]]

Sadly, the above doesn't work (yet). Spirit library is a strange beast, and requires completely different way of thinking. Yes, there's the grammar specification stuff (which seriously abuses expression templates and operator overloading), but the logic behind the parsing and accessing the parsed data is tricky at best. In the above sample, you saw three different ways to get data from parser - assignment operator, assign_a() function, and push_back_a() function. Those are called "actions" - and there are a ton of possible ones for that, but never enough. The question is where to we attach the actions, and how hardly we couple the parsing and the data handling together.

What I liked about my parser at ed2k module was that I was able to completely decouple the packet parsing and the packet handling, which clearly separated the protocol logic from the protocol format, allowing much simpler coding at both ends. However, I'm not yet sure how to accomplish such a thing with spirit, and whether it's wise to pursue such goal at all with BT / Spirit.

On other news, something I forgot from yesterday - I re-organized the source code structure again, it's now much more editor-friendly - namely, all components files are now in same directory - e.g. hncore headers and source files are in hncore/, ed2k headers and sourcse are in hncore/ed2k (notice I dropped the "plugins" subdir as well). Rationale: it got really tedious to switch between include/hncore/ed2k/ and hncore/plugins/ed2k/src dirs all the time, and there was actually no reason why it should be like that - the original intent was to allow include paths like , but that was now accomplished with much more maintainable directory structure. And keeping this thing maintainable is a continued effort, considering that Hydranode currently consists of roughly 187 source files, totaling somewhere around 40-45'000 lines of code - quite a bit :)

Madcat, off to wonder what does a spirit of a hurricane look like ...

Comments: Post a Comment

<< Home

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