|
|
|
@ -205,13 +205,13 @@ namespace Exiv2 {
|
|
|
|
|
Slice<byte*> makeSlice(DataBuf& buf, size_t begin, size_t end)
|
|
|
|
|
{
|
|
|
|
|
checkDataBufBounds(buf, end);
|
|
|
|
|
return Slice<byte*>(buf.pData_, begin, end);
|
|
|
|
|
return {buf.pData_, begin, end};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Slice<const byte*> makeSlice(const DataBuf& buf, size_t begin, size_t end)
|
|
|
|
|
{
|
|
|
|
|
checkDataBufBounds(buf, end);
|
|
|
|
|
return Slice<const byte*>(buf.pData_, begin, end);
|
|
|
|
|
return {buf.pData_, begin, end};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::ostream& operator<<(std::ostream& os, const Rational& r)
|
|
|
|
@ -673,13 +673,15 @@ namespace Exiv2 {
|
|
|
|
|
if (ok) return ret;
|
|
|
|
|
|
|
|
|
|
long l = stringTo<long>(s, ok);
|
|
|
|
|
if (ok) return Rational(l, 1);
|
|
|
|
|
if (ok)
|
|
|
|
|
return {l, 1};
|
|
|
|
|
|
|
|
|
|
float f = stringTo<float>(s, ok);
|
|
|
|
|
if (ok) return floatToRationalCast(f);
|
|
|
|
|
|
|
|
|
|
bool b = stringTo<bool>(s, ok);
|
|
|
|
|
if (ok) return b ? Rational(1, 1) : Rational(0, 1);
|
|
|
|
|
if (ok)
|
|
|
|
|
return {b ? 1 : 0, 1};
|
|
|
|
|
|
|
|
|
|
// everything failed, return from stringTo<Rational> is probably the best fit
|
|
|
|
|
return ret;
|
|
|
|
@ -692,7 +694,7 @@ namespace Exiv2 {
|
|
|
|
|
#else
|
|
|
|
|
if (!std::isfinite(f)) {
|
|
|
|
|
#endif
|
|
|
|
|
return Rational(f > 0 ? 1 : -1, 0);
|
|
|
|
|
return {f > 0 ? 1 : -1, 0};
|
|
|
|
|
}
|
|
|
|
|
// Beware: primitive conversion algorithm
|
|
|
|
|
int32_t den = 1000000;
|
|
|
|
@ -710,7 +712,7 @@ namespace Exiv2 {
|
|
|
|
|
const int32_t nom = static_cast<int32_t>(f * den + rnd);
|
|
|
|
|
const int32_t g = gcd(nom, den);
|
|
|
|
|
|
|
|
|
|
return Rational(nom / g, den / g);
|
|
|
|
|
return {nom / g, den / g};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Exiv2
|
|
|
|
|