1

Here is my code

std::ifstream ifs("f:/test.txt");
std::string line;

//In header in my code
static std::vector<unsigned long long> v_BF_Char;
static std::vector<unsigned long long> v_Begin_BF_Range;
static std::multimap<uintmax_t, std::string> m_BF_Char;

//qi::int_parser<uintmax_t, 16> hex_int;
static qi::uint_parser<unsigned long long, 16, 2, -1> hex_int; 

while (std::getline(ifs, line))
{
    typedef std::string::const_iterator It;
    It begin = line.begin(), end = line.end();

    // rule for grammer
   //  qi::rule<It, unsigned long long()> braced_hex = '<' >> hex_int >> '>';
    qi::rule<It, uintmax_t()> braced_hex2 = '<' >> hex_int >> '>';
    qi::rule<It, std::vector<unsigned long long>()> braced_hex = '<' >> qi::repeat(1,2)[hex_int] >> '>';
    qi::rule<It, std::vector<unsigned long long>()> braced_hex1 = '[' >> qi::repeat(1,2)[hex_int] >> ']';
    bool beginbfrange_check = qi::phrase_parse(begin, end, *braced_hex >> *braced_hex1 , qi::space, v_Begin_BF_Range);
}

My test.txt Contain the following data

<005d> <00a6> [<0063> <007c> <0064> <007e>]
<51dc> <04001C0180000000000000000EE317BC>
<05001C0180000000> <04001C0180000000000000000EE317BC>
<51dc> <30ea30f330ae30c330c8>
<0000> <fffd>
<003d> <00a5>
<05001C0180000000> <04001C0180000000000000000EE317BC>
<005d> <00a6>
<005e> <007d>
<005f> <0303>
<0060> <2019>

I want to parse <005d> <00a6> [<0063> <007c> <0064> <007e>] this line which is the first line of my text file.

I am parsing it like that

qi::rule<It, uintmax_t()> braced_hex2 = '<' >> hex_int >> '>';
bool beginbfrange_check = qi::phrase_parse(begin, end, *braced_hex2 >> *('[' >> *braced_hex2 >> ']') , qi::space, v_Begin_BF_Range);

Which is working fine but i want to use my optimized rule and when i used it which is

bool beginbfrange_check = qi::phrase_parse(begin, end, *braced_hex >> *braced_hex1 , qi::space, v_Begin_BF_Range);

it works but vector store only 005d and 00a6 values and not store rest of the values the values in vector should be 005d 00a6 0063 007c 0064> 007e

**The problem is with other QI rule **

  • For the record, the older answer is here: http://stackoverflow.com/questions/30365628/function-or-functor-calling-using-sprit-boost-parser-library-rule-to-save-values – sehe Jun 18 '15 at 00:27
  • pleas why are you taking it seriously that question is look like my question but my question say far way different than that pleas run it and check it by your self i want to do thats with optimized way. why you dont wanna help me ?and i am not mad btw i said that in question clearly? –  Jun 18 '15 at 05:20

0 Answers0