diff options
| author | 2017-06-03 07:07:37 -0400 | |
|---|---|---|
| committer | 2019-07-07 13:55:17 +0700 | |
| commit | 7d6b42c9e738c97f32023d78313ec390806a9731 (patch) | |
| tree | 6c41c2b7c443e096ebb6d3a1b1eb5856a2eea0c0 | |
| parent | ec957fb8253ffbced690fb5bcb1743f015ab0815 (diff) | |
| download | libplist-7d6b42c9e738c97f32023d78313ec390806a9731.tar.gz libplist-7d6b42c9e738c97f32023d78313ec390806a9731.tar.bz2 | |
Add PList::Dictionary::const_iterator
... and const versions of three member functions, each returning const_iterator:
* Plist::Dictionary::Begin()
* PList::Dictionary::End()
* PList::Dictionary::Find()
| -rw-r--r-- | include/plist/Dictionary.h | 4 | ||||
| -rw-r--r-- | src/Dictionary.cpp | 15 |
2 files changed, 19 insertions, 0 deletions
diff --git a/include/plist/Dictionary.h b/include/plist/Dictionary.h index 7a29f14..71d40ac 100644 --- a/include/plist/Dictionary.h +++ b/include/plist/Dictionary.h | |||
| @@ -41,11 +41,15 @@ public : | |||
| 41 | Node* Clone() const; | 41 | Node* Clone() const; |
| 42 | 42 | ||
| 43 | typedef std::map<std::string,Node*>::iterator iterator; | 43 | typedef std::map<std::string,Node*>::iterator iterator; |
| 44 | typedef std::map<std::string,Node*>::const_iterator const_iterator; | ||
| 44 | 45 | ||
| 45 | Node* operator[](const std::string& key); | 46 | Node* operator[](const std::string& key); |
| 46 | iterator Begin(); | 47 | iterator Begin(); |
| 47 | iterator End(); | 48 | iterator End(); |
| 48 | iterator Find(const std::string& key); | 49 | iterator Find(const std::string& key); |
| 50 | const_iterator Begin() const; | ||
| 51 | const_iterator End() const; | ||
| 52 | const_iterator Find(const std::string& key) const; | ||
| 49 | iterator Set(const std::string& key, const Node* node); | 53 | iterator Set(const std::string& key, const Node* node); |
| 50 | iterator Set(const std::string& key, const Node& node); | 54 | iterator Set(const std::string& key, const Node& node); |
| 51 | iterator Insert(const std::string& key, Node* node) PLIST_WARN_DEPRECATED("use Set() instead"); | 55 | iterator Insert(const std::string& key, Node* node) PLIST_WARN_DEPRECATED("use Set() instead"); |
diff --git a/src/Dictionary.cpp b/src/Dictionary.cpp index 5e2e1c0..59908c6 100644 --- a/src/Dictionary.cpp +++ b/src/Dictionary.cpp | |||
| @@ -104,11 +104,26 @@ Dictionary::iterator Dictionary::End() | |||
| 104 | return _map.end(); | 104 | return _map.end(); |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | Dictionary::const_iterator Dictionary::Begin() const | ||
| 108 | { | ||
| 109 | return _map.begin(); | ||
| 110 | } | ||
| 111 | |||
| 112 | Dictionary::const_iterator Dictionary::End() const | ||
| 113 | { | ||
| 114 | return _map.end(); | ||
| 115 | } | ||
| 116 | |||
| 107 | Dictionary::iterator Dictionary::Find(const std::string& key) | 117 | Dictionary::iterator Dictionary::Find(const std::string& key) |
| 108 | { | 118 | { |
| 109 | return _map.find(key); | 119 | return _map.find(key); |
| 110 | } | 120 | } |
| 111 | 121 | ||
| 122 | Dictionary::const_iterator Dictionary::Find(const std::string& key) const | ||
| 123 | { | ||
| 124 | return _map.find(key); | ||
| 125 | } | ||
| 126 | |||
| 112 | Dictionary::iterator Dictionary::Set(const std::string& key, const Node* node) | 127 | Dictionary::iterator Dictionary::Set(const std::string& key, const Node* node) |
| 113 | { | 128 | { |
| 114 | if (node) | 129 | if (node) |
