Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 20-04-2009
Member
 
Join Date: May 2008
Posts: 859
Parsing in C++

In a project of mine, I need a parsing when given a series of binary and store in a table. I really need your help because I blocked for a while. I can not find the solution. The data that I get are hexadecimal and have the same form:

The first part we will call and request that contains:
A code announcing the beginning of the sequence: 0x5C (character \), ASCII 2 (representing the type of application), 2 bytes (not ASCII).

The two bytes represent the end of that size will the data following the complaint.

Example:
String \ Z 5 F
Hex. 5C 46 5A 00 05
Here the party will be given a size 5.

In the data that contains data we have:
This time at the beginning of each data sequence we find the code symbol # 23, 2 ASCII (representing the data type), 2 bytes (not ASCII). And the end of two bytes is the size of the data processed.

Example:
String. I F # 5
Hex 23 46 49 00 05
This means that data size 5 follow this sequence.

An example of a complete sequence in hexadecimal would be (I removed the data part of this sequence in the example to be hexadecimal in this case ABCDE who come to the end of the last cycle and I just put in the translation string) :
5C 46 49 00 0A 23 46 4E 00 23 46 49 00 05

Who would give string:
\ FN0 # FI10 # FI5ABCDE

I would like to store in a parsing of the data. It should be recognized to summarize the request starting with 5C (\) and stored recognize the size of the data in the query. Depending on the size, given the treaty. Noticing the hex code 23 (#) announcing the start of a sequence of data. And the size of the data after the code sequence and stored as well. In the data there are several data that may follow but there is a single query. I hope not to have been too confusing
Reply With Quote
  #2  
Old 20-04-2009
Member
 
Join Date: May 2008
Posts: 685
Re: Parsing in C++

And what problem are you having? I suppose that shouldn't generate any problem. Could you be specific about your issue and provide some more details?
Reply With Quote
  #3  
Old 20-04-2009
Member
 
Join Date: May 2008
Posts: 859
Re: Parsing in C++

Here is the function that I began to write. But I think that it is easier and I do not take everything into account. I need help with something that works better.

Code:
<code type="cpp">
bool parse( int* tab )
{   int k=0;
 int *rqst= NULL;
 int **data= NULL;
    rqst = new int[20];
    data = new int[20][20];
 for (int i =0;i<5;i++)
      {
  rqst[i]= tab[i];
      }
 for (int i =0;i<tab[4];i++)
      for (int j =0;j< 4+data[k][4];j++)
      {  int i;
   int j;
       data[k][j]=tab[i];
     if(data[k][j]== 23)
      {
       k++;
       j=0;
      }
      }
      }</code>
Reply With Quote
  #4  
Old 20-04-2009
Member
 
Join Date: May 2008
Posts: 685
Re: Parsing in C++

data = new int [20] [20];

not C ++.

uses a vector of vector
Reply With Quote
  #5  
Old 20-04-2009
Member
 
Join Date: May 2008
Posts: 859
Re: Parsing in C++

I fixed the code by using a vector to vector. But I still get the other errors. And I do not take everything into account.

Code:
 vector< vector<int> > parse( int* tab )
 {   int k=0;
 int *rqst= NULL;
 // int **data= NULL;
 vector< vector<int> > data;
     rqst = new int[20];
     //data = new int[20][20];
 for (int i =0;i<5;i++)
       {
  rqst[i]= tab[i];
       }
 for (int i =0;i<tab[4];i++)
   {
  for (int j =0;j< 4+data[k][4];j++)
       {  int i;
   int j;
        data[k][j]=tab[i];
     if(data[k][j]== 23)
      {
       k++;
       j=0;
      }
       }
       }
       }
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Parsing in C++"
Thread Thread Starter Forum Replies Last Post
How to use XML Parsing using PHP LasitMalinga Software Development 4 05-10-2011 02:33 PM
Parsing XML in Objective C Sheravat Software Development 4 29-05-2010 05:58 AM
Parsing XML using MSXML Arumugan Software Development 5 10-03-2010 06:20 AM
Parsing XML WebService Efigenio Software Development 4 03-03-2010 03:55 AM
javafx xml parsing example russ_da_buss Software Development 3 10-08-2009 06:56 PM


All times are GMT +5.5. The time now is 12:45 PM.