diff options
author | Aaron Giles <aaron@aarongiles.com> | 2011-04-17 17:49:20 +0000 |
---|---|---|
committer | Aaron Giles <aaron@aarongiles.com> | 2011-04-17 17:49:20 +0000 |
commit | bfbd08f7f72ac948ac27e8795f6f49a6ca6e9383 (patch) | |
tree | e914d0fca9e3bfddb040d5180a9e767c6b9ee8db | |
parent | e91993f24e6f700f6ab648774a3c0a94bab78915 (diff) |
Improve driver enumerator to by default exclude internal drivers,
unless explicitly searched for.
-rw-r--r-- | src/emu/driver.c | 29 | ||||
-rw-r--r-- | src/emu/driver.h | 4 |
2 files changed, 31 insertions, 2 deletions
diff --git a/src/emu/driver.c b/src/emu/driver.c index d39633d649a..cee7268cc80 100644 --- a/src/emu/driver.c +++ b/src/emu/driver.c @@ -77,6 +77,22 @@ int driver_list::find(const char *name) //------------------------------------------------- +// matches - true if we match, taking into +// account wildcards in the wildstring +//------------------------------------------------- + +bool driver_list::matches(const char *wildstring, const char *string) +{ + // can only match internal drivers if the wildstring starts with an underscore + if (string[0] == '_' && (wildstring == NULL || wildstring[0] != '_')) + return false; + + // match everything else normally + return (wildstring == NULL || mame_strwildcmp(wildstring, string) == 0); +} + + +//------------------------------------------------- // driver_sort_callback - compare two items in // an array of game_driver pointers //------------------------------------------------- @@ -241,6 +257,19 @@ int driver_enumerator::filter(const game_driver &driver) //------------------------------------------------- +// include_all - include all non-internal drivers +//------------------------------------------------- + +void driver_enumerator::include_all() +{ + memset(m_included, 1, sizeof(m_included[0]) * s_driver_count); m_filtered_count = s_driver_count; + int empty = find("___empty"); + assert(empty != -1); + m_included[empty] = 0; +} + + +//------------------------------------------------- // next - get the next driver matching the given // filter //------------------------------------------------- diff --git a/src/emu/driver.h b/src/emu/driver.h index c920c0ca5e6..16e23e867c4 100644 --- a/src/emu/driver.h +++ b/src/emu/driver.h @@ -138,7 +138,7 @@ public: static int find(const game_driver &driver) { return find(driver.name); } // static helpers - static bool matches(const char *wildstring, const char *string) { return (wildstring == NULL || mame_strwildcmp(wildstring, string) == 0); } + static bool matches(const char *wildstring, const char *string); protected: // internal helpers @@ -191,7 +191,7 @@ public: // filtering/iterating int filter(const char *string = NULL); int filter(const game_driver &driver); - void include_all() { memset(m_included, 1, sizeof(m_included[0]) * s_driver_count); m_filtered_count = s_driver_count; } + void include_all(); void exclude_all() { memset(m_included, 0, sizeof(m_included[0]) * s_driver_count); m_filtered_count = 0; } void reset() { m_current = -1; } bool next(); |