Skip to content

Commit 89de153

Browse files
committed
remove exvGettext in favor of macro
Saves a function call. Signed-off-by: Rosen Penev <[email protected]>
1 parent 1cb11d8 commit 89de153

File tree

6 files changed

+67
-64
lines changed

6 files changed

+67
-64
lines changed

src/fujimn_int.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ static std::ostream& printFujiDriveSetting(std::ostream& os, const Value& value,
293293
auto fps = valint >> 24;
294294

295295
if (auto setting = Exiv2::find(fujiDriveSettingByte1, byte1)) {
296-
os << exvGettext(setting->label_);
296+
os << _(setting->label_);
297297
} else {
298298
os << "(" << +byte1 << ")";
299299
}
@@ -435,7 +435,7 @@ static std::ostream& printFujiFaceElementTypes(std::ostream& os, const Value& va
435435
os << " ";
436436
}
437437
if (auto td = Exiv2::find(fujiFaceElementType, longValue)) {
438-
os << exvGettext(td->label_);
438+
os << _(td->label_);
439439
} else {
440440
os << "(" << value.toInt64(n) << ")";
441441
}

src/minoltamn_int.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1674,7 +1674,7 @@ static bool inRange(long value, long min, long max) {
16741674
static std::ostream& resolvedLens(std::ostream& os, long lensID, long index) {
16751675
auto td = Exiv2::find(minoltaSonyLensID, lensID);
16761676
std::vector<std::string> tokens = split(td[0].label_, "|");
1677-
return os << exvGettext(trim(tokens.at(index - 1)).c_str());
1677+
return os << _(trim(tokens.at(index - 1)).c_str());
16781678
}
16791679

16801680
static std::ostream& resolveLens0x1c(std::ostream& os, const Value& value, const ExifData* metadata) {

src/nikonmn_int.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3896,11 +3896,16 @@ std::ostream& Nikon3MakerNote::print0x009e(std::ostream& os, const Value& value,
38963896
continue;
38973897
if (l != 0)
38983898
trim = false;
3899-
std::string d = s.empty() ? "" : "; ";
3900-
if (auto td = Exiv2::find(nikonRetouchHistory, l)) {
3901-
s = std::string(exvGettext(td->label_)).append(d).append(s);
3899+
if (s.empty()) {
3900+
if (auto td = Exiv2::find(nikonRetouchHistory, l))
3901+
s = stringFormat("{}{}", _(td->label_), s);
3902+
else
3903+
s = stringFormat("{} ({}) {}", _("Unknown"), l, s);
39023904
} else {
3903-
s = std::string(_("Unknown")).append(" (").append(std::to_string(l)).append(")").append(d).append(s);
3905+
if (auto td = Exiv2::find(nikonRetouchHistory, l))
3906+
s = stringFormat("{}; {}", _(td->label_), s);
3907+
else
3908+
s = stringFormat("{} ({}) ; {}", _("Unknown"), l, s);
39043909
}
39053910
}
39063911
return os << s;

src/pentaxmn_int.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace Exiv2::Internal {
2929
by looking up a reference table.
3030
*/
3131
template <size_t N, const TagDetails (&array)[N], int count, int ignoredcount, int ignoredcountmax>
32-
std::ostream& printCombiTag(std::ostream& os, const Value& value, const ExifData* metadata) {
32+
static std::ostream& printCombiTag(std::ostream& os, const Value& value, const ExifData* metadata) {
3333
static_assert(N > 0, "Passed zero length printCombiTag");
3434
std::ios::fmtflags f(os.flags());
3535
if ((value.count() != count &&
@@ -44,11 +44,11 @@ std::ostream& printCombiTag(std::ostream& os, const Value& value, const ExifData
4444
}
4545
l += (value.toUint32(c) << ((count - c - 1) * 8));
4646
}
47+
4748
if (auto td = Exiv2::find(array, l)) {
48-
os << exvGettext(td->label_);
49+
os << _(td->label_);
4950
} else {
50-
os << exvGettext("Unknown") << " (0x" << std::setw(2 * count) << std::setfill('0') << std::hex << l << std::dec
51-
<< ")";
51+
os << _("Unknown") << " (0x" << std::setw(2 * count) << std::setfill('0') << std::hex << l << std::dec << ")";
5252
}
5353

5454
os.flags(f);
@@ -1116,8 +1116,7 @@ static std::ostream& resolveLens0x32c(std::ostream& os, const Value& value, cons
11161116
if (index > 0) {
11171117
const unsigned long lensID = 0x32c;
11181118
auto td = Exiv2::find(pentaxLensType, lensID);
1119-
os << exvGettext(td[index].label_);
1120-
return os;
1119+
return os << _(td[index].label_);
11211120
}
11221121
} catch (...) {
11231122
}
@@ -1180,8 +1179,7 @@ static std::ostream& resolveLens0x3ff(std::ostream& os, const Value& value, cons
11801179
if (index > 0) {
11811180
const unsigned long lensID = 0x3ff;
11821181
auto td = Exiv2::find(pentaxLensType, lensID);
1183-
os << exvGettext(td[index].label_);
1184-
return os;
1182+
return os << _(td[index].label_);
11851183
}
11861184
} catch (...) {
11871185
}
@@ -1207,8 +1205,7 @@ static std::ostream& resolveLens0x8ff(std::ostream& os, const Value& value, cons
12071205
if (index > 0) {
12081206
const unsigned long lensID = 0x8ff;
12091207
auto td = Exiv2::find(pentaxLensType, lensID);
1210-
os << exvGettext(td[index].label_);
1211-
return os;
1208+
return os << _(td[index].label_);
12121209
}
12131210
} catch (...) {
12141211
}
@@ -1241,8 +1238,7 @@ static std::ostream& resolveLens0x319(std::ostream& os, const Value& value, cons
12411238
if (index > 0) {
12421239
const unsigned long lensID = 0x319;
12431240
auto td = Exiv2::find(pentaxLensType, lensID);
1244-
os << exvGettext(td[index].label_);
1245-
return os;
1241+
return os << _(td[index].label_);
12461242
}
12471243
} catch (...) {
12481244
}

src/quicktimevideo.cpp

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ void QuickTimeVideo::CameraTagsDecoder(size_t size) {
826826
io_->readOrThrow(buf.data(), 10);
827827
io_->readOrThrow(buf.data(), 4);
828828
if (auto td = Exiv2::find(whiteBalance, buf.read_uint32(0, littleEndian)))
829-
xmpData_["Xmp.video.WhiteBalance"] = exvGettext(td->label_);
829+
xmpData_["Xmp.video.WhiteBalance"] = _(td->label_);
830830
io_->readOrThrow(buf.data(), 4);
831831
io_->readOrThrow(buf2.data(), 4);
832832
xmpData_["Xmp.video.FocalLength"] =
@@ -884,7 +884,7 @@ void QuickTimeVideo::userDataDecoder(size_t outer_size, size_t recursion_depth)
884884
else if (equalsQTimeTag(buf, "CNCV") || equalsQTimeTag(buf, "CNFV") || equalsQTimeTag(buf, "CNMN") ||
885885
equalsQTimeTag(buf, "NCHD") || equalsQTimeTag(buf, "FFMV")) {
886886
enforce(tv, Exiv2::ErrorCode::kerCorruptedMetadata);
887-
xmpData_[exvGettext(tv->label_)] = readString(*io_, size - 8);
887+
xmpData_[_(tv->label_)] = readString(*io_, size - 8);
888888
}
889889

890890
else if (equalsQTimeTag(buf, "CMbo") || equalsQTimeTag(buf, "Cmbo")) {
@@ -894,14 +894,14 @@ void QuickTimeVideo::userDataDecoder(size_t outer_size, size_t recursion_depth)
894894
tv_internal = Exiv2::find(cameraByteOrderTags, Exiv2::toString(buf.data()));
895895

896896
if (tv_internal)
897-
xmpData_[exvGettext(tv->label_)] = exvGettext(tv_internal->label_);
897+
xmpData_[_(tv->label_)] = _(tv_internal->label_);
898898
else
899-
xmpData_[exvGettext(tv->label_)] = Exiv2::toString(buf.data());
899+
xmpData_[_(tv->label_)] = Exiv2::toString(buf.data());
900900
}
901901

902902
else if (tv) {
903903
io_->readOrThrow(buf.data(), 4);
904-
xmpData_[exvGettext(tv->label_)] = readString(*io_, size - 12);
904+
xmpData_[_(tv->label_)] = readString(*io_, size - 12);
905905
}
906906

907907
else if (td)
@@ -949,40 +949,40 @@ void QuickTimeVideo::NikonTagsDecoder(size_t size) {
949949
io_->readOrThrow(buf.data(), 1);
950950
td2 = Exiv2::find(PictureControlAdjust, static_cast<int>(buf.data()[0]) & 7);
951951
if (td2)
952-
xmpData_["Xmp.video.PictureControlAdjust"] = exvGettext(td2->label_);
952+
xmpData_["Xmp.video.PictureControlAdjust"] = _(td2->label_);
953953
else
954954
xmpData_["Xmp.video.PictureControlAdjust"] = static_cast<int>(buf.data()[0]) & 7;
955955

956956
io_->readOrThrow(buf.data(), 1);
957957
td2 = Exiv2::find(NormalSoftHard, static_cast<int>(buf.data()[0]) & 7);
958958
if (td2)
959-
xmpData_["Xmp.video.PictureControlQuickAdjust"] = exvGettext(td2->label_);
959+
xmpData_["Xmp.video.PictureControlQuickAdjust"] = _(td2->label_);
960960

961961
io_->readOrThrow(buf.data(), 1);
962962
td2 = Exiv2::find(NormalSoftHard, static_cast<int>(buf.data()[0]) & 7);
963963
if (td2)
964-
xmpData_["Xmp.video.Sharpness"] = exvGettext(td2->label_);
964+
xmpData_["Xmp.video.Sharpness"] = _(td2->label_);
965965
else
966966
xmpData_["Xmp.video.Sharpness"] = static_cast<int>(buf.data()[0]) & 7;
967967

968968
io_->readOrThrow(buf.data(), 1);
969969
td2 = Exiv2::find(NormalSoftHard, static_cast<int>(buf.data()[0]) & 7);
970970
if (td2)
971-
xmpData_["Xmp.video.Contrast"] = exvGettext(td2->label_);
971+
xmpData_["Xmp.video.Contrast"] = _(td2->label_);
972972
else
973973
xmpData_["Xmp.video.Contrast"] = static_cast<int>(buf.data()[0]) & 7;
974974

975975
io_->readOrThrow(buf.data(), 1);
976976
td2 = Exiv2::find(NormalSoftHard, static_cast<int>(buf.data()[0]) & 7);
977977
if (td2)
978-
xmpData_["Xmp.video.Brightness"] = exvGettext(td2->label_);
978+
xmpData_["Xmp.video.Brightness"] = _(td2->label_);
979979
else
980980
xmpData_["Xmp.video.Brightness"] = static_cast<int>(buf.data()[0]) & 7;
981981

982982
io_->readOrThrow(buf.data(), 1);
983983
td2 = Exiv2::find(Saturation, static_cast<int>(buf.data()[0]) & 7);
984984
if (td2)
985-
xmpData_["Xmp.video.Saturation"] = exvGettext(td2->label_);
985+
xmpData_["Xmp.video.Saturation"] = _(td2->label_);
986986
else
987987
xmpData_["Xmp.video.Saturation"] = static_cast<int>(buf.data()[0]) & 7;
988988

@@ -992,14 +992,14 @@ void QuickTimeVideo::NikonTagsDecoder(size_t size) {
992992
io_->readOrThrow(buf.data(), 1);
993993
td2 = Exiv2::find(FilterEffect, static_cast<int>(buf.data()[0]));
994994
if (td2)
995-
xmpData_["Xmp.video.FilterEffect"] = exvGettext(td2->label_);
995+
xmpData_["Xmp.video.FilterEffect"] = _(td2->label_);
996996
else
997997
xmpData_["Xmp.video.FilterEffect"] = static_cast<int>(buf.data()[0]);
998998

999999
io_->readOrThrow(buf.data(), 1);
10001000
td2 = Exiv2::find(ToningEffect, static_cast<int>(buf.data()[0]));
10011001
if (td2)
1002-
xmpData_["Xmp.video.ToningEffect"] = exvGettext(td2->label_);
1002+
xmpData_["Xmp.video.ToningEffect"] = _(td2->label_);
10031003
else
10041004
xmpData_["Xmp.video.ToningEffect"] = static_cast<int>(buf.data()[0]);
10051005

@@ -1019,12 +1019,12 @@ void QuickTimeVideo::NikonTagsDecoder(size_t size) {
10191019
io_->readOrThrow(buf.data(), 1);
10201020
td2 = Exiv2::find(YesNo, static_cast<int>(buf.data()[0]));
10211021
if (td2)
1022-
xmpData_["Xmp.video.DayLightSavings"] = exvGettext(td2->label_);
1022+
xmpData_["Xmp.video.DayLightSavings"] = _(td2->label_);
10231023

10241024
io_->readOrThrow(buf.data(), 1);
10251025
td2 = Exiv2::find(DateDisplayFormat, static_cast<int>(buf.data()[0]));
10261026
if (td2)
1027-
xmpData_["Xmp.video.DateDisplayFormat"] = exvGettext(td2->label_);
1027+
xmpData_["Xmp.video.DateDisplayFormat"] = _(td2->label_);
10281028

10291029
io_->seek(local_pos + dataLength, BasicIo::beg);
10301030
}
@@ -1047,14 +1047,14 @@ void QuickTimeVideo::NikonTagsDecoder(size_t size) {
10471047
}
10481048

10491049
if (td) {
1050-
xmpData_[exvGettext(td->label_)] = Exiv2::toString(buf.data());
1050+
xmpData_[_(td->label_)] = Exiv2::toString(buf.data());
10511051
}
10521052
} else if (dataType == 4) {
10531053
dataLength = buf.read_uint16(0, bigEndian) * 4;
10541054
std::memset(buf.data(), 0x0, buf.size());
10551055
io_->readOrThrow(buf.data(), 4);
10561056
if (td)
1057-
xmpData_[exvGettext(td->label_)] = Exiv2::toString(buf.read_uint32(0, bigEndian));
1057+
xmpData_[_(td->label_)] = Exiv2::toString(buf.read_uint32(0, bigEndian));
10581058

10591059
// Sanity check with an "unreasonably" large number
10601060
if (dataLength > 200 || dataLength < 4) {
@@ -1070,7 +1070,7 @@ void QuickTimeVideo::NikonTagsDecoder(size_t size) {
10701070
std::memset(buf.data(), 0x0, buf.size());
10711071
io_->readOrThrow(buf.data(), 2);
10721072
if (td)
1073-
xmpData_[exvGettext(td->label_)] = Exiv2::toString(buf.read_uint16(0, bigEndian));
1073+
xmpData_[_(td->label_)] = Exiv2::toString(buf.read_uint16(0, bigEndian));
10741074

10751075
// Sanity check with an "unreasonably" large number
10761076
if (dataLength > 200 || dataLength < 2) {
@@ -1087,8 +1087,8 @@ void QuickTimeVideo::NikonTagsDecoder(size_t size) {
10871087
io_->readOrThrow(buf.data(), 4);
10881088
io_->readOrThrow(buf2.data(), 4);
10891089
if (td)
1090-
xmpData_[exvGettext(td->label_)] = Exiv2::toString(static_cast<double>(buf.read_uint32(0, bigEndian)) /
1091-
static_cast<double>(buf2.read_uint32(0, bigEndian)));
1090+
xmpData_[_(td->label_)] =
1091+
static_cast<double>(buf.read_uint32(0, bigEndian)) / static_cast<double>(buf2.read_uint32(0, bigEndian));
10921092

10931093
// Sanity check with an "unreasonably" large number
10941094
if (dataLength > 200 || dataLength < 8) {
@@ -1105,7 +1105,7 @@ void QuickTimeVideo::NikonTagsDecoder(size_t size) {
11051105
io_->readOrThrow(buf.data(), 2);
11061106
io_->readOrThrow(buf2.data(), 2);
11071107
if (td)
1108-
xmpData_[exvGettext(td->label_)] =
1108+
xmpData_[_(td->label_)] =
11091109
Exiv2::toString(buf.read_uint16(0, bigEndian)) + " " + Exiv2::toString(buf2.read_uint16(0, bigEndian));
11101110

11111111
// Sanity check with an "unreasonably" large number
@@ -1205,14 +1205,14 @@ void QuickTimeVideo::audioDescDecoder() {
12051205
case AudioFormat:
12061206
td = Exiv2::find(qTimeFileType, Exiv2::toString(buf.data()));
12071207
if (td)
1208-
xmpData_["Xmp.audio.Compressor"] = exvGettext(td->label_);
1208+
xmpData_["Xmp.audio.Compressor"] = _(td->label_);
12091209
else
12101210
xmpData_["Xmp.audio.Compressor"] = Exiv2::toString(buf.data());
12111211
break;
12121212
case AudioVendorID:
12131213
td = Exiv2::find(vendorIDTags, Exiv2::toString(buf.data()));
12141214
if (td)
1215-
xmpData_["Xmp.audio.VendorID"] = exvGettext(td->label_);
1215+
xmpData_["Xmp.audio.VendorID"] = _(td->label_);
12161216
break;
12171217
case AudioChannels:
12181218
xmpData_["Xmp.audio.ChannelType"] = buf.read_uint16(0, bigEndian);
@@ -1245,14 +1245,14 @@ void QuickTimeVideo::imageDescDecoder() {
12451245
case codec:
12461246
td = Exiv2::find(qTimeFileType, Exiv2::toString(buf.data()));
12471247
if (td)
1248-
xmpData_["Xmp.video.Codec"] = exvGettext(td->label_);
1248+
xmpData_["Xmp.video.Codec"] = _(td->label_);
12491249
else
12501250
xmpData_["Xmp.video.Codec"] = Exiv2::toString(buf.data());
12511251
break;
12521252
case VendorID:
12531253
td = Exiv2::find(vendorIDTags, Exiv2::toString(buf.data()));
12541254
if (td)
1255-
xmpData_["Xmp.video.VendorID"] = exvGettext(td->label_);
1255+
xmpData_["Xmp.video.VendorID"] = _(td->label_);
12561256
break;
12571257
case SourceImageWidth_Height:
12581258
xmpData_["Xmp.video.SourceImageWidth"] = buf.read_uint16(0, bigEndian);
@@ -1310,7 +1310,7 @@ void QuickTimeVideo::videoHeaderDecoder(size_t size) {
13101310
case GraphicsMode:
13111311
td = Exiv2::find(graphicsModetags, buf.read_uint16(0, bigEndian));
13121312
if (td)
1313-
xmpData_["Xmp.video.GraphicsMode"] = exvGettext(td->label_);
1313+
xmpData_["Xmp.video.GraphicsMode"] = _(td->label_);
13141314
break;
13151315
case OpColor:
13161316
xmpData_["Xmp.video.OpColor"] = buf.read_uint16(0, bigEndian);
@@ -1338,27 +1338,27 @@ void QuickTimeVideo::handlerDecoder(size_t size) {
13381338
tv = Exiv2::find(handlerClassTags, Exiv2::toString(buf.data()));
13391339
if (tv) {
13401340
if (currentStream_ == Video)
1341-
xmpData_["Xmp.video.HandlerClass"] = exvGettext(tv->label_);
1341+
xmpData_["Xmp.video.HandlerClass"] = _(tv->label_);
13421342
else if (currentStream_ == Audio)
1343-
xmpData_["Xmp.audio.HandlerClass"] = exvGettext(tv->label_);
1343+
xmpData_["Xmp.audio.HandlerClass"] = _(tv->label_);
13441344
}
13451345
break;
13461346
case HandlerType:
13471347
tv = Exiv2::find(handlerTypeTags, Exiv2::toString(buf.data()));
13481348
if (tv) {
13491349
if (currentStream_ == Video)
1350-
xmpData_["Xmp.video.HandlerType"] = exvGettext(tv->label_);
1350+
xmpData_["Xmp.video.HandlerType"] = _(tv->label_);
13511351
else if (currentStream_ == Audio)
1352-
xmpData_["Xmp.audio.HandlerType"] = exvGettext(tv->label_);
1352+
xmpData_["Xmp.audio.HandlerType"] = _(tv->label_);
13531353
}
13541354
break;
13551355
case HandlerVendorID:
13561356
tv = Exiv2::find(vendorIDTags, Exiv2::toString(buf.data()));
13571357
if (tv) {
13581358
if (currentStream_ == Video)
1359-
xmpData_["Xmp.video.HandlerVendorID"] = exvGettext(tv->label_);
1359+
xmpData_["Xmp.video.HandlerVendorID"] = _(tv->label_);
13601360
else if (currentStream_ == Audio)
1361-
xmpData_["Xmp.audio.HandlerVendorID"] = exvGettext(tv->label_);
1361+
xmpData_["Xmp.audio.HandlerVendorID"] = _(tv->label_);
13621362
}
13631363
break;
13641364
}
@@ -1380,14 +1380,14 @@ void QuickTimeVideo::fileTypeDecoder(size_t size) {
13801380
switch (i) {
13811381
case 0:
13821382
if (td)
1383-
xmpData_["Xmp.video.MajorBrand"] = exvGettext(td->label_);
1383+
xmpData_["Xmp.video.MajorBrand"] = _(td->label_);
13841384
break;
13851385
case 1:
13861386
xmpData_["Xmp.video.MinorVersion"] = buf.read_uint32(0, bigEndian);
13871387
break;
13881388
default:
13891389
if (td)
1390-
v->read(exvGettext(td->label_));
1390+
v->read(_(td->label_));
13911391
else
13921392
v->read(Exiv2::toString(buf.data()));
13931393
break;

0 commit comments

Comments
 (0)