[Cluster-devel] conga/ricci common/XML.cpp include/XML.h modul ...
kupcevic at sourceware.org
kupcevic at sourceware.org
Tue Sep 26 00:54:27 UTC 2006
CVSROOT: /cvs/cluster
Module name: conga
Changes by: kupcevic at sourceware.org 2006-09-26 00:54:26
Modified files:
ricci/common : XML.cpp
ricci/include : XML.h
ricci/modules/cluster: ClusterConf.cpp
Log message:
xml file parsing - code aggregation
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/common/XML.cpp.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/include/XML.h.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/ClusterConf.cpp.diff?cvsroot=cluster&r1=1.5&r2=1.6
--- conga/ricci/common/XML.cpp 2006/08/14 23:55:48 1.4
+++ conga/ricci/common/XML.cpp 2006/09/26 00:54:26 1.5
@@ -29,7 +29,7 @@
#include <libxml/tree.h>
#include <algorithm>
-
+#include <fstream>
//#include <iostream>
using namespace std;
@@ -226,6 +226,28 @@
return xml;
}
+XMLObject
+readXML(const String& filename)
+{
+ char* buff = 0;
+ try {
+ ifstream is(filename.c_str());
+ is.seekg(0, ios::end);
+ unsigned int length = is.tellg();
+ is.seekg(0, ios::beg);
+ buff = new char[length];
+ is.read(buff, length);
+ String xml_data(buff, length);
+
+ XMLObject xml(parseXML(xml_data));
+ delete [] buff; buff = 0;
+ return xml;
+ } catch ( ... ) {
+ delete [] buff;
+ throw;
+ }
+}
+
--- conga/ricci/include/XML.h 2006/08/10 22:53:07 1.3
+++ conga/ricci/include/XML.h 2006/09/26 00:54:26 1.4
@@ -64,6 +64,7 @@
};
+XMLObject readXML(const String& filename);
XMLObject parseXML(const String& xml);
String generateXML(const XMLObject& obj);
--- conga/ricci/modules/cluster/ClusterConf.cpp 2006/08/15 00:16:30 1.5
+++ conga/ricci/modules/cluster/ClusterConf.cpp 2006/09/26 00:54:26 1.6
@@ -49,24 +49,7 @@
XMLObject
ClusterConf::get()
{
- char* buff = 0;
- try {
- ifstream is(CLUSTER_CONF_PATH.c_str());
- is.seekg(0, ios::end);
- unsigned int length = is.tellg();
- is.seekg(0, ios::beg);
- buff = new char[length];
- is.read(buff, length);
- String cluster_conf(buff, length);
-
- XMLObject xml(parseXML(cluster_conf));
- delete [] buff;
- buff = 0;
- return xml;
- } catch ( ... ) {
- delete [] buff;
- throw;
- }
+ return readXML(CLUSTER_CONF_PATH);
}
void
More information about the Cluster-devel
mailing list