[1D] Change 'save' behavior to avoid endlessly appending solutions
Instead of changing the solution 'id' provided by the user to avoid duplicates, replace the solution with the same id.
This commit is contained in:
parent
2a69d99d83
commit
4081d41841
1 changed files with 5 additions and 9 deletions
|
|
@ -385,21 +385,17 @@ void OneDim::save(const std::string& fname, std::string id,
|
|||
XML_Node* ct;
|
||||
if (fin) {
|
||||
root.build(fin);
|
||||
const XML_Node* same_ID = root.findID(id);
|
||||
int jid = 1;
|
||||
string idnew = id;
|
||||
while (same_ID != 0) {
|
||||
idnew = id + "_" + int2str(jid);
|
||||
jid++;
|
||||
same_ID = root.findID(idnew);
|
||||
// Remove existing solution with the same id
|
||||
XML_Node* same_ID = root.findID(id);
|
||||
if (same_ID) {
|
||||
same_ID->parent()->removeChild(same_ID);
|
||||
}
|
||||
id = idnew;
|
||||
fin.close();
|
||||
ct = &root.child("ctml");
|
||||
} else {
|
||||
ct = &root.addChild("ctml");
|
||||
}
|
||||
XML_Node& sim = (XML_Node&)ct->addChild("simulation");
|
||||
XML_Node& sim = ct->addChild("simulation");
|
||||
sim.addAttribute("id",id);
|
||||
addString(sim,"timestamp",asctime(newtime));
|
||||
if (desc != "") {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue