BIND 10 trac2786, updated. e817fc7e97fff519a1e6b7a0ef56fd966a274039 [2786] Use parent class functions to access and modify data in OptionCustom
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri May 17 12:37:09 UTC 2013
The branch, trac2786 has been updated
via e817fc7e97fff519a1e6b7a0ef56fd966a274039 (commit)
from e0d3a70defab35a0dd3f1beffc3495b8965883d6 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit e817fc7e97fff519a1e6b7a0ef56fd966a274039
Author: Marcin Siodelski <marcin at isc.org>
Date: Fri May 17 14:36:45 2013 +0200
[2786] Use parent class functions to access and modify data in OptionCustom
-----------------------------------------------------------------------
Summary of changes:
src/lib/dhcp/option_custom.cc | 28 +++++++++++---------------
src/lib/dhcp/option_custom.h | 9 +++++++--
src/lib/dhcp/tests/option_custom_unittest.cc | 4 ++--
3 files changed, 21 insertions(+), 20 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/dhcp/option_custom.cc b/src/lib/dhcp/option_custom.cc
index ee59096..12145fc 100644
--- a/src/lib/dhcp/option_custom.cc
+++ b/src/lib/dhcp/option_custom.cc
@@ -28,20 +28,20 @@ OptionCustom::OptionCustom(const OptionDefinition& def,
}
OptionCustom::OptionCustom(const OptionDefinition& def,
- Universe u,
- const OptionBuffer& data)
+ Universe u,
+ const OptionBuffer& data)
: Option(u, def.getCode(), data.begin(), data.end()),
definition_(def) {
- createBuffers(data_);
+ createBuffers(getData());
}
OptionCustom::OptionCustom(const OptionDefinition& def,
- Universe u,
- OptionBufferConstIter first,
- OptionBufferConstIter last)
+ Universe u,
+ OptionBufferConstIter first,
+ OptionBufferConstIter last)
: Option(u, def.getCode(), first, last),
definition_(def) {
- createBuffers(data_);
+ createBuffers(getData());
}
void
@@ -507,9 +507,7 @@ OptionCustom::writeString(const std::string& text, const uint32_t index) {
void
OptionCustom::unpack(OptionBufferConstIter begin,
OptionBufferConstIter end) {
- data_ = OptionBuffer(begin, end);
- // Chop the buffer stored in data_ into set of sub buffers.
- createBuffers(data_);
+ initialize(begin, end);
}
uint16_t
@@ -533,15 +531,13 @@ OptionCustom::len() {
return (length);
}
-void OptionCustom::setData(const OptionBufferConstIter first,
- const OptionBufferConstIter last) {
- // We will copy entire option buffer, so we have to resize data_.
- data_.resize(std::distance(first, last));
- std::copy(first, last, data_.begin());
+void OptionCustom::initialize(const OptionBufferConstIter first,
+ const OptionBufferConstIter last) {
+ setData(first, last);
// Chop the data_ buffer into set of buffers that represent
// option fields data.
- createBuffers(data_);
+ createBuffers(getData());
}
std::string OptionCustom::toText(int indent) {
diff --git a/src/lib/dhcp/option_custom.h b/src/lib/dhcp/option_custom.h
index 5766cb4..e0314ae 100644
--- a/src/lib/dhcp/option_custom.h
+++ b/src/lib/dhcp/option_custom.h
@@ -280,8 +280,8 @@ public:
///
/// @param first iterator pointing to beginning of buffer to copy.
/// @param last iterator pointing to end of buffer to copy.
- void setData(const OptionBufferConstIter first,
- const OptionBufferConstIter last);
+ void initialize(const OptionBufferConstIter first,
+ const OptionBufferConstIter last);
private:
@@ -336,6 +336,11 @@ private:
std::string dataFieldToText(const OptionDataType data_type,
const uint32_t index) const;
+ /// Make this function private as we don't want it to be invoked
+ /// on OptionCustom object. We rather want that initialize to
+ /// be called instead.
+ using Option::setData;
+
/// Option definition used to create an option.
OptionDefinition definition_;
diff --git a/src/lib/dhcp/tests/option_custom_unittest.cc b/src/lib/dhcp/tests/option_custom_unittest.cc
index 2a9f771..c04bbc2 100644
--- a/src/lib/dhcp/tests/option_custom_unittest.cc
+++ b/src/lib/dhcp/tests/option_custom_unittest.cc
@@ -1324,7 +1324,7 @@ TEST_F(OptionCustomTest, unpack) {
// The purpose of this test is to verify that new data can be set for
// a custom option.
-TEST_F(OptionCustomTest, setData) {
+TEST_F(OptionCustomTest, initialize) {
OptionDefinition opt_def("OPTION_FOO", 1000, "ipv6-address", true);
// Initialize reference data.
@@ -1370,7 +1370,7 @@ TEST_F(OptionCustomTest, setData) {
}
// Replace the option data.
- ASSERT_NO_THROW(option->setData(buf.begin(), buf.end()));
+ ASSERT_NO_THROW(option->initialize(buf.begin(), buf.end()));
// Now we should have only 2 data fields.
ASSERT_EQ(2, option->getDataFieldsNum());
More information about the bind10-changes
mailing list