summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2020-09-02 22:10:29 +1000
committer Vas Crabb <vas@vastheman.com>2020-09-02 22:10:29 +1000
commit83ea46d1580c7012250f707432c8a452d241e027 (patch)
treec057935bdc1d047e86491c941604530a1431d970
parentabb34eb3fc094401814282b1387ea16c06e48ef4 (diff)
Don't ignore config elements with attributes but no child nodes.
-rw-r--r--src/emu/config.cpp2
-rw-r--r--src/lib/util/xmlfile.cpp16
-rw-r--r--src/lib/util/xmlfile.h5
3 files changed, 17 insertions, 6 deletions
diff --git a/src/emu/config.cpp b/src/emu/config.cpp
index abef9a4239b..42126dcad88 100644
--- a/src/emu/config.cpp
+++ b/src/emu/config.cpp
@@ -257,7 +257,7 @@ int configuration_manager::save_xml(emu_file &file, config_type which_type)
type.save(which_type, curnode);
/* if nothing was added, just nuke the node */
- if (!curnode->get_value() && !curnode->get_first_child())
+ if (!curnode->get_value() && !curnode->get_first_child() && !curnode->count_attributes())
curnode->delete_node();
}
diff --git a/src/lib/util/xmlfile.cpp b/src/lib/util/xmlfile.cpp
index 2ef0acfcf0c..ad4d4e1e8f8 100644
--- a/src/lib/util/xmlfile.cpp
+++ b/src/lib/util/xmlfile.cpp
@@ -268,11 +268,10 @@ void data_node::trim_whitespace()
number of child nodes
-------------------------------------------------*/
-int data_node::count_children() const
+std::size_t data_node::count_children() const
{
- int count = 0;
-
/* loop over children and count */
+ std::size_t count = 0;
for (data_node const *node = get_first_child(); node; node = node->get_next_sibling())
count++;
return count;
@@ -280,6 +279,17 @@ int data_node::count_children() const
/*-------------------------------------------------
+ data_node::count_children - count the
+ number of child nodes
+-------------------------------------------------*/
+
+std::size_t data_node::count_attributes() const
+{
+ return m_attributes.size();
+}
+
+
+/*-------------------------------------------------
data_node::get_child - find the first
child of the specified node with the specified
tag
diff --git a/src/lib/util/xmlfile.h b/src/lib/util/xmlfile.h
index 0780172b0c2..814c27aaede 100644
--- a/src/lib/util/xmlfile.h
+++ b/src/lib/util/xmlfile.h
@@ -89,8 +89,9 @@ public:
data_node *get_parent() { return m_parent; }
data_node const *get_parent() const { return m_parent; }
- // count the number of child nodes
- int count_children() const;
+ // count the number of children
+ std::size_t count_children() const;
+ std::size_t count_attributes() const;
// get the first child
data_node *get_first_child() { return m_first_child; }