diff options
author | Jelte Jansen <jelte@isc.org> | 2010-06-15 14:38:55 +0200 |
---|---|---|
committer | Jelte Jansen <jelte@isc.org> | 2010-06-15 14:38:55 +0200 |
commit | ab6751e34fe7a492f5a0a37a7e4c7c74897e41e4 (patch) | |
tree | 3f120b087ae35752f1484e9fba9334e04fd781fe /src/lib/cc/data.h | |
parent | few doc updates (diff) | |
download | kea-ab6751e34fe7a492f5a0a37a7e4c7c74897e41e4.tar.xz kea-ab6751e34fe7a492f5a0a37a7e4c7c74897e41e4.zip |
empty constructors for lists and maps, and corresponding 'factory' functions Element::createList() and Element::createMap()
git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac172@2112 e5f2f494-b856-4b98-b285-d166d9295462
Diffstat (limited to 'src/lib/cc/data.h')
-rw-r--r-- | src/lib/cc/data.h | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/lib/cc/data.h b/src/lib/cc/data.h index a82cd89f5b..b37439eaba 100644 --- a/src/lib/cc/data.h +++ b/src/lib/cc/data.h @@ -272,9 +272,12 @@ public: static ElementPtr create(const std::string& s); // need both std:string and char *, since c++ will match // bool before std::string when you pass it a char * - static ElementPtr create(const char *s) { return create(std::string(s)); }; - static ElementPtr create(const std::vector<ElementPtr>& v); - static ElementPtr create(const std::map<std::string, ElementPtr>& m); + static ElementPtr create(const char *s) { return create(std::string(s)); }; + + /// \brief Creates an empty ListElement type ElementPtr. + static ElementPtr createList(); + /// \brief Creates an empty MapElement type ElementPtr. + static ElementPtr createMap(); //@} /// \name Compound factory functions @@ -404,7 +407,7 @@ class ListElement : public Element { std::vector<ElementPtr> l; public: - ListElement(std::vector<ElementPtr> v) : Element(list), l(v) {}; + ListElement() : Element(list), l(std::vector<ElementPtr>()) {}; const std::vector<ElementPtr>& listValue() { return l; } using Element::getValue; bool getValue(std::vector<ElementPtr>& t) { t = l; return true; }; @@ -426,7 +429,8 @@ class MapElement : public Element { std::map<std::string, ElementPtr> m; public: - MapElement(const std::map<std::string, ElementPtr>& v) : Element(map), m(v) {}; + MapElement() : Element(map), m(std::map<std::string, ElementPtr>()) {}; + // TODO: should we have direct iterators instead of exposing the std::map here? const std::map<std::string, ElementPtr>& mapValue() { return m; } using Element::getValue; bool getValue(std::map<std::string, ElementPtr>& t) { t = m; return true; }; @@ -435,7 +439,7 @@ public: using Element::get; ElementPtr get(const std::string& s) { if (contains(s)) { return m[s]; } else { return ElementPtr();} }; using Element::set; - void set(const std::string& s, ElementPtr p) { m[s] = p; }; + void set(const std::string& key, ElementPtr value); using Element::remove; void remove(const std::string& s) { m.erase(s); } bool contains(const std::string& s) { return m.find(s) != m.end(); } |