if (node->name() == "DKDM") {
return make_shared<DKDM>(dcp::EncryptedKDM(node->content()));
} else if (node->name() == "DKDMGroup") {
- auto group = make_shared<DKDMGroup>(node->string_attribute("Name"));
+ auto name = node->optional_string_attribute("Name");
+ if (!name) {
+ name = node->string_attribute("name");
+ }
+ auto group = make_shared<DKDMGroup>(*name);
for (auto i: node->node_children()) {
if (auto c = read(i)) {
group->add (c);
void
-DKDM::as_xml (xmlpp::Element* node) const
+DKDM::as_xml(xmlpp::Element* element) const
{
- node->add_child("DKDM")->add_child_text (_dkdm.as_xml ());
+ cxml::add_text_child(element, "DKDM", _dkdm.as_xml());
}
void
-DKDMGroup::as_xml (xmlpp::Element* node) const
+DKDMGroup::as_xml(xmlpp::Element* element) const
{
- auto f = node->add_child("DKDMGroup");
- f->set_attribute ("Name", _name);
+ auto f = cxml::add_child(element, "DKDMGroup");
+ f->set_attribute("name", _name);
for (auto i: _children) {
i->as_xml (f);
}
}
}
}
+
+
+bool
+DKDMGroup::contains(string dkdm_id) const
+{
+ for (auto child: _children) {
+ if (auto child_group = dynamic_pointer_cast<DKDMGroup>(child)) {
+ if (child_group->contains(dkdm_id)) {
+ return true;
+ }
+ } else if (auto child_dkdm = dynamic_pointer_cast<DKDM>(child)) {
+ if (child_dkdm->dkdm().id() == dkdm_id) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+
+bool
+DKDMGroup::contains_dkdm() const
+{
+ for (auto child: _children) {
+ if (child->contains_dkdm()) {
+ return true;
+ }
+ }
+
+ return false;
+}