DRTVWR-418: Use U32 for int (and hex) of HttpStatus in 64-bit too.
Turns out that Monty didn't intend for the int-flavored representation of HttpStatus to expand to 64 bits even when unsigned long is that wide. So change the implicit conversion operator, and its uses, to U32 instead. That produces a consistent toHex() result for both 32-bit and 64-bit builds.master
parent
1df282efa1
commit
40fb9d3e58
|
|
@ -50,11 +50,12 @@ HttpStatus::type_enum_t EXT_CURL_EASY;
|
|||
HttpStatus::type_enum_t EXT_CURL_MULTI;
|
||||
HttpStatus::type_enum_t LLCORE;
|
||||
|
||||
HttpStatus::operator unsigned long() const
|
||||
HttpStatus::operator U32() const
|
||||
{
|
||||
static const int shift(sizeof(unsigned long) * 4);
|
||||
// Effectively, concatenate mType (high) with mStatus (low).
|
||||
static const int shift(sizeof(mDetails->mStatus) * 8);
|
||||
|
||||
unsigned long result(((unsigned long)mDetails->mType) << shift | (unsigned long)(int)mDetails->mStatus);
|
||||
U32 result(U32(mDetails->mType) << shift | U32((int)mDetails->mStatus));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -64,7 +65,7 @@ std::string HttpStatus::toHex() const
|
|||
std::ostringstream result;
|
||||
result.width(8);
|
||||
result.fill('0');
|
||||
result << std::hex << operator unsigned long();
|
||||
result << std::hex << operator U32();
|
||||
return result.str();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -382,10 +382,10 @@ struct HttpStatus
|
|||
/// creates an ambiguous second path to integer conversion
|
||||
/// which tends to find programming errors such as formatting
|
||||
/// the status to a stream (operator<<).
|
||||
operator unsigned long() const;
|
||||
unsigned long toULong() const
|
||||
operator U32() const;
|
||||
U32 toULong() const
|
||||
{
|
||||
return operator unsigned long();
|
||||
return operator U32();
|
||||
}
|
||||
|
||||
/// And to convert to a hex string.
|
||||
|
|
|
|||
|
|
@ -244,11 +244,7 @@ void HttpStatusTestObjectType::test<7>()
|
|||
HttpStatus status(404);
|
||||
std::string msg = status.toHex();
|
||||
// std::cout << "Result: " << msg << std::endl;
|
||||
#if ADDRESS_SIZE == 32
|
||||
ensure_equals(msg, "01940001");
|
||||
#else
|
||||
ensure_equals(msg, "19400000001");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue