Skip to content

Commit

Permalink
COMMON: Use PtrList to store the child nodes in XMLNode
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed Oct 26, 2016
1 parent ceebc5f commit 2ba2ee9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
16 changes: 1 addition & 15 deletions src/common/xml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,24 +99,10 @@ const XMLNode &XMLParser::getRoot() const {


XMLNode::XMLNode(_xmlNode &node, bool makeLower, XMLNode *parent) : _parent(parent) {
try {

load(node, makeLower);

} catch (...) {
clean();

throw;
}
load(node, makeLower);
}

XMLNode::~XMLNode() {
clean();
}

void XMLNode::clean() {
for (Children::iterator c = _children.begin(); c != _children.end(); ++c)
delete *c;
}

const UString &XMLNode::getName() const {
Expand Down
5 changes: 3 additions & 2 deletions src/common/xml.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <boost/noncopyable.hpp>

#include "src/common/scopedptr.h"
#include "src/common/ptrlist.h"
#include "src/common/ustring.h"

struct _xmlNode;
Expand Down Expand Up @@ -62,7 +63,7 @@ class XMLParser : boost::noncopyable {
class XMLNode : boost::noncopyable {
public:
typedef std::map<UString, UString> Properties;
typedef std::list<const XMLNode *> Children;
typedef PtrList<const XMLNode> Children;

const UString &getName() const;
const UString &getContent() const;
Expand Down Expand Up @@ -100,7 +101,7 @@ class XMLNode : boost::noncopyable {
~XMLNode();

void load(_xmlNode &node, bool makeLower);
void clean();


friend class XMLParser;

Expand Down

0 comments on commit 2ba2ee9

Please sign in to comment.