[gnote] Dynamically create XmlWriter
- From: Aurimas Äernius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Dynamically create XmlWriter
- Date: Fri, 3 Feb 2012 21:36:06 +0000 (UTC)
commit d4568bf006a05232a01234c777bca1c4f50ee109
Author: Aurimas Äernius <aurisc4 gmail com>
Date: Thu Feb 2 22:57:04 2012 +0200
Dynamically create XmlWriter
File gets written on destruction and we need to control, when it is written.
src/synchronization/filesystemsyncserver.cpp | 36 +++++++++++++------------
1 files changed, 19 insertions(+), 17 deletions(-)
---
diff --git a/src/synchronization/filesystemsyncserver.cpp b/src/synchronization/filesystemsyncserver.cpp
index 84a1754..5c26827 100644
--- a/src/synchronization/filesystemsyncserver.cpp
+++ b/src/synchronization/filesystemsyncserver.cpp
@@ -256,12 +256,12 @@ bool FileSystemSyncServer::commit_sync_transaction()
}
// Write out the new manifest file
- sharp::XmlWriter xml(manifestFilePath);
+ sharp::XmlWriter *xml = new sharp::XmlWriter(manifestFilePath);
try {
- xml.write_start_document();
- xml.write_start_element("", "sync", "");
- xml.write_attribute_string("", "revision", "", boost::lexical_cast<std::string>(m_new_revision));
- xml.write_attribute_string("", "server-id", "", m_server_id);
+ xml->write_start_document();
+ xml->write_start_element("", "sync", "");
+ xml->write_attribute_string("", "revision", "", boost::lexical_cast<std::string>(m_new_revision));
+ xml->write_attribute_string("", "server-id", "", m_server_id);
for(sharp::XmlNodeSet::iterator iter = noteNodes.begin(); iter != noteNodes.end(); ++iter) {
std::string note_id = sharp::xml_node_xpath_find_single(*iter, "@id");
@@ -277,27 +277,29 @@ bool FileSystemSyncServer::commit_sync_transaction()
continue;
}
- xml.write_start_element("", "note", "");
- xml.write_attribute_string("", "id", "", note_id);
- xml.write_attribute_string("", "rev", "", rev);
- xml.write_end_element();
+ xml->write_start_element("", "note", "");
+ xml->write_attribute_string("", "id", "", note_id);
+ xml->write_attribute_string("", "rev", "", rev);
+ xml->write_end_element();
}
// Write out all the updated notes
for(std::list<std::string>::iterator iter = m_updated_notes.begin(); iter != m_updated_notes.end(); ++iter) {
- xml.write_start_element("", "note", "");
- xml.write_attribute_string("", "id", "", *iter);
- xml.write_attribute_string("", "rev", "", boost::lexical_cast<std::string>(m_new_revision));
- xml.write_end_element();
+ xml->write_start_element("", "note", "");
+ xml->write_attribute_string("", "id", "", *iter);
+ xml->write_attribute_string("", "rev", "", boost::lexical_cast<std::string>(m_new_revision));
+ xml->write_end_element();
}
- xml.write_end_element();
- xml.write_end_document();
- xml.close();
+ xml->write_end_element();
+ xml->write_end_document();
+ xml->close();
xmlFreeDoc(xml_doc);
+ delete xml;
}
catch(...) {
- xml.close();
+ xml->close();
+ delete xml;
throw;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]