[geos-devel] [GEOS] #863: DEBUG_BYTEORDER_VALUES=1 does not build
GEOS
geos-trac at osgeo.org
Fri Mar 16 14:47:25 PDT 2018
#863: DEBUG_BYTEORDER_VALUES=1 does not build
-----------------------+---------------------------
Reporter: goatbar | Owner: geos-devel@…
Type: defect | Status: new
Priority: minor | Milestone: 3.6.3
Component: Default | Version: 3.6.2
Severity: Annoyance | Resolution:
Keywords: debugging |
-----------------------+---------------------------
Comment (by goatbar):
I think there is still more that can be done to improve the eof checks,
but here is what I ended up with after code review. I'll try to get the
tests I've been working on out in the autotest2 tree in the next few days.
I have more work to do for coverage.
{{{#!c++
namespace {
unsigned char ASCIIHexToUChar(char val)
{
switch ( val )
{
case '0' :
return 0;
case '1' :
return 1;
case '2' :
return 2;
case '3' :
return 3;
case '4' :
return 4;
case '5' :
return 5;
case '6' :
return 6;
case '7' :
return 7;
case '8' :
return 8;
case '9' :
return 9;
case 'A' :
case 'a' :
return 10;
case 'B' :
case 'b' :
return 11;
case 'C' :
case 'c' :
return 12;
case 'D' :
case 'd' :
return 13;
case 'E' :
case 'e' :
return 14;
case 'F' :
case 'f' :
return 15;
default:
throw ParseException("Invalid HEX char");
}
}
} // namespace
// Must be an even number of characters in the istream.
// Throws a ParseException if there are an odd number of characters.
Geometry *
WKBReader::readHEX(istream &is)
{
// setup input/output stream
stringstream os(ios_base::binary|ios_base::in|ios_base::out);
while( true )
{
const int input_high = is.get();
if (input_high == char_traits<char>::eof())
break;
const int input_low = is.get();
if (input_low == char_traits<char>::eof())
throw ParseException("Premature end of HEX
string");
const char high = static_cast<char>(input_high);
const char low = static_cast<char>(input_low);
const unsigned char result_high = ASCIIHexToUChar(high);
const unsigned char result_low = ASCIIHexToUChar(low);
const unsigned char value =
static_cast<char>((result_high<<4) + result_low);
#if DEBUG_HEX_READER
cout<<"HEX "<<high<<low<<" -> DEC "<<(int)value<<endl;
#endif
// write the value to the output stream
os << value;
}
// now call read to convert the geometry
return this->read(os);
}
}}}
--
Ticket URL: <https://trac.osgeo.org/geos/ticket/863#comment:1>
GEOS <http://trac.osgeo.org/geos>
GEOS (Geometry Engine - Open Source) is a C++ port of the Java Topology Suite (JTS).
More information about the geos-devel
mailing list