Skip to content

Commit 59971d1

Browse files
committed
convert some ostreams to stringFormat
compilation issue was discovered and fixed. Signed-off-by: Rosen Penev <[email protected]>
1 parent 5089d9f commit 59971d1

File tree

1 file changed

+23
-62
lines changed

1 file changed

+23
-62
lines changed

src/tags_int.cpp

Lines changed: 23 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "canonmn_int.hpp"
1111
#include "casiomn_int.hpp"
1212
#include "fujimn_int.hpp"
13+
#include "image_int.hpp"
1314
#include "minoltamn_int.hpp"
1415
#include "nikonmn_int.hpp"
1516
#include "olympusmn_int.hpp"
@@ -2909,6 +2910,7 @@ std::ostream& print0x829a(std::ostream& os, const Value& value, const ExifData*)
29092910
if (value.typeId() != unsignedRational)
29102911
return os << "(" << value << ")";
29112912

2913+
using Exiv2::operator<<;
29122914
URational t = value.toRational();
29132915
if (t.first == 0 || t.second == 0) {
29142916
os << "(" << t << ")";
@@ -2925,18 +2927,10 @@ std::ostream& print0x829a(std::ostream& os, const Value& value, const ExifData*)
29252927
}
29262928

29272929
std::ostream& print0x829d(std::ostream& os, const Value& value, const ExifData*) {
2928-
std::ios::fmtflags f(os.flags());
29292930
Rational fnumber = value.toRational();
2930-
if (fnumber.second != 0) {
2931-
std::ostringstream oss;
2932-
oss.copyfmt(os);
2933-
os << "F" << std::setprecision(2) << static_cast<float>(fnumber.first) / fnumber.second;
2934-
os.copyfmt(oss);
2935-
} else {
2936-
os << "(" << value << ")";
2937-
}
2938-
os.flags(f);
2939-
return os;
2931+
if (fnumber.second != 0)
2932+
return os << stringFormat("F{:.2g}", static_cast<float>(fnumber.first) / fnumber.second);
2933+
return os << "(" << value << ")";
29402934
}
29412935

29422936
//! ExposureProgram, tag 0x8822
@@ -3000,16 +2994,9 @@ std::ostream& print0x9201(std::ostream& os, const Value& value, const ExifData*)
30002994
}
30012995

30022996
std::ostream& print0x9202(std::ostream& os, const Value& value, const ExifData*) {
3003-
std::ios::fmtflags f(os.flags());
3004-
if (value.count() == 0 || value.toRational().second == 0) {
2997+
if (value.count() == 0 || value.toRational().second == 0)
30052998
return os << "(" << value << ")";
3006-
}
3007-
std::ostringstream oss;
3008-
oss.copyfmt(os);
3009-
os << "F" << std::setprecision(2) << fnumber(value.toFloat());
3010-
os.copyfmt(oss);
3011-
os.flags(f);
3012-
return os;
2999+
return os << stringFormat("F{:.2g}", fnumber(value.toFloat()));
30133000
}
30143001

30153002
std::ostream& print0x9204(std::ostream& os, const Value& value, const ExifData*) {
@@ -3033,22 +3020,14 @@ std::ostream& print0x9204(std::ostream& os, const Value& value, const ExifData*)
30333020
}
30343021

30353022
std::ostream& print0x9206(std::ostream& os, const Value& value, const ExifData*) {
3036-
std::ios::fmtflags f(os.flags());
30373023
Rational distance = value.toRational();
3038-
if (distance.first == 0) {
3039-
os << _("Unknown");
3040-
} else if (static_cast<uint32_t>(distance.first) == 0xffffffff) {
3041-
os << _("Infinity");
3042-
} else if (distance.second != 0) {
3043-
std::ostringstream oss;
3044-
oss.copyfmt(os);
3045-
os << std::fixed << std::setprecision(2) << static_cast<float>(distance.first) / distance.second << " m";
3046-
os.copyfmt(oss);
3047-
} else {
3048-
os << "(" << value << ")";
3049-
}
3050-
os.flags(f);
3051-
return os;
3024+
if (distance.first == 0)
3025+
return os << _("Unknown");
3026+
if (static_cast<uint32_t>(distance.first) == std::numeric_limits<uint32_t>::max())
3027+
return os << _("Infinity");
3028+
if (distance.second != 0)
3029+
return os << stringFormat("{:.2f} m", static_cast<float>(distance.first) / distance.second);
3030+
return os << "(" << value << ")";
30523031
}
30533032

30543033
//! MeteringMode, tag 0x9207
@@ -3067,18 +3046,10 @@ std::ostream& print0x9208(std::ostream& os, const Value& value, const ExifData*
30673046
}
30683047

30693048
std::ostream& print0x920a(std::ostream& os, const Value& value, const ExifData*) {
3070-
std::ios::fmtflags f(os.flags());
30713049
Rational length = value.toRational();
3072-
if (length.second != 0) {
3073-
std::ostringstream oss;
3074-
oss.copyfmt(os);
3075-
os << std::fixed << std::setprecision(1) << static_cast<float>(length.first) / length.second << " mm";
3076-
os.copyfmt(oss);
3077-
} else {
3078-
os << "(" << value << ")";
3079-
}
3080-
os.flags(f);
3081-
return os;
3050+
if (length.second != 0)
3051+
return os << stringFormat("{:.1f} mm", static_cast<float>(length.first) / length.second);
3052+
return os << "(" << value << ")";
30823053
}
30833054

30843055
//! ColorSpace, tag 0xa001
@@ -3159,26 +3130,16 @@ std::ostream& print0xa403(std::ostream& os, const Value& value, const ExifData*
31593130
}
31603131

31613132
std::ostream& print0xa404(std::ostream& os, const Value& value, const ExifData*) {
3162-
std::ios::fmtflags f(os.flags());
31633133
Rational zoom = value.toRational();
3164-
if (zoom.second == 0) {
3165-
os << _("Digital zoom not used");
3166-
} else {
3167-
std::ostringstream oss;
3168-
oss.copyfmt(os);
3169-
os << std::fixed << std::setprecision(1) << static_cast<float>(zoom.first) / zoom.second;
3170-
os.copyfmt(oss);
3171-
}
3172-
os.flags(f);
3173-
return os;
3134+
if (zoom.second == 0)
3135+
return os << _("Digital zoom not used");
3136+
return os << stringFormat("{:.1f}", static_cast<float>(zoom.first) / zoom.second);
31743137
}
31753138

31763139
std::ostream& print0xa405(std::ostream& os, const Value& value, const ExifData*) {
3177-
if (auto length = value.toInt64(); length == 0)
3178-
os << _("Unknown");
3179-
else
3180-
os << length << ".0 mm";
3181-
return os;
3140+
if (auto length = value.toInt64(); length != 0)
3141+
return os << length << ".0 mm";
3142+
return os << _("Unknown");
31823143
}
31833144

31843145
//! SceneCaptureType, tag 0xa406

0 commit comments

Comments
 (0)