1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| int user_mgr::modifier(const string& u, const string& attrib, const string& value){
bool trouve = false;
TiXmlHandle hdl(doc);
TiXmlElement *elem = hdl.FirstChildElement().FirstChildElement().Element();
while(elem && !trouve){
if( string(elem->Attribute("name")) == u){
trouve = true;
break;
}
elem = elem->NextSiblingElement();
}
if (!trouve){
cerr << "client inexistant" << endl;
return 1;
}
else{
elem->SetAttribute(attrib, value);
doc->SaveFile(xml_filename);
// mise a jour de la liste
list<user>::iterator i=user_list.begin();
while(i!=user_list.end() && i->name!=u){
if(attrib == "name")
i->name=value;
else if(attrib == "pass")
i->pass=value;
else if(attrib == "droits"){
istringstream iss(value);
int int_value;
iss >> int_value;
i->droits=int_value;
}
else
cerr << "attribut inconnu" << endl;
i++;
}
return 0;
}
} |
Partager