diff options
-rw-r--r-- | common/config-file.cpp | 10 | ||||
-rw-r--r-- | common/map.h | 19 |
2 files changed, 16 insertions, 13 deletions
diff --git a/common/config-file.cpp b/common/config-file.cpp index 9a45b002b5..4b66e70981 100644 --- a/common/config-file.cpp +++ b/common/config-file.cpp @@ -164,12 +164,12 @@ void Config::flush() const { if (!(cfg_file = fopen(filename.c_str(), "w"))) { debug(1, "Unable to write configuration file: %s.\n", filename.c_str()); } else { - DomainMap::Iterator d; + DomainMap::ConstIterator d; for (d = domains.begin(); d != domains.end(); ++d) { fprintf(cfg_file, "[%s]\n", d->_key.c_str()); const StringMap &data = d->_value; - StringMap::Iterator x; + StringMap::ConstIterator x; for (x = data.begin(); x != data.end(); ++x) { const String &value = x->_value; if (!value.isEmpty()) @@ -209,7 +209,7 @@ void Config::set_filename(const String &f) { } void Config::merge_config(const Config &c) { - DomainMap::Iterator d, end(c.domains.end()); + DomainMap::ConstIterator d, end(c.domains.end()); for (d = c.domains.begin(); d != end; ++d) { domains[d->_key].merge(d->_value); } @@ -221,7 +221,7 @@ void Config::set_writing(bool w) { const int Config::count_domains() { int count = 0; - DomainMap::Iterator d, end(domains.end()); + DomainMap::ConstIterator d, end(domains.end()); for (d = domains.begin(); d != end; ++d) count++; @@ -230,7 +230,7 @@ const int Config::count_domains() { Common::StringList Config::get_domains() { StringList domainNames; - DomainMap::Iterator d, end(domains.end()); + DomainMap::ConstIterator d, end(domains.end()); for (d = domains.begin(); d != end; ++d) { domainNames.push_back(d->_key); } diff --git a/common/map.h b/common/map.h index 8fde5cd693..b043ff01ad 100644 --- a/common/map.h +++ b/common/map.h @@ -61,16 +61,19 @@ protected: } public: - class Iterator { + class ConstIterator { + friend class Map<Key, Value>; protected: Node *_node; + ConstIterator(Node *node) : _node(node) {} public: - Iterator(Node *node = 0) : _node(node) {} + ConstIterator() : _node(0) {} + Node &operator *() { assert(_node != 0); return *_node; } const Node &operator *() const { assert(_node != 0); return *_node; } const Node *operator->() const { assert(_node != 0); return _node; } - bool operator !=(const Iterator &iter) const { return _node != iter._node; } + bool operator !=(const ConstIterator &iter) const { return _node != iter._node; } void operator ++() { if (!_node) return; @@ -188,23 +191,23 @@ public: // different walk order (infix comes to mind). if (map.isEmpty()) return; - Iterator x(map.begin()), e(map.end()); + ConstIterator x(map.begin()), e(map.end()); for (; x != e; ++x) { (*this)[x->_key] = x->_value; } } - Iterator begin() const { + ConstIterator begin() const { Node *node = _root; if (node) { while (node->_left) node = node->_left; } - return Iterator(node); + return ConstIterator(node); } - Iterator end() const { - return Iterator(); + ConstIterator end() const { + return ConstIterator(); } protected: |