BIND 10 trac2786, updated. e0d3a70defab35a0dd3f1beffc3495b8965883d6 [2786] Changes as a result of the second review.
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri May 17 11:45:41 UTC 2013
The branch, trac2786 has been updated
via e0d3a70defab35a0dd3f1beffc3495b8965883d6 (commit)
from ee886b45eb503cf048abf8416ce7b37430f6fb25 (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 e0d3a70defab35a0dd3f1beffc3495b8965883d6
Author: Marcin Siodelski <marcin at isc.org>
Date: Fri May 17 13:45:32 2013 +0200
[2786] Changes as a result of the second review.
-----------------------------------------------------------------------
Summary of changes:
src/lib/dhcp/option.cc | 11 ++---------
src/lib/dhcp/option.h | 9 +++++++--
src/lib/dhcp/option_string.cc | 12 +++++++-----
3 files changed, 16 insertions(+), 16 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/dhcp/option.cc b/src/lib/dhcp/option.cc
index e06b163..3889ed2 100644
--- a/src/lib/dhcp/option.cc
+++ b/src/lib/dhcp/option.cc
@@ -55,7 +55,7 @@ Option::Option(Universe u, uint16_t type, const OptionBuffer& data)
Option::Option(Universe u, uint16_t type, OptionBufferConstIter first,
OptionBufferConstIter last)
- :universe_(u), type_(type), data_(OptionBuffer(first,last)) {
+ :universe_(u), type_(type), data_(first, last) {
check();
}
@@ -121,7 +121,7 @@ Option::packOptions(isc::util::OutputBuffer& buf) {
void Option::unpack(OptionBufferConstIter begin,
OptionBufferConstIter end) {
- data_ = OptionBuffer(begin, end);
+ setData(begin, end);
}
void
@@ -274,13 +274,6 @@ void Option::setUint32(uint32_t value) {
writeUint32(value, &data_[0]);
}
-void Option::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());
-}
-
bool Option::equal(const OptionPtr& other) const {
return ( (getType() == other->getType()) &&
(getData() == other->getData()) );
diff --git a/src/lib/dhcp/option.h b/src/lib/dhcp/option.h
index 28e65a9..b42d458 100644
--- a/src/lib/dhcp/option.h
+++ b/src/lib/dhcp/option.h
@@ -282,8 +282,13 @@ 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);
+ ///
+ /// @tparam InputIterator type of the iterator representing the
+ /// limits of the buffer to be assigned to a data_ buffer.
+ template<typename InputIterator>
+ void setData(InputIterator first, InputIterator last) {
+ data_.assign(first, last);
+ }
/// just to force that every option has virtual dtor
virtual ~Option();
diff --git a/src/lib/dhcp/option_string.cc b/src/lib/dhcp/option_string.cc
index 4108b91..6a8001a 100644
--- a/src/lib/dhcp/option_string.cc
+++ b/src/lib/dhcp/option_string.cc
@@ -36,7 +36,8 @@ OptionString::OptionString(const Option::Universe u, const uint16_t type,
std::string
OptionString::getValue() const {
- return (std::string(data_.begin(), data_.end()));
+ const OptionBuffer& data = getData();
+ return (std::string(data.begin(), data.end()));
}
void
@@ -49,13 +50,13 @@ OptionString::setValue(const std::string& value) {
<< getType() << "' must not be empty");
}
- data_.assign(value.begin(), value.end());
+ setData(value.begin(), value.end());
}
uint16_t
OptionString::len() {
- return (getHeaderLen() + data_.size());
+ return (getHeaderLen() + getData().size());
}
void
@@ -63,7 +64,8 @@ OptionString::pack(isc::util::OutputBuffer& buf) {
// Pack option header.
packHeader(buf);
// Pack data.
- buf.writeData(&data_[0], data_.size());
+ const OptionBuffer& data = getData();
+ buf.writeData(&data[0], data.size());
// That's it. We don't pack any sub-options here, because this option
// must not contain sub-options.
@@ -77,7 +79,7 @@ OptionString::unpack(OptionBufferConstIter begin,
<< getType() << "' holding string value"
<< " - empty value is not accepted");
}
- data_.assign(begin, end);
+ setData(begin, end);
}
} // end of isc::dhcp namespace
More information about the bind10-changes
mailing list