@@ -282,47 +282,47 @@ ByteVector ByteVector::fromCString(const char *s, unsigned int length)
282282
283283ByteVector ByteVector::fromUInt (unsigned int value, bool mostSignificantByteFirst)
284284{
285- return fromNumber<unsigned int >(value, mostSignificantByteFirst);
285+ return fromNumber<uint32_t >(value, mostSignificantByteFirst);
286286}
287287
288288ByteVector ByteVector::fromShort (short value, bool mostSignificantByteFirst)
289289{
290- return fromNumber<unsigned short >(value, mostSignificantByteFirst);
290+ return fromNumber<uint16_t >(value, mostSignificantByteFirst);
291291}
292292
293293ByteVector ByteVector::fromUShort (unsigned short value, bool mostSignificantByteFirst)
294294{
295- return fromNumber<unsigned short >(value, mostSignificantByteFirst);
295+ return fromNumber<uint16_t >(value, mostSignificantByteFirst);
296296}
297297
298298ByteVector ByteVector::fromLongLong (long long value, bool mostSignificantByteFirst)
299299{
300- return fromNumber<unsigned long long >(value, mostSignificantByteFirst);
300+ return fromNumber<uint64_t >(value, mostSignificantByteFirst);
301301}
302302
303303ByteVector ByteVector::fromULongLong (unsigned long long value, bool mostSignificantByteFirst)
304304{
305- return fromNumber<unsigned long long >(value, mostSignificantByteFirst);
305+ return fromNumber<uint64_t >(value, mostSignificantByteFirst);
306306}
307307
308308ByteVector ByteVector::fromFloat32LE (float value)
309309{
310- return fromFloat<float , unsigned int , Utils::LittleEndian>(value);
310+ return fromFloat<float , uint32_t , Utils::LittleEndian>(value);
311311}
312312
313313ByteVector ByteVector::fromFloat32BE (float value)
314314{
315- return fromFloat<float , unsigned int , Utils::BigEndian>(value);
315+ return fromFloat<float , uint32_t , Utils::BigEndian>(value);
316316}
317317
318318ByteVector ByteVector::fromFloat64LE (double value)
319319{
320- return fromFloat<double , unsigned long long , Utils::LittleEndian>(value);
320+ return fromFloat<double , uint64_t , Utils::LittleEndian>(value);
321321}
322322
323323ByteVector ByteVector::fromFloat64BE (double value)
324324{
325- return fromFloat<double , unsigned long long , Utils::BigEndian>(value);
325+ return fromFloat<double , uint64_t , Utils::BigEndian>(value);
326326}
327327
328328// //////////////////////////////////////////////////////////////////////////////
@@ -656,79 +656,86 @@ bool ByteVector::isEmpty() const
656656 return d->length == 0 ;
657657}
658658
659+ // Sanity checks
660+ static_assert (sizeof (unsigned short ) == sizeof (uint16_t ), " unsigned short and uint16_t are different sizes" );
661+ static_assert (sizeof (unsigned int ) == sizeof (uint32_t ), " unsigned int and uint32_t are different sizes" );
662+ static_assert (sizeof (unsigned long long ) == sizeof (uint64_t ), " unsigned long long and uint64_t are different sizes" );
663+ static_assert (sizeof (float ) == sizeof (uint32_t ), " float and uint32_t are different sizes" );
664+ static_assert (sizeof (double ) == sizeof (uint64_t ), " double and uint64_t are different sizes" );
665+
659666unsigned int ByteVector::toUInt (bool mostSignificantByteFirst) const
660667{
661- return toNumber<unsigned int >(*this , 0 , mostSignificantByteFirst);
668+ return toNumber<uint32_t >(*this , 0 , mostSignificantByteFirst);
662669}
663670
664671unsigned int ByteVector::toUInt (unsigned int offset, bool mostSignificantByteFirst) const
665672{
666- return toNumber<unsigned int >(*this , offset, mostSignificantByteFirst);
673+ return toNumber<uint32_t >(*this , offset, mostSignificantByteFirst);
667674}
668675
669676unsigned int ByteVector::toUInt (unsigned int offset, unsigned int length, bool mostSignificantByteFirst) const
670677{
671- return toNumber<unsigned int >(*this , offset, length, mostSignificantByteFirst);
678+ return toNumber<uint32_t >(*this , offset, length, mostSignificantByteFirst);
672679}
673680
674681short ByteVector::toShort (bool mostSignificantByteFirst) const
675682{
676- return toNumber<unsigned short >(*this , 0 , mostSignificantByteFirst);
683+ return toNumber<uint16_t >(*this , 0 , mostSignificantByteFirst);
677684}
678685
679686short ByteVector::toShort (unsigned int offset, bool mostSignificantByteFirst) const
680687{
681- return toNumber<unsigned short >(*this , offset, mostSignificantByteFirst);
688+ return toNumber<uint16_t >(*this , offset, mostSignificantByteFirst);
682689}
683690
684691unsigned short ByteVector::toUShort (bool mostSignificantByteFirst) const
685692{
686- return toNumber<unsigned short >(*this , 0 , mostSignificantByteFirst);
693+ return toNumber<uint16_t >(*this , 0 , mostSignificantByteFirst);
687694}
688695
689696unsigned short ByteVector::toUShort (unsigned int offset, bool mostSignificantByteFirst) const
690697{
691- return toNumber<unsigned short >(*this , offset, mostSignificantByteFirst);
698+ return toNumber<uint16_t >(*this , offset, mostSignificantByteFirst);
692699}
693700
694701long long ByteVector::toLongLong (bool mostSignificantByteFirst) const
695702{
696- return toNumber<unsigned long long >(*this , 0 , mostSignificantByteFirst);
703+ return toNumber<uint64_t >(*this , 0 , mostSignificantByteFirst);
697704}
698705
699706long long ByteVector::toLongLong (unsigned int offset, bool mostSignificantByteFirst) const
700707{
701- return toNumber<unsigned long long >(*this , offset, mostSignificantByteFirst);
708+ return toNumber<uint64_t >(*this , offset, mostSignificantByteFirst);
702709}
703710
704711unsigned long long ByteVector::toULongLong (bool mostSignificantByteFirst) const
705712{
706- return toNumber<unsigned long long >(*this , 0 , mostSignificantByteFirst);
713+ return toNumber<uint64_t >(*this , 0 , mostSignificantByteFirst);
707714}
708715
709716unsigned long long ByteVector::toULongLong (unsigned int offset, bool mostSignificantByteFirst) const
710717{
711- return toNumber<unsigned long long >(*this , offset, mostSignificantByteFirst);
718+ return toNumber<uint64_t >(*this , offset, mostSignificantByteFirst);
712719}
713720
714721float ByteVector::toFloat32LE (size_t offset) const
715722{
716- return toFloat<float , unsigned int , Utils::LittleEndian>(*this , offset);
723+ return toFloat<float , uint32_t , Utils::LittleEndian>(*this , offset);
717724}
718725
719726float ByteVector::toFloat32BE (size_t offset) const
720727{
721- return toFloat<float , unsigned int , Utils::BigEndian>(*this , offset);
728+ return toFloat<float , uint32_t , Utils::BigEndian>(*this , offset);
722729}
723730
724731double ByteVector::toFloat64LE (size_t offset) const
725732{
726- return toFloat<double , unsigned long long , Utils::LittleEndian>(*this , offset);
733+ return toFloat<double , uint64_t , Utils::LittleEndian>(*this , offset);
727734}
728735
729736double ByteVector::toFloat64BE (size_t offset) const
730737{
731- return toFloat<double , unsigned long long , Utils::BigEndian>(*this , offset);
738+ return toFloat<double , uint64_t , Utils::BigEndian>(*this , offset);
732739}
733740
734741long double ByteVector::toFloat80LE (size_t offset) const
0 commit comments