invalid scalar hex value 0x8000000 and over
- by kioto
Hi.
I found a problem getting hex value from yaml file. It couldn't get hex value 0x80000000 and over.
Following is a sample C++ program.
// ymlparser.cpp
#include <iostream>
#include <fstream>
#include "yaml-cpp/yaml.h"
int main(void)
{
try {
std::ifstream fin("hex.yaml");
YAML::Parser parser(fin);
YAML::Node doc;
parser.GetNextDocument(doc);
int num1;
doc["hex1"] >> num1;
printf("num1 = 0x%x\n", num1);
int num2;
doc["hex2"] >> num2;
printf("num2 = 0x%x\n", num2);
return 0;
} catch(YAML::ParserException& e) {
std::cout << e.what() << "\n";
}
}
hex.yaml
hex1: 0x7FFFFFFF
hex2: 0x80000000
Error message is here.
$ ./ymlparser
num1 = 0x7fffffff
terminate called after throwing an instance of 'YAML::InvalidScalar'
what(): yaml-cpp: error at line 2, column 7: invalid scalar
Aborted
Environment
yaml-cpp : getting from svn, March.22.2010 or v0.2.5
OS : Ubuntu 9.10 i386
I need to get hex the value on yaml-cpp now, but I have no idea.
Please tell me how to get it another way.
Thanks,