diff options
author | Kazunori Fujiwara <fujiwara@wide.ad.jp> | 2012-10-10 00:21:09 +0200 |
---|---|---|
committer | Mukund Sivaraman <muks@isc.org> | 2012-10-10 00:22:51 +0200 |
commit | 593b348cbb8207fca3e9d01620794cfe118455b2 (patch) | |
tree | e2d7966dfebdd944477ed38c9bd76bacac54ec69 /src/lib/cc/data.h | |
parent | [master] Set lockfile path for DHCP tests (diff) | |
download | kea-593b348cbb8207fca3e9d01620794cfe118455b2.tar.xz kea-593b348cbb8207fca3e9d01620794cfe118455b2.zip |
[2302] Fix bugs in Element class
Two bugs in src/lib/cc/data.h:
* Element::find() does not return value because its argument is not a
reference.
* getValue() member functions does not work for ConstElementPointer
because getValue() member functions are not specified as const.
Aharen found these bugs.
Diffstat (limited to 'src/lib/cc/data.h')
-rw-r--r-- | src/lib/cc/data.h | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/lib/cc/data.h b/src/lib/cc/data.h index 5c731e6b54..ef177ca988 100644 --- a/src/lib/cc/data.h +++ b/src/lib/cc/data.h @@ -152,12 +152,12 @@ public: /// data to the given reference and returning true /// //@{ - virtual bool getValue(long int& t); - virtual bool getValue(double& t); - virtual bool getValue(bool& t); - virtual bool getValue(std::string& t); - virtual bool getValue(std::vector<ConstElementPtr>& t); - virtual bool getValue(std::map<std::string, ConstElementPtr>& t); + virtual bool getValue(long int& t) const; + virtual bool getValue(double& t) const; + virtual bool getValue(bool& t) const; + virtual bool getValue(std::string& t) const; + virtual bool getValue(std::vector<ConstElementPtr>& t) const; + virtual bool getValue(std::map<std::string, ConstElementPtr>& t) const; //@} /// @@ -253,7 +253,7 @@ public: /// \param identifier The identifier of the element to find /// \param t Reference to store the resulting ElementPtr, if found. /// \return true if the element was found, false if not. - virtual bool find(const std::string& identifier, ConstElementPtr t) const; + virtual bool find(const std::string& identifier, ConstElementPtr& t) const; //@} @@ -378,7 +378,7 @@ public: IntElement(long int v) : Element(integer), i(v) { } long int intValue() const { return (i); } using Element::getValue; - bool getValue(long int& t) { t = i; return (true); } + bool getValue(long int& t) const { t = i; return (true); } using Element::setValue; bool setValue(const long int v) { i = v; return (true); } void toJSON(std::ostream& ss) const; @@ -392,7 +392,7 @@ public: DoubleElement(double v) : Element(real), d(v) {}; double doubleValue() const { return (d); } using Element::getValue; - bool getValue(double& t) { t = d; return (true); } + bool getValue(double& t) const { t = d; return (true); } using Element::setValue; bool setValue(const double v) { d = v; return (true); } void toJSON(std::ostream& ss) const; @@ -406,7 +406,7 @@ public: BoolElement(const bool v) : Element(boolean), b(v) {}; bool boolValue() const { return (b); } using Element::getValue; - bool getValue(bool& t) { t = b; return (true); } + bool getValue(bool& t) const { t = b; return (true); } using Element::setValue; bool setValue(const bool v) { b = v; return (true); } void toJSON(std::ostream& ss) const; @@ -427,7 +427,7 @@ public: StringElement(std::string v) : Element(string), s(v) {}; std::string stringValue() const { return (s); } using Element::getValue; - bool getValue(std::string& t) { t = s; return (true); } + bool getValue(std::string& t) const { t = s; return (true); } using Element::setValue; bool setValue(const std::string& v) { s = v; return (true); } void toJSON(std::ostream& ss) const; @@ -441,7 +441,7 @@ public: ListElement() : Element(list) {} const std::vector<ConstElementPtr>& listValue() const { return (l); } using Element::getValue; - bool getValue(std::vector<ConstElementPtr>& t) { + bool getValue(std::vector<ConstElementPtr>& t) const { t = l; return (true); } @@ -474,7 +474,7 @@ public: return (m); } using Element::getValue; - bool getValue(std::map<std::string, ConstElementPtr>& t) { + bool getValue(std::map<std::string, ConstElementPtr>& t) const { t = m; return (true); } @@ -507,7 +507,7 @@ public: // returns true if found, or false if not found (either because // it doesnt exist or one of the elements in the path is not // a MapElement) - bool find(const std::string& id, ConstElementPtr t) const; + bool find(const std::string& id, ConstElementPtr& t) const; bool equals(const Element& other) const; }; |