Skip to content

Commit 273e917

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

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
@@ -11,6 +11,7 @@
1111
#include "canonmn_int.hpp"
1212
#include "casiomn_int.hpp"
1313
#include "fujimn_int.hpp"
14+
#include "image_int.hpp"
1415
#include "minoltamn_int.hpp"
1516
#include "nikonmn_int.hpp"
1617
#include "olympusmn_int.hpp"
@@ -2908,6 +2909,7 @@ std::ostream& print0x829a(std::ostream& os, const Value& value, const ExifData*)
29082909
if (value.typeId() != unsignedRational)
29092910
return os << "(" << value << ")";
29102911

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

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

29412935
//! ExposureProgram, tag 0x8822
@@ -2999,16 +2993,9 @@ std::ostream& print0x9201(std::ostream& os, const Value& value, const ExifData*)
29992993
}
30002994

30012995
std::ostream& print0x9202(std::ostream& os, const Value& value, const ExifData*) {
3002-
std::ios::fmtflags f(os.flags());
3003-
if (value.count() == 0 || value.toRational().second == 0) {
2996+
if (value.count() == 0 || value.toRational().second == 0)
30042997
return os << "(" << value << ")";
3005-
}
3006-
std::ostringstream oss;
3007-
oss.copyfmt(os);
3008-
os << "F" << std::setprecision(2) << fnumber(value.toFloat());
3009-
os.copyfmt(oss);
3010-
os.flags(f);
3011-
return os;
2998+
return os << stringFormat("F{:.2}", fnumber(value.toFloat()));
30122999
}
30133000

30143001
std::ostream& print0x9204(std::ostream& os, const Value& value, const ExifData*) {
@@ -3032,22 +3019,14 @@ std::ostream& print0x9204(std::ostream& os, const Value& value, const ExifData*)
30323019
}
30333020

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

30533032
//! MeteringMode, tag 0x9207
@@ -3066,18 +3045,10 @@ std::ostream& print0x9208(std::ostream& os, const Value& value, const ExifData*
30663045
}
30673046

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

30833054
//! ColorSpace, tag 0xa001
@@ -3158,26 +3129,16 @@ std::ostream& print0xa403(std::ostream& os, const Value& value, const ExifData*
31583129
}
31593130

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

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

31833144
//! SceneCaptureType, tag 0xa406

0 commit comments

Comments
 (0)