Commit d28df7ed authored by Jan Möbius's avatar Jan Möbius

PLY: convert readInteger into a template

parent d91986fc
......@@ -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;
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;
std::cerr << "unsupported conversion type to integral: " << _type << std::endl;
break;
}
}
//------------------------------------------------------------------------------
......
This diff is collapsed.
......@@ -139,8 +139,8 @@ private:
void readValue(ValueType _type , std::istream& _in, short& _value) const;
void readValue(ValueType _type , std::istream& _in, signed char& _value) const;
void readInteger(ValueType _type, std::istream& _in, int& _value) const;
void readInteger(ValueType _type, std::istream& _in, unsigned int& _value) const;
template<typename T>
void readInteger(ValueType _type, std::istream& _in, T& _value) const;
/// Read unsupported properties in PLY file
void consume_input(std::istream& _in, int _count) const {
......@@ -223,7 +223,7 @@ private:
{
_in >> _value;
}
//read and assign custom properties with the given type. Also creates property, if not exist
template<bool binary, typename T, typename Handle>
void readCreateCustomProperty(std::istream& _in, BaseImporter& _bi, Handle _h, const std::string& _propName, const ValueType _valueType, const ValueType _listType) const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment