PLY: convert readInteger into a template
This commit is contained in:
@@ -971,8 +971,10 @@ void _PLYReader_::readValue(ValueType _type, std::istream& _in, int& _value) con
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
template<typename T>
|
||||
void _PLYReader_::readInteger(ValueType _type, std::istream& _in, T& _value) const {
|
||||
|
||||
void _PLYReader_::readInteger(ValueType _type, std::istream& _in, int& _value) const {
|
||||
static_assert(std::is_integral<T>::value, "Integral required.");
|
||||
|
||||
int32_t tmp_int32_t;
|
||||
uint32_t tmp_uint32_t;
|
||||
@@ -1020,71 +1022,12 @@ void _PLYReader_::readInteger(ValueType _type, std::istream& _in, int& _value) c
|
||||
default:
|
||||
|
||||
_value = 0;
|
||||
std::cerr << "unsupported conversion type to int: " << _type << std::endl;
|
||||
std::cerr << "unsupported conversion type to integral: " << _type << std::endl;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
void _PLYReader_::readInteger(ValueType _type, std::istream& _in, unsigned int& _value) const {
|
||||
|
||||
int32_t tmp_int32_t;
|
||||
uint32_t tmp_uint32_t;
|
||||
int8_t tmp_char;
|
||||
uint8_t tmp_uchar;
|
||||
|
||||
switch (_type) {
|
||||
|
||||
case ValueTypeUINT:
|
||||
|
||||
case ValueTypeUINT32:
|
||||
|
||||
restore(_in, tmp_uint32_t, options_.check(Options::MSB));
|
||||
_value = tmp_uint32_t;
|
||||
|
||||
break;
|
||||
|
||||
case ValueTypeINT:
|
||||
|
||||
case ValueTypeINT32:
|
||||
|
||||
restore(_in, tmp_int32_t, options_.check(Options::MSB));
|
||||
_value = tmp_int32_t;
|
||||
|
||||
break;
|
||||
|
||||
case ValueTypeUCHAR:
|
||||
|
||||
case ValueTypeUINT8:
|
||||
|
||||
restore(_in, tmp_uchar, options_.check(Options::MSB));
|
||||
_value = tmp_uchar;
|
||||
|
||||
break;
|
||||
|
||||
case ValueTypeCHAR:
|
||||
|
||||
case ValueTypeINT8:
|
||||
|
||||
restore(_in, tmp_char, options_.check(Options::MSB));
|
||||
_value = tmp_char;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
_value = 0;
|
||||
std::cerr << "unsupported conversion type to unsigned int: " << _type << std::endl;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user