Lines 1-26
Link Here
|
1 |
--- src/xml.h.orig 2013-10-20 20:33:20.000000000 -0400 |
1 |
--- src/xml.h.orig 2014-05-08 17:59:25.000000000 -0700 |
2 |
+++ src/xml.h 2014-02-01 20:20:55.798824124 -0500 |
2 |
+++ src/xml.h 2014-05-24 04:17:00.000000000 -0700 |
3 |
@@ -108,7 +108,6 @@ |
3 |
@@ -16,6 +16,14 @@ |
4 |
XMLElementAttributeList _attributes; |
4 |
#include <vector> |
5 |
XMLElementList _elements; |
5 |
#include <utility> |
6 |
std::vector<XMLElementList::iterator> _parsingStack; |
6 |
#include <expat.h> |
7 |
- XMLElementList::iterator _iter; |
7 |
+#if defined(__GNUC__) && !defined(__clang__) |
8 |
bool _iterByName; |
8 |
+#define USE_TR1 |
9 |
std::string _iterName; |
9 |
+#endif |
10 |
XMLElementAttributeList::iterator _aiter; |
10 |
+#ifdef USE_TR1 |
11 |
@@ -132,6 +131,7 @@ |
11 |
+#include <tr1/memory> |
|
|
12 |
+#else |
13 |
+#include <memory> |
14 |
+#endif |
15 |
|
16 |
using std::pair; |
17 |
using std::string; |
18 |
@@ -23,12 +31,28 @@ |
19 |
using std::map; |
20 |
using std::multimap; |
21 |
using std::vector; |
22 |
+#ifdef USE_TR1 |
23 |
+using std::tr1::shared_ptr; |
24 |
+#else |
25 |
+using std::shared_ptr; |
26 |
+using std::make_shared; |
27 |
+#endif |
28 |
+ |
29 |
|
30 |
namespace tqsllib { |
31 |
|
32 |
+ |
33 |
class XMLElement; |
34 |
+shared_ptr<XMLElement> make_shared_XMLElement(XMLElement *e); |
35 |
+class XMLElementP { |
36 |
+ public: |
37 |
+ XMLElementP() {} |
38 |
+ XMLElementP(shared_ptr<XMLElement> new_elem) { elem = new_elem; } |
39 |
+ |
40 |
+ shared_ptr<XMLElement> elem; |
41 |
+}; |
42 |
|
43 |
-typedef multimap<string, XMLElement> XMLElementList; |
44 |
+typedef multimap<string, XMLElementP> XMLElementList; |
45 |
typedef map<string, string> XMLElementAttributeList; |
46 |
|
47 |
/** Encapsulates an XML element |
48 |
@@ -62,7 +86,7 @@ |
49 |
*/ |
50 |
pair<string, bool> getAttribute(const string& key); |
51 |
/// Add an element to the list of contained subelements |
52 |
- XMLElementList::iterator addElement(const XMLElement& element); |
53 |
+ XMLElementList::iterator addElement(XMLElement& element); |
54 |
XMLElementAttributeList& getAttributeList() { return _attributes; } |
55 |
XMLElementList& getElementList() { return _elements; } |
56 |
/// Parse an XML file and add its element tree to this element |
57 |
@@ -134,8 +158,8 @@ |
58 |
} |
59 |
|
60 |
inline XMLElementList::iterator |
61 |
-XMLElement::addElement(const XMLElement& element) { |
62 |
- XMLElementList::iterator it = _elements.insert(make_pair(element.getElementName(), element)); |
63 |
+XMLElement::addElement(XMLElement& element) { |
64 |
+ XMLElementList::iterator it = _elements.insert(make_pair(element.getElementName(), make_shared_XMLElement(&element))); |
12 |
return it; |
65 |
return it; |
13 |
} |
66 |
} |
14 |
|
67 |
|
15 |
+#if 0 |
68 |
@@ -158,9 +182,9 @@ |
16 |
inline bool |
69 |
XMLElement::getNextElement(XMLElement& element) { |
17 |
XMLElement::getFirstElement(XMLElement& element) { |
70 |
if (_iter == _elements.end()) |
18 |
_iterByName = false; |
71 |
return false; |
19 |
@@ -157,6 +157,7 @@ |
72 |
- if (_iterByName && _iter->second.getElementName() != _iterName) |
|
|
73 |
+ if (_iterByName && _iter->second.elem->getElementName() != _iterName) |
74 |
return false; |
75 |
- element = _iter->second; |
76 |
+ element = *_iter->second.elem.get(); |
20 |
++_iter; |
77 |
++_iter; |
21 |
return true; |
78 |
return true; |
22 |
} |
79 |
} |
23 |
+#endif |
|
|
24 |
|
25 |
inline bool |
26 |
XMLElement::getFirstAttribute(std::string& key, std::string& attr) { |