Reputation: 45
I have been trying to parse an XML file using boost's property tree, but every time I want to get the value of a string it throws an access violation exception. It works fine with integers so I'm a bit confused. Here's some of the code:
class Config
{
char * test;
int test2;
public:
Config();
};
Config::Config(void)
{
boost::property_tree::ptree pt;
boost::property_tree::xml_parser::read_xml("config.xml", pt);
try
{
test = pt.get<char*>("base.char");
test2 = pt.get<int>("base.int");
}
catch(std::exception e)
{
//something wasn't specified
}
}
And the XML file:
<base>
<char>test</char>
<int>10</int>
</base>
First I thought it's because I didn't allocate space for the string but neither malloc() nor new char[] helped.
Any help would be appreciated. Thanks in advance :)
Upvotes: 2
Views: 716