help with parsing constructs from file and populating custom data-structs

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

help with parsing constructs from file and populating custom data-structs

Rajan, Vivek K

Hello-

 

I have a file which contains many occurrence of following construct; one such snippet is shown below:

 

 

Id 1

   S/E : (A) ABC (jj/kk/ll) --> (B) mm/nn/pp  (tt/oo/kk)

   T1    [m]         -0.123

   T2    [m]         -0.234

   T3    [m]         0.009

 

   0.1     0.2       0.3     (a)   0.5    b    cc      a1/b1/c1                gggg llll

             99        0.1    (b)                           a2/b2/c2

   0.2     0.3       0.4     (a)   0.9    b    cc      a3/b3/c3              hhhh kk

   - - - - END OF ID - - - -

 

 

 

In my C++ program, I have the following custom data-structure:

======================================================

 

typedef std::vector< std::pair<std::string, std::string> > _StrStrVector;

 

  struct _TP {

    int _id;                         // = 1                         from above snippet

 

    std::string _s;                // = ABC                    from above snippet

    std::string _e;                // = mm/nn/pp            from above snippet

 

    // Header

    double _T1;                   // = -0.123                 from above snippet

    double _T2;                   // = -0.234                 from above snippet

    double _T3;                   // = 0.009                  from above snippet

 

    // Path trace

    _StrStrVector _tc;

 

        // From above snippet

        // Add the trace

        // pair<string, string> pr;

        // p._tc.clear();

          // pr.first  = "a1/b1/c1";

          // pr.second = "0.1     0.2       0.3     (a)   0.5    b    cc”;

          // p._tc.push_back(pr);

 

          // pr.first  = "a2/b2/c2";

          // pr.second = "99        0.1    (b)”;

          // p._tc.push_back(pr);

 

          // pr.first  = "a3/b3/c3";

          // pr.second = "0.2     0.3       0.4     (a)   0.9    b    cc”;

          // p._tc.push_back(pr);

  };

======================================================

 

Can someone help me with how to create SPIRIT rules to parse the above construct from a file and populate my custom data-structure as show above? Thanks for help. New with SPIRIT parsers, still learning.

 

Vivek