From mboxrd@z Thu Jan 1 00:00:00 1970 From: kupcevic@sourceware.org Date: 26 Sep 2006 00:54:27 -0000 Subject: [Cluster-devel] conga/ricci common/XML.cpp include/XML.h modul ... Message-ID: <20060926005427.15669.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 #include - +#include //#include 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