invalid scalar hex value 0x8000000 and over
Posted
by kioto
on Stack Overflow
See other posts from Stack Overflow
or by kioto
Published on 2010-03-22T16:24:41Z
Indexed on
2010/03/22
16:31 UTC
Read the original article
Hit count: 236
yaml-cpp
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,
© Stack Overflow or respective owner