diff options
| author | Max Horn | 2006-03-28 09:42:54 +0000 |
|---|---|---|
| committer | Max Horn | 2006-03-28 09:42:54 +0000 |
| commit | 9f93e5bb81a54a98eb7957209662f152e2962679 (patch) | |
| tree | ffd439f7aa7347bd7ba806c2131be458a7112ef1 /common | |
| parent | 950c3451a2dbadffa6437e98a20eb3a4163216e2 (diff) | |
| download | scummvm-rg350-9f93e5bb81a54a98eb7957209662f152e2962679.tar.gz scummvm-rg350-9f93e5bb81a54a98eb7957209662f152e2962679.tar.bz2 scummvm-rg350-9f93e5bb81a54a98eb7957209662f152e2962679.zip | |
Renamed various container isEmpty() methods to empty() to match STL conventions
svn-id: r21472
Diffstat (limited to 'common')
| -rw-r--r-- | common/array.h | 2 | ||||
| -rw-r--r-- | common/assocarray.h | 11 | ||||
| -rw-r--r-- | common/config-file.cpp | 10 | ||||
| -rw-r--r-- | common/config-manager.cpp | 38 | ||||
| -rw-r--r-- | common/list.h | 2 | ||||
| -rw-r--r-- | common/map.h | 2 | ||||
| -rw-r--r-- | common/stack.h | 2 | ||||
| -rw-r--r-- | common/str.h | 2 | ||||
| -rw-r--r-- | common/util.cpp | 6 |
9 files changed, 41 insertions, 34 deletions
diff --git a/common/array.h b/common/array.h index ec4ea818d0..6493a9bda7 100644 --- a/common/array.h +++ b/common/array.h @@ -130,7 +130,7 @@ public: _capacity = 0; } - bool isEmpty() const { + bool empty() const { return (_size == 0); } diff --git a/common/assocarray.h b/common/assocarray.h index 0e10ea7f4f..8505f48c19 100644 --- a/common/assocarray.h +++ b/common/assocarray.h @@ -140,9 +140,16 @@ public: // even allow in-place modifications of Key *new_all_keys(void) const; Val *new_all_values(void) const; + //const_iterator begin() const + //const_iterator end() const - - // TODO: There is no "remove(key)" method yet. + // TODO: There is no "remove" method yet. + //void remove(const Key &key); + + + bool empty() const { + return (_nele == 0); + } }; //------------------------------------------------------- diff --git a/common/config-file.cpp b/common/config-file.cpp index cb770f625e..568b5f554f 100644 --- a/common/config-file.cpp +++ b/common/config-file.cpp @@ -122,7 +122,7 @@ bool ConfigFile::loadFromStream(SeekableReadStream &stream) { *p = 0; // Previous section is finished now, store it. - if (!section.name.isEmpty()) + if (!section.name.empty()) _sections.push_back(section); section.name = buf + 1; @@ -140,7 +140,7 @@ bool ConfigFile::loadFromStream(SeekableReadStream &stream) { continue; // If no section has been set, this config file is invalid! - if (section.name.isEmpty()) { + if (section.name.empty()) { error("Config file buggy: Key/value pair found outside a section in line %d", lineno); } @@ -162,7 +162,7 @@ bool ConfigFile::loadFromStream(SeekableReadStream &stream) { } // Save last section - if (!section.name.isEmpty()) + if (!section.name.empty()) _sections.push_back(section); return (!stream.ioFailed() || stream.eos()); @@ -179,7 +179,7 @@ bool ConfigFile::saveToFile(const String &filename) { bool ConfigFile::saveToStream(WriteStream &stream) { for (List<Section>::iterator i = _sections.begin(); i != _sections.end(); ++i) { // Write out the section comment, if any - if (! i->comment.isEmpty()) { + if (! i->comment.empty()) { stream.writeString(i->comment); } @@ -192,7 +192,7 @@ bool ConfigFile::saveToStream(WriteStream &stream) { // Write out the key/value pairs for (List<KeyValue>::iterator kv = i->keys.begin(); kv != i->keys.end(); ++kv) { // Write out the comment, if any - if (! kv->comment.isEmpty()) { + if (! kv->comment.empty()) { stream.writeString(kv->comment); } // Write out the key/value pair diff --git a/common/config-manager.cpp b/common/config-manager.cpp index ee49a4babf..17f7d3bd62 100644 --- a/common/config-manager.cpp +++ b/common/config-manager.cpp @@ -198,7 +198,7 @@ void ConfigManager::loadFile(const String &filename) { continue; // If no domain has been set, this config file is invalid! - if (domain.isEmpty()) { + if (domain.empty()) { error("Config file buggy: Key/value pair found outside a domain in line %d", lineno); } @@ -265,14 +265,14 @@ void ConfigManager::flushToDisk() { } void ConfigManager::writeDomain(FILE *file, const String &name, const Domain &domain) { - if (domain.isEmpty()) + if (domain.empty()) return; // Don't bother writing empty domains. String comment; // Write domain comment (if any) comment = domain.getDomainComment(); - if (!comment.isEmpty()) + if (!comment.empty()) fprintf(file, "%s", comment.c_str()); // Write domain start @@ -282,7 +282,7 @@ void ConfigManager::writeDomain(FILE *file, const String &name, const Domain &do Domain::const_iterator x; for (x = domain.begin(); x != domain.end(); ++x) { const String &value = x->_value; - if (!value.isEmpty()) { + if (!value.empty()) { // Write comment (if any) if (domain.hasKVComment(x->_key)) { comment = domain.getKVComment(x->_key); @@ -308,7 +308,7 @@ bool ConfigManager::hasKey(const String &key) const { if (_transientDomain.contains(key)) return true; - if (!_activeDomain.isEmpty() && _gameDomains[_activeDomain].contains(key)) + if (!_activeDomain.empty() && _gameDomains[_activeDomain].contains(key)) return true; DomainMap::const_iterator iter; @@ -321,7 +321,7 @@ bool ConfigManager::hasKey(const String &key) const { } bool ConfigManager::hasKey(const String &key, const String &dom) const { - assert(!dom.isEmpty()); + assert(!dom.empty()); assert(isValidDomainName(dom)); if (dom == kTransientDomain) @@ -335,7 +335,7 @@ bool ConfigManager::hasKey(const String &key, const String &dom) const { } void ConfigManager::removeKey(const String &key, const String &dom) { - assert(!dom.isEmpty()); + assert(!dom.empty()); assert(isValidDomainName(dom)); if (dom == kTransientDomain) @@ -361,12 +361,12 @@ const String & ConfigManager::get(const String &key, const String &domain) const // 3) All global domains // 4) The defaults - if ((domain.isEmpty() || domain == kTransientDomain) && _transientDomain.contains(key)) + if ((domain.empty() || domain == kTransientDomain) && _transientDomain.contains(key)) return _transientDomain[key]; - const String &dom = domain.isEmpty() ? _activeDomain : domain; + const String &dom = domain.empty() ? _activeDomain : domain; - if (!dom.isEmpty() && _gameDomains.contains(dom) && _gameDomains[dom].contains(key)) + if (!dom.empty() && _gameDomains.contains(dom) && _gameDomains[dom].contains(key)) return _gameDomains[dom][key]; DomainMap::const_iterator iter; @@ -385,7 +385,7 @@ int ConfigManager::getInt(const String &key, const String &dom) const { // For now, be tolerant against missing config keys. Strictly spoken, it is // a bug in the calling code to retrieve an int for a key which isn't even // present... and a default value of 0 seems rather arbitrary. - if (value.isEmpty()) + if (value.empty()) return 0; int ivalue = (int)strtol(value.c_str(), &errpos, 10); @@ -412,11 +412,11 @@ bool ConfigManager::getBool(const String &key, const String &dom) const { void ConfigManager::set(const String &key, const String &value, const String &dom) { assert(isValidDomainName(dom)); - if (dom.isEmpty()) { + if (dom.empty()) { // Remove the transient domain value _transientDomain.remove(key); - if (_activeDomain.isEmpty()) + if (_activeDomain.empty()) _globalDomains[kApplicationDomain][key] = value; else _gameDomains[_activeDomain][key] = value; @@ -428,7 +428,7 @@ void ConfigManager::set(const String &key, const String &value, const String &do else { if (_globalDomains.contains(dom)) { _globalDomains[dom][key] = value; - if (_activeDomain.isEmpty() || !_gameDomains[_activeDomain].contains(key)) + if (_activeDomain.empty() || !_gameDomains[_activeDomain].contains(key)) _transientDomain.remove(key); } else { _gameDomains[dom][key] = value; @@ -480,14 +480,14 @@ void ConfigManager::registerDefault(const String &key, bool value) { void ConfigManager::setActiveDomain(const String &domain) { - assert(!domain.isEmpty()); + assert(!domain.empty()); assert(isValidDomainName(domain)); _activeDomain = domain; _gameDomains.addKey(domain); } void ConfigManager::removeGameDomain(const String &domain) { - assert(!domain.isEmpty()); + assert(!domain.empty()); assert(isValidDomainName(domain)); _gameDomains.remove(domain); } @@ -496,8 +496,8 @@ void ConfigManager::renameGameDomain(const String &oldName, const String &newNam if (oldName == newName) return; - assert(!oldName.isEmpty()); - assert(!newName.isEmpty()); + assert(!oldName.empty()); + assert(!newName.empty()); assert(isValidDomainName(oldName)); assert(isValidDomainName(newName)); @@ -507,7 +507,7 @@ void ConfigManager::renameGameDomain(const String &oldName, const String &newNam } bool ConfigManager::hasGameDomain(const String &domain) const { - assert(!domain.isEmpty()); + assert(!domain.empty()); return isValidDomainName(domain) && _gameDomains.contains(domain); } diff --git a/common/list.h b/common/list.h index 6d93636798..eac6b917f9 100644 --- a/common/list.h +++ b/common/list.h @@ -230,7 +230,7 @@ public: erase(begin(), end()); } - bool isEmpty() const { + bool empty() const { return (_anchor == _anchor->_next); } diff --git a/common/map.h b/common/map.h index 091e646eef..25cb94fb9a 100644 --- a/common/map.h +++ b/common/map.h @@ -150,7 +150,7 @@ public: _root = 0; } - bool isEmpty() const { + bool empty() const { return (_root == 0); } diff --git a/common/stack.h b/common/stack.h index 5e4e55035b..ce438b6174 100644 --- a/common/stack.h +++ b/common/stack.h @@ -83,7 +83,7 @@ public: Stack<T>() {} bool empty() const { - return _stack.isEmpty(); + return _stack.empty(); } void clear() { _stack.clear(); diff --git a/common/str.h b/common/str.h index 48fc2864d3..b345000164 100644 --- a/common/str.h +++ b/common/str.h @@ -71,7 +71,7 @@ public: const char *c_str() const { return _str ? _str : ""; } uint size() const { return _len; } - bool isEmpty() const { return (_len == 0); } + bool empty() const { return (_len == 0); } char lastChar() const { return (_len > 0) ? _str[_len-1] : 0; } char operator [](int idx) const { diff --git a/common/util.cpp b/common/util.cpp index fc01565582..e032601857 100644 --- a/common/util.cpp +++ b/common/util.cpp @@ -131,7 +131,7 @@ const LanguageDescription g_languages[] = { }; Language parseLanguage(const String &str) { - if (str.isEmpty()) + if (str.empty()) return UNK_LANG; const char *s = str.c_str(); @@ -189,7 +189,7 @@ const PlatformDescription g_platforms[] = { }; Platform parsePlatform(const String &str) { - if (str.isEmpty()) + if (str.empty()) return kPlatformUnknown; const char *s = str.c_str(); @@ -245,7 +245,7 @@ const RenderModeDescription g_renderModes[] = { }; RenderMode parseRenderMode(const String &str) { - if (str.isEmpty()) + if (str.empty()) return kRenderDefault; const char *s = str.c_str(); |
