2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-09-05 08:25:16 +00:00

[2312] Use common read/write functions to store values in a buffer.

This commit is contained in:
Marcin Siodelski
2012-11-26 15:53:20 +01:00
parent f3da5ed9ef
commit 7c73dd5e84
4 changed files with 52 additions and 124 deletions

View File

@@ -104,24 +104,7 @@ public:
<< "returned by the readInteger function.");
}
assert(buffers_[index].size() == OptionDataTypeTraits<T>::len);
T value;
switch (OptionDataTypeTraits<T>::len) {
case 1:
value = *(buffers_[index].begin());
break;
case 2:
value = isc::util::readUint16(&(*buffers_[index].begin()));
break;
case 4:
value = isc::util::readUint32(&(*buffers_[index].begin()));
break;
default:
// This should not happen because we made checks on data types
// but it does not hurt to keep throw statement here.
isc_throw(isc::dhcp::InvalidDataType,
"invalid size of the data type to be read as integer.");
}
return (value);
return (OptionDataTypeUtil::readInt<T>(buffers_[index]));
}
void readString(const uint32_t index, std::string& value) const;