qi::repeat(1,2) funtion in rule is giving me warrning and i dont want to ignore that warning so i want to optimized this code like separating the rule from the parsering method.
qi::phrase_parse is doing the same thing which is in the the rule but i want to sperate the rule and give rule to the pharse_parse funtion.
std::ifstream ifs("f:/test.txt");
std::string line;
//In header in my code
std::vector<unsigned long long> v_BF_Char;
//qi::int_parser<uintmax_t, 16> hex_int;
static qi::uint_parser<unsigned long long, 16, 16, 16> 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 = '<' >> qi::repeat(1,2)[hex_int] >> '>';
bool ok = qi::phrase_parse(begin, end,
*('<' >> qi::repeat(1,2)[ hex_int ] >> '>'), qi::space, v_BF_Char);
and want to do somthing like this
bool ok = qi::phrase_parse(begin, end,
braced_hex , qi::space, v_BF_Char);
test.txt Contain
<51dc> <04001C0180000000000000000EE317BC>
<05001C0180000000> <04001C0180000000000000000EE317BC>
<51dc> <30ea30f330ae30c330c8>
<0000> <fffd>
<003d> <00a5>
<005d> <00a6>
<005e> <007d>
<005f> <0303>
<0060> <2019>
<0061> <005c>
<0062> <2018>
<0063> <007c>
<0064> <007e>
<0068> <2044>
<0069> <0192>
<006a> <00a7>
<006b> <00a4>
<006c> <201c>
My code is working for only 2nd line and extract values in vector but not other line values.
Fix the rule's exposed attribute:
Repeat exposes a vector of
hex_int
's exposed attribute typeLive demo:
Live On Coliru
Prints:
E.g. for this input: