Here is the XML file:
<?xml version="1.0" encoding="utf-8"?><clientConfig> <graphics> <renderer>GL</renderer> <!-- GL, D3D8, D3D9, SW, BR --> <resolutionWidth>1024</resolutionWidth> <resolutionHeight>768</resolutionHeight> <bitDepth>32</bitDepth> <fullscreen>true</fullscreen> <stencilBuffer>false</stencilBuffer> <vsync>false</vsync> </graphics></clientConfig>
Here is the C++ code:
//Create a boost property tree boost::property_tree::ptree proptree; //Read the XML file try { boost::property_tree::read_xml(full_path, proptree, boost::property_tree::xml_parser::no_comments); tog::ClientConfig::m_rendererString = proptree.get<std::string>("clientConfig.graphics.renderer", "GL"); unsigned int width = proptree.get<unsigned int>("clientConfig.graphics.resolutionWidth", 1024); unsigned int height = proptree.get<unsigned int>("clientConfig.graphics.resoltuionHeight", 768); tog::ClientConfig::m_windowResolution = irr::core::dimension2d<irr::u32>(width, height); tog::ClientConfig::m_bitDepth = proptree.get<unsigned short>("clientConfig.graphics.bitDepth", 32); if(proptree.get<std::string>("clientConfig.graphics.fullscreen", "false") == "true") { tog::ClientConfig::m_fullscreen = true; } else { tog::ClientConfig::m_fullscreen = false; } if(proptree.get<std::string>("clientConfig.graphics.stencilBuffer", "false") == "true") { tog::ClientConfig::m_stencilBuffer = true; } else { tog::ClientConfig::m_stencilBuffer = false; } if(proptree.get<std::string>("clientConfig.graphics.vsync", "false") == "true") { tog::ClientConfig::m_vsync = true; } else { tog::ClientConfig::m_vsync = false; } } catch(boost::property_tree::xml_parser_error& e) { throw tog::Exception("Unable to open and parse XML config file \"" + full_path + "\". " + e.what()); } catch(...) { }
I get access violations at every proptree.get().
This is what i get from the error:
First-chance exception at 0x00423da0 in Tales of Garia.exe: 0xC0000005: Access violation reading location 0xcdcdcde5.Unhandled exception at 0x00423da0 in Tales of Garia.exe: 0xC0000005: Access violation reading location 0xcdcdcde5.
That's the exception i get at the first proptree.get(). Visual Studio opens "xstring" at this position:
else if (this->_BUF_SIZE <= this->_Myres) { // copy any leftovers to small buffer and deallocate _Elem *_Ptr = this->_Bx._Ptr; if (0 < _Newsize) _Traits::copy(this->_Bx._Buf, _Ptr, _Newsize); this->_Alval.deallocate(_Ptr, this->_Myres + 1); }
What might be the problem here? The file path is correct, and no exception is thrown before this.
[Edited by - claesson92 on June 20, 2010 3:19:35 PM]