@@ -38,12 +38,18 @@ namespace XdgUtils {
38
38
}
39
39
}
40
40
41
+ std::vector<std::shared_ptr<Node>>& Group::getEntries () {
42
+ return entries;;
43
+ }
44
+
41
45
const std::vector<std::shared_ptr<Node>>& Group::getEntries () const {
42
46
return entries;
43
47
}
44
48
45
49
void Group::setEntries (const std::vector<std::shared_ptr<Node>>& entries) {
46
- Group::entries = entries;
50
+ this ->entries .clear ();
51
+ for (const auto & entry: entries)
52
+ this ->entries .emplace_back (entry->clone ());
47
53
}
48
54
49
55
bool Group::operator ==(const Group& rhs) const {
@@ -54,25 +60,8 @@ namespace XdgUtils {
54
60
auto bItr = rhs.entries .begin ();
55
61
56
62
while (aItr != entries.end () && bItr != rhs.entries .end ()) {
57
- if (auto a = dynamic_cast <Entry*>((*aItr).get ())) {
58
- // if the first one is an Entry the second one must also be
59
- if (auto b = dynamic_cast <Entry*>((*bItr).get ())) {
60
- // if both are entries compare them as such
61
- if (*a != *b)
62
- return false ;
63
- } else
64
- return false ;
65
- }
66
-
67
- if (auto a = dynamic_cast <Comment*>((*aItr).get ())) {
68
- // if the first one is an Comment the second one must also be
69
- if (auto b = dynamic_cast <Comment*>((*bItr).get ())) {
70
- // if both are comments compare them as such
71
- if (*a != *b)
72
- return false ;
73
- } else
74
- return false ;
75
- }
63
+ if (*aItr->get () != *bItr->get ())
64
+ return false ;
76
65
77
66
++aItr, ++bItr;
78
67
}
@@ -81,6 +70,7 @@ namespace XdgUtils {
81
70
return (aItr == entries.end () && bItr == rhs.entries .end ());
82
71
}
83
72
73
+
84
74
bool Group::operator !=(const Group& rhs) const {
85
75
return !(rhs == *this );
86
76
}
@@ -89,6 +79,38 @@ namespace XdgUtils {
89
79
group.write (os);
90
80
return os;
91
81
}
82
+
83
+ Node* Group::clone () const {
84
+ return new Group (*this );
85
+ }
86
+
87
+ Group::Group (const Group& other) : headerValue(other.headerValue), headerRawValue(other.headerRawValue) {
88
+ setEntries (other.entries );
89
+ }
90
+
91
+ Group& Group::operator =(const Group& other) {
92
+ headerValue = other.headerValue ;
93
+ headerRawValue = other.headerRawValue ;
94
+
95
+ setEntries (other.entries );
96
+ return *this ;
97
+ }
98
+
99
+ Group::Group (Group&& other) noexcept {
100
+ headerValue = std::move (other.headerValue );
101
+ headerRawValue = std::move (other.headerRawValue );
102
+ entries = std::move (other.entries );
103
+ }
104
+
105
+ Group& Group::operator =(Group&& other) noexcept {
106
+ headerValue = std::move (other.headerValue );
107
+ headerRawValue = std::move (other.headerRawValue );
108
+ entries = std::move (other.entries );
109
+
110
+ return *this ;
111
+ }
112
+
113
+ Group::~Group () = default ;
92
114
}
93
115
}
94
116
}
0 commit comments