Results 1 to 5 of 5

Thread: Parsing in C++

  1. #1
    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

  2. #2
    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?

  3. #3
    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>

  4. #4
    Join Date
    May 2008
    Posts
    685

    Re: Parsing in C++

    data = new int [20] [20];

    not C ++.

    uses a vector of vector

  5. #5
    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;
          }
           }
           }
           }

Similar Threads

  1. How to use XML Parsing using PHP
    By LasitMalinga in forum Software Development
    Replies: 4
    Last Post: 05-10-2011, 02:33 PM
  2. Parsing XML in Objective C
    By Sheravat in forum Software Development
    Replies: 4
    Last Post: 29-05-2010, 05:58 AM
  3. Parsing XML using MSXML
    By Arumugan in forum Software Development
    Replies: 5
    Last Post: 10-03-2010, 06:20 AM
  4. Parsing XML WebService
    By Efigenio in forum Software Development
    Replies: 4
    Last Post: 03-03-2010, 03:55 AM
  5. javafx xml parsing example
    By russ_da_buss in forum Software Development
    Replies: 3
    Last Post: 10-08-2009, 06:56 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,690,217.19041 seconds with 16 queries