diff options
Diffstat (limited to 'src/lib/util/xmlfile.h')
-rw-r--r-- | src/lib/util/xmlfile.h | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/lib/util/xmlfile.h b/src/lib/util/xmlfile.h index 8d09b2b7e1e..8949ede2d6d 100644 --- a/src/lib/util/xmlfile.h +++ b/src/lib/util/xmlfile.h @@ -7,17 +7,16 @@ XML file parsing code. ***************************************************************************/ - -#pragma once - #ifndef MAME_LIB_UTIL_XMLFILE_H #define MAME_LIB_UTIL_XMLFILE_H -#include "osdcore.h" +#pragma once + #include "corefile.h" #include <list> #include <string> +#include <string_view> #include <utility> @@ -25,7 +24,7 @@ struct XML_ParserStruct; -namespace util { namespace xml { +namespace util::xml { /*************************************************************************** CONSTANTS @@ -89,8 +88,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; } @@ -134,11 +134,14 @@ public: // return whether a node has the specified attribute bool has_attribute(const char *attribute) const; + // return a pointer to the string value of an attribute, or nullptr if not present + std::string const *get_attribute_string_ptr(const char *attribute) const; + // return the string value of an attribute, or the specified default if not present const char *get_attribute_string(const char *attribute, const char *defvalue) const; // return the integer value of an attribute, or the specified default if not present - int get_attribute_int(const char *attribute, int defvalue) const; + long long get_attribute_int(const char *attribute, long long defvalue) const; // return the format of the given integer attribute int_format get_attribute_int_format(const char *attribute) const; @@ -150,7 +153,7 @@ public: void set_attribute(const char *name, const char *value); // set the integer value of an attribute - void set_attribute_int(const char *name, int value); + void set_attribute_int(const char *name, long long value); // set the float value of an attribute void set_attribute_float(const char *name, float value); @@ -221,7 +224,7 @@ public: static ptr create(); // parse an XML file into its nodes - static ptr read(util::core_file &file, parse_options const *opts); + static ptr read(read_stream &file, parse_options const *opts); // parse an XML string into its nodes static ptr string_read(const char *string, parse_options const *opts); @@ -243,8 +246,8 @@ private: /* ----- miscellaneous interfaces ----- */ /* normalize a string into something that can be written to an XML file */ -const char *normalize_string(const char *string); +std::string normalize_string(std::string_view string); -} } // namespace util::xml +} // namespace util::xml -#endif /* MAME_LIB_UTIL_XMLFILE_H */ +#endif // MAME_LIB_UTIL_XMLFILE_H |