|
Boost Users : |
Subject: Re: [Boost-users] Can boost help me organize/parse lots of binary data?
From: Larry Evans (cppljevans_at_[hidden])
Date: 2013-02-23 11:39:34
On 02/22/13 08:38, Larry Evans wrote:
> On 02/22/13 00:16, Antony Polukhin wrote:
[snip]
> In the example code from your last post, which is quoted below, the
> variant visitor is not used to decode this input stream, it's only
> used to perform some operaton on the variant. Quoting from Chris' OP:
>
> I will be decoding many of these "packets" and doing various things
> with them like printing their values to console, etc.
>
> That quote mentions two purposes:
>
> 1) Decoding packets
> 2) Operating on the decoded packets
>
> The code quoted below does 2); however, the 1) is done by the Decode
This should read:
The variant visitor code quoted below does 2)
> methods shown below, the most complicated of which is the
> EmployeePacket::Decode. This EmployeePacket::Decode is somewhat like
> a very simple Spirit alternative parser:
>
>
>
http://www.boost.org/doc/libs/1_53_0/libs/spirit/doc/html/spirit/qi/reference/operator/alternative.html
>
Actually, I think a Spirit would be an instance of the "inversion of
control":
http://martinfowler.com/bliki/InversionOfControl.html
of EmployeePacket::Decode. IOW, the Decode method of processing the
binary input stream uses "Normal Control" whereas using spirit to
process the input stream would use "Inversion of the Normal Control"
to process the binary input stream. That's because, like the #ruby
example in the InversionOfControl.html, the Decode method uses "Normal
Control" because it decides when to read the input stream
(corresponding to the #ruby example's "when to ask questions, when to
read responses"), and using a switch statement, when to call another
Decode function to process the read data (corresponding to the #ruby
example's "when to process those results".). OTOH, spirit, AFAICT,
uses "Inverson of the Normal Control" in that it, instead of the user,
decides when to read the input and when to call the processing
functions (a.k.a the semantic actions, or the "process_name" and
"process_quest" functions in the Tk exmaple in
InversionOfControl.html).
Hence, if you decide to use spirit, I think the Decode functions would
have to be rewritten to be semantic actions to be called by the
spirit's parsers :(
[snip]
HTH.
-Larry
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net