Construct, reading in from the provided stream ! Reads in an entire XML document from some stream and parses it as soon as serialization starts @param stream The stream to read from. Can be a stringstream or a file. */
| 415 | |
| 416 | @param stream The stream to read from. Can be a stringstream or a file. */ |
| 417 | XMLInputArchive( std::istream & stream ) : |
| 418 | InputArchive<XMLInputArchive>( this ), |
| 419 | itsData( std::istreambuf_iterator<char>( stream ), std::istreambuf_iterator<char>() ) |
| 420 | { |
| 421 | try |
| 422 | { |
| 423 | itsData.push_back('\0'); // rapidxml will do terrible things without the data being null terminated |
| 424 | itsXML.parse<rapidxml::parse_trim_whitespace | rapidxml::parse_no_data_nodes | rapidxml::parse_declaration_node>( reinterpret_cast<char *>( itsData.data() ) ); |
| 425 | } |
| 426 | catch( rapidxml::parse_error const & ) |
| 427 | { |
| 428 | //std::cerr << "-----Original-----" << std::endl; |
| 429 | //stream.seekg(0); |
| 430 | //std::cout << std::string( std::istreambuf_iterator<char>( stream ), std::istreambuf_iterator<char>() ) << std::endl; |
| 431 | |
| 432 | //std::cerr << "-----Error-----" << std::endl; |
| 433 | //std::cerr << e.what() << std::endl; |
| 434 | //std::cerr << e.where<char>() << std::endl; |
| 435 | throw Exception("XML Parsing failed - likely due to invalid characters or invalid naming"); |
| 436 | } |
| 437 | |
| 438 | // Parse the root |
| 439 | auto root = itsXML.first_node( xml_detail::CEREAL_XML_STRING ); |
| 440 | if( root == nullptr ) |
| 441 | throw Exception("Could not detect cereal root node - likely due to empty or invalid input"); |
| 442 | else |
| 443 | itsNodes.emplace( root ); |
| 444 | } |
| 445 | |
| 446 | ~XMLInputArchive() CEREAL_NOEXCEPT = default; |
| 447 |
nothing calls this directly
no test coverage detected