Parsing Binary Data into structure

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Parsing Binary Data into structure

Salman Razzaq

Hi,

 

I have an array of BYTE data which I want to parse using boost spirit framework. My goal is that the parser will parse the binary array of data into a structure. Is it possible to do it.

 

Here is an example: -

 

Data = {0x50, 0x55, 0xF1, 0x2}

 

Struct Header

{

                WORD                   P1;

                BYTE                      P2;

                BYTE                      P3;

}

 

Regards,

 

Salman

 


------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Parsing Binary Data into structure

sehe

On Tue, 23 Sep 2014 15:28:36 +0100, "Salman Razzaq" <[hidden email]> wrote:

Hi,

I have an array of BYTE data which I want to parse using boost spirit framework. My goal is that the parser will parse the binary array of data into a structure. Is it possible to do it.

 

 

 

Yes. You just have to decide whether you know the relevant endiannesses.

Once you know, go here: http://www.boost.org/doc/libs/1_56_0/libs/spirit/doc/html/spirit/qi/reference/binary.html

 


------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Parsing Binary Data into structure

Salman Razzaq

Hi Seth,

 

Thanks for the quick reply.

 

I will go for big endianness.

 

Is it possible can you give me an example of above data into structure.

 

Regards,

 

Salman

 

From: Seth [mailto:[hidden email]]
Sent: 23 September 2014 16:37
To: Spirit General Mailing List
Subject: Re: [Spirit-general] Parsing Binary Data into structure

 

On Tue, 23 Sep 2014 15:28:36 +0100, "Salman Razzaq" <[hidden email]> wrote:

Hi,

I have an array of BYTE data which I want to parse using boost spirit framework. My goal is that the parser will parse the binary array of data into a structure. Is it possible to do it.

 

 

 

Yes. You just have to decide whether you know the relevant endiannesses.

Once you know, go here: http://www.boost.org/doc/libs/1_56_0/libs/spirit/doc/html/spirit/qi/reference/binary.html

 


------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Parsing Binary Data into structure

Stephen Torri
In reply to this post by Salman Razzaq
The only current issue using binary data is showing the output of you use BOOST_SPIRIT_DEBUG_NODE with BOOST_SPIRIT_DEBUG defined. It will print out the XML but the data will be printed as text characters rather than hexadecimal. I have wanted to change that but my current work probably won't let me volunteer the code. 

Stephen


Sent from my Verizon Wireless 4G LTE smartphone


-------- Original message --------
From: Seth
Date:09/23/2014 11:37 (GMT-05:00)
To: Spirit General Mailing List
Subject: Re: [Spirit-general] Parsing Binary Data into structure

On Tue, 23 Sep 2014 15:28:36 +0100, "Salman Razzaq" <[hidden email]> wrote:

Hi,

I have an array of BYTE data which I want to parse using boost spirit framework. My goal is that the parser will parse the binary array of data into a structure. Is it possible to do it.

 

 

 

Yes. You just have to decide whether you know the relevant endiannesses.

Once you know, go here: http://www.boost.org/doc/libs/1_56_0/libs/spirit/doc/html/spirit/qi/reference/binary.html

 


------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general