Skip to contentSkip to conversation

conga/ricci common/XML.cpp include/XML.h modul ...

Cluster-devel [email protected] 1 participant 1 message Sep 26, 2006

lore
Share & tools
lore
#0 lore raw

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

ricci/common/XML.cpp +23 -1
@@ -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;
+  }
+}
+
 
 
 
ricci/include/XML.h +1 -0
@@ -64,6 +64,7 @@
 };
 
 
+XMLObject readXML(const String& filename);
 XMLObject parseXML(const String& xml);
 String generateXML(const XMLObject& obj);
 
ricci/modules/cluster/ClusterConf.cpp +1 -18
@@ -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