mirror of
https://github.com/mfontanini/libtins
synced 2026-01-23 02:35:57 +01:00
Fix C++03 build issues on PDU option
This commit is contained in:
@@ -54,6 +54,8 @@ namespace Internals {
|
||||
namespace Converters {
|
||||
uint8_t convert(const uint8_t* ptr, uint32_t data_size, PDU::endian_type endian,
|
||||
type_to_type<uint8_t>);
|
||||
int8_t convert(const uint8_t* ptr, uint32_t data_size, PDU::endian_type endian,
|
||||
type_to_type<int8_t>);
|
||||
uint16_t convert(const uint8_t* ptr, uint32_t data_size, PDU::endian_type endian,
|
||||
type_to_type<uint16_t>);
|
||||
uint32_t convert(const uint8_t* ptr, uint32_t data_size, PDU::endian_type endian,
|
||||
@@ -110,6 +112,12 @@ namespace Internals {
|
||||
PDUType::endianness, type);
|
||||
}
|
||||
|
||||
template <typename U, typename X, typename PDUType>
|
||||
static U do_convert(const PDUOption<X, PDUType>& opt, type_to_type<int8_t> type) {
|
||||
return Converters::convert(opt.data_ptr(), opt.data_size(),
|
||||
PDUType::endianness, type);
|
||||
}
|
||||
|
||||
template <typename U, typename X, typename PDUType>
|
||||
static U do_convert(const PDUOption<X, PDUType>& opt, type_to_type<uint16_t> type) {
|
||||
return Converters::convert(opt.data_ptr(), opt.data_size(),
|
||||
|
||||
@@ -81,11 +81,10 @@ vector<T> convert_vector(const uint8_t* u8_ptr, uint32_t data_size, PDU::endian_
|
||||
return output;
|
||||
}
|
||||
|
||||
template<typename T, typename U,
|
||||
typename = typename enable_if<is_unsigned_integral<T>::value &&
|
||||
is_unsigned_integral<U>::value>::type>
|
||||
vector<std::pair<T, U> > convert_vector(const uint8_t* ptr, uint32_t data_size,
|
||||
PDU::endian_type endian) {
|
||||
template<typename T, typename U>
|
||||
typename enable_if<is_unsigned_integral<T>::value && is_unsigned_integral<U>::value,
|
||||
vector<std::pair<T, U> > >::type
|
||||
convert_vector(const uint8_t* ptr, uint32_t data_size, PDU::endian_type endian) {
|
||||
if (data_size % (sizeof(T) + sizeof(U)) != 0) {
|
||||
throw malformed_option();
|
||||
}
|
||||
@@ -111,10 +110,10 @@ vector<std::pair<T, U> > convert_vector(const uint8_t* ptr, uint32_t data_size,
|
||||
return output;
|
||||
}
|
||||
|
||||
template<typename T, typename U,
|
||||
typename = typename enable_if<is_unsigned_integral<T>::value &&
|
||||
is_unsigned_integral<U>::value>::type>
|
||||
std::pair<T, U> convert_pair(const uint8_t* ptr, uint32_t data_size, PDU::endian_type endian) {
|
||||
template<typename T, typename U>
|
||||
typename enable_if<is_unsigned_integral<T>::value && is_unsigned_integral<U>::value,
|
||||
std::pair<T, U> >::type
|
||||
convert_pair(const uint8_t* ptr, uint32_t data_size, PDU::endian_type endian) {
|
||||
if (data_size != sizeof(T) + sizeof(U)) {
|
||||
throw malformed_option();
|
||||
}
|
||||
@@ -139,6 +138,13 @@ uint8_t convert(const uint8_t* ptr, uint32_t data_size, PDU::endian_type, type_t
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
int8_t convert(const uint8_t* ptr, uint32_t data_size, PDU::endian_type, type_to_type<int8_t>) {
|
||||
if (data_size != 1) {
|
||||
throw malformed_option();
|
||||
}
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
uint16_t convert(const uint8_t* ptr, uint32_t data_size, PDU::endian_type endian,
|
||||
type_to_type<uint16_t>) {
|
||||
return convert_to_integral<uint16_t>(ptr, data_size, endian);
|
||||
@@ -250,7 +256,7 @@ vector<IPv6Address> convert(const uint8_t* ptr, uint32_t data_size, PDU::endian_
|
||||
return output;
|
||||
}
|
||||
|
||||
vector<pair<uint8_t, uint8_t>> convert(const uint8_t* ptr, uint32_t data_size,
|
||||
vector<pair<uint8_t, uint8_t> > convert(const uint8_t* ptr, uint32_t data_size,
|
||||
PDU::endian_type endian,
|
||||
type_to_type<vector<pair<uint8_t, uint8_t> > >) {
|
||||
return convert_vector<uint8_t, uint8_t>(ptr, data_size, endian);
|
||||
|
||||
Reference in New Issue
Block a user