[Zrouter-src] ZRouter.org: push to zconf++ zconf++/model.cc zconf++/model.h

zrouter-src at zrouter.org zrouter-src at zrouter.org
Wed Feb 22 15:07:35 UTC 2012


details:   /rev/f95e4d975a6c
changeset: 65:f95e4d975a6c
user:      "Nicolai Petri <nicolai at petri.dk>"
date:      Wed Feb 22 16:06:52 2012 +0100
description:
Add support for erase(idx|key);

diffstat:

 zconf++/model.cc |  8 ++++++++
 zconf++/model.h  |  2 ++
 2 files changed, 10 insertions(+), 0 deletions(-)

diffs (30 lines):

diff -r 15035caa0738 -r f95e4d975a6c zconf++/model.cc
--- a/zconf++/model.cc	Wed Feb 22 15:23:08 2012 +0100
+++ b/zconf++/model.cc	Wed Feb 22 16:06:52 2012 +0100
@@ -184,6 +184,14 @@
 				}
 				return false;
 			}
+			bool Leaf::erase(const std::string p_key) {
+				check_type_const(OBJECT_LEAF);
+				return (m_map.erase(p_key) > 0);
+			}
+			bool Leaf::erase(const int p_idx) {
+				check_type_const(ARRAY_LEAF);
+				return (m_array.erase(m_array.begin()+p_idx) != m_array.end());
+			}
 			LeafRef Leaf::parent() const
 			{
 				return *m_parent;
diff -r 15035caa0738 -r f95e4d975a6c zconf++/model.h
--- a/zconf++/model.h	Wed Feb 22 15:23:08 2012 +0100
+++ b/zconf++/model.h	Wed Feb 22 16:06:52 2012 +0100
@@ -106,6 +106,8 @@
 			const LeafType type() const;
 			bool contains(const std::string p_key);
 			bool contains(const int p_idx);
+			bool erase(const std::string p_key);
+			bool erase(const int p_idx);
 			bool containsValue(const int p_value);
 			LeafRef parent() const;
 			Leaf& operator[](const int p_idx);


More information about the Zrouter-src mailing list