2

<0776> <0778> [<00a600310030002f0031> <006b> <00a4>] I have this line in text file and i am parsing it and storing the values in

vector<unsigned long long> myVector;

it stored in vector something like this and first two values are always my starting and ending point and in [] is my array values. First two values are keys(range) and in [] are values three values are going to be mapped on keys

console

myVector[0] = 0776 
myVector[1] = 0778
myVector[2] = 00a600310030002f00
myVector[3] = 31
myVector[4] = 006b
myVector[5] = 00a4

//CODE

static qi::uint_parser<unsigned long long, 16, 2, -1> hex_int;
qi::rule<It, std::vector<unsigned long long>()> braced_hex = '<' >> qi::repeat(1,2)[hex_int] >> '>';
bool check1 = qi::phrase_parse(str_line, l, *braced_hex >> *('[' >> *braced_hex >> ']') , qi::space, v_Begin_BF_Range);
string str;
int startingpoint = myVector[0];
for(int i = myVector[0]; i<= myVector[1]; i++)
{
  str = myVector[i - startingpoint];
}

what i want is

0776 = 00a600310030002f0031;
0777 = 006b
0778 = 00a4
  • 1
    Could it be that sizeof(unsigned long long) == 8 on your platform ? "00a600310030002f0031" is simply too large. – Oncaphillis Jun 25 '15 at 08:02
  • Indeed, you need 72 bits for that hex value ( a6 0031 0030 002f 0031). So apparently the parser discards the last 8 bits to fit the number in 64 bits. – Rugruth Jun 25 '15 at 08:25
  • parser is not discarding the value when parser found the out of range value it automatically split the value into two pieces and pushback halfvalue in one index and another half on other index my question was lil bit different. @sehe can u help me out ? –  Jun 25 '15 at 08:59
  • Well, that's true, the parser doesn't "discard" the last byte, but the problem is still the same, you can't read a 72 bit value into a 64 bit variable. You need a class or extension that supports variables of more than 64 bits. Or you can read strings and do the conversion manually to an ad-hoc class. – Rugruth Jun 25 '15 at 10:10
  • if there is a way to read all values in the string then it would be better can u do that for me ? –  Jun 25 '15 at 10:14
  • I've given you this advice before: [You need to decide what it means when you parse less than 16 hex digits. Does that imply leading zeros? What is the byte ordering assumed to be? Did you actually want to parse just std::vector?](http://stackoverflow.com/questions/30883431/defining-function-in-spirit-rule-gives-warning#comment49820689_30883431). I think by now you've found the relevance. Next time you bring the same question to SO, tell us **what you want to achieve**, not how you are attempting to do it. See [XY-problem](http://meta.stackoverflow.com/questions/66377/q) – sehe Jun 25 '15 at 23:08
  • when 00a600310030002f0031 values comes its breaks into two pieces so i want a track of it that there is a big value thats why its break into two pieces so its help me to identify that this is actually a one value not two . –  Jun 26 '15 at 02:13

0 Answers0