Od razu wrzucę funkcję, która modyfikuje plik xml, czyli prosty save game
void Player::UpdatePlayerDataXML( void )
{
std::ifstream file( "pliki/player.xml" );
std::string xmlString( (std::istreambuf_iterator<char>( file )), std::istreambuf_iterator<char>() );
rapidxml::xml_document<> doc;
doc.parse<0>( &xmlString[0] );
rapidxml::xml_node<>* root = doc.first_node( "player" );
root->first_node( "health" )->value( std::to_string( m_healthPoints ).c_str() );
root->first_node( "maxHealth" )->value( std::to_string( m_maxHealthPoints ).c_str() );
root->first_node( "experiencePoints" )->value( std::to_string( m_experiencePoints ).c_str() );
root->first_node( "monstersKilled" )->value( std::to_string( m_monstersKilled ).c_str() );
root->first_node( "pistolAmmunition" )->value( std::to_string( m_pistolAmmunition ).c_str() );
root->first_node( "damage" )->value( std::to_string( m_damage ).c_str() );
root->first_node( "position_x" )->value( std::to_string( m_position.x ).c_str() );
root->first_node( "position_y" )->value( std::to_string( m_position.y ).c_str() );
std::ofstream outFile( "pliki/player.xml" );
outFile << doc;
outFile.close();
}
Problem pojawią się w tym miejscu, visual studio podkreśla na czerwono błąd:
outFile << doc;
żaden operator << nie pasuje do tych argumentów funkcji
typy operandów std::ofstream << rapidxml::xml_document<char>
Tak wyglądają moje dyrektywy include
#include <iostream>
#include <fstream>
#include <string>
#include "rapidxml/rapidxml.hpp"
Po próbie skompilowania:
1>C:\Programming projects\Wanderer\sdlproject\Player.cpp(98,16): error C2679: dwuargumentowy "<<": nie znaleziono żadnego operatora, który przyjmuje prawostronny operand typu "rapidxml::xml_document<char>" (lub nie istnieje akceptowalna konwersja)