Opened 12 years ago
Last modified 11 years ago
#4738 new Bugs
property_tree parsers fail when top node has data()
Reported by: | Owned by: | Sebastian Redl | |
---|---|---|---|
Milestone: | To Be Determined | Component: | property_tree |
Version: | Boost 1.43.0 | Severity: | Problem |
Keywords: | property_tree, data, root, parser | Cc: |
Description
ptree tree( "DATA" ); write_xml( "test.xml", tree ); // writes out DATA with no tag read_xml( "test.xml", tree ); // fails since cannot read DATA without a tag.
ptree pt1( "DATA" ); write_info( "test.info", tree ); // does not write DATA at all ptree pt2; read_info( "test.info", pt2 ); // reads in empty ptree BOOST_CHECK( pt1 == pt2 ); // fails since the node has no data
These could be easy fixes but some convention will have to be adopted. The info parser could be modified to write out the top level data when indent==-1 but the reader would then have to interpret an initial string with no following data or children to as data(). Alternatively there could be a null key represented by "" or some special character.
The XML is trickier because the DATA either needs to be an attribute or needs some sort of tag, or it cannot be parsed as XML.
I only checked this on the 1.43.0 that I have installed but it does not appear that the problem has been fixed in 1.44.0 or in subversion.
What this really should use is fail at write time for the XML interface.