Skip to content

Commit a35cb2b

Browse files
committed
clazy: remove some non-POD statics
Signed-off-by: Rosen Penev <[email protected]>
1 parent 1d663d1 commit a35cb2b

File tree

3 files changed

+36
-17
lines changed

3 files changed

+36
-17
lines changed

src/asfvideo.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,14 @@ bool AsfVideo::GUIDTag::operator<(const GUIDTag& other) const {
7070

7171
constexpr AsfVideo::GUIDTag Header(0x75B22630, 0x668E, 0x11CF, {0xA6, 0xD9, 0x00, 0xAA, 0x00, 0x62, 0xCE, 0x6C});
7272

73-
const std::map<AsfVideo::GUIDTag, std::string> GUIDReferenceTags = {
73+
constexpr struct tags {
74+
AsfVideo::GUIDTag first;
75+
std::string_view second;
76+
77+
bool operator==(const AsfVideo::GUIDTag& tag) const {
78+
return first == tag;
79+
};
80+
} GUIDReferenceTags[] = {
7481
//!< Top-level ASF object GUIDS
7582
{Header, "Header"},
7683
{{0x75B22636, 0x668E, 0x11CF, {0xA6, 0xD9, 0x00, 0xAA, 0x00, 0x62, 0xCE, 0x6C}}, "Data"},
@@ -231,9 +238,8 @@ void AsfVideo::decodeBlock() {
231238
<< "\tsize= " << objectHeader.getSize() << "\t " << io_->tell() << "/" << io_->size() << '\n';
232239
#endif
233240
Internal::enforce(objectHeader.getSize() <= io_->size() - io_->tell(), Exiv2::ErrorCode::kerCorruptedMetadata);
234-
auto tag = GUIDReferenceTags.find(GUIDTag(objectHeader.getId().data()));
235241

236-
if (tag != GUIDReferenceTags.end()) {
242+
if (auto tag = Exiv2::find(GUIDReferenceTags, GUIDTag(objectHeader.getId().data()))) {
237243
if (tag->second == "Header")
238244
decodeHeader();
239245
else if (tag->second == "File_Properties")
@@ -339,8 +345,7 @@ void AsfVideo::streamProperties() {
339345
enum class streamTypeInfo { Audio = 1, Video = 2 };
340346
auto stream = streamTypeInfo{0};
341347

342-
auto tag_stream_type = GUIDReferenceTags.find(GUIDTag(streamTypedBuf.data()));
343-
if (tag_stream_type != GUIDReferenceTags.end()) {
348+
if (auto tag_stream_type = Exiv2::find(GUIDReferenceTags, GUIDTag(streamTypedBuf.data()))) {
344349
if (tag_stream_type->second == "Audio_Media")
345350
stream = streamTypeInfo::Audio;
346351
else if (tag_stream_type->second == "Video_Media")

src/image.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ std::string pathOfFileUrl(const std::string& url) {
129129
}
130130
#endif
131131

132+
bool typeValid(uint16_t type) {
133+
return type >= 1 && type <= 13;
134+
}
135+
136+
std::set<size_t> visits; // #547
137+
132138
} // namespace
133139

134140
// *****************************************************************************
@@ -305,12 +311,6 @@ const char* Image::typeName(uint16_t tag) {
305311
return result;
306312
}
307313

308-
static bool typeValid(uint16_t type) {
309-
return type >= 1 && type <= 13;
310-
}
311-
312-
static std::set<size_t> visits; // #547
313-
314314
void Image::printIFDStructure(BasicIo& io, std::ostream& out, Exiv2::PrintStructureOption option, size_t start,
315315
bool bSwap, char c, size_t depth) {
316316
if (depth == 1)

src/riffvideo.cpp

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,16 @@
1616

1717
#include <array>
1818

19-
namespace Exiv2::Internal {
19+
namespace {
2020

21-
const std::map<std::string, std::string> infoTags = {
21+
constexpr struct tags {
22+
std::string_view first;
23+
const char* second;
24+
25+
bool operator==(std::string_view tag) const {
26+
return tag == first;
27+
};
28+
} infoTags[] = {
2229
{"AGES", "Xmp.video.Rated"},
2330
{"CMNT", "Xmp.video.Comment"},
2431
{"CODE", "Xmp.video.EncodedBy"},
@@ -105,7 +112,14 @@ const std::map<std::string, std::string> infoTags = {
105112
{"YEAR", "Xmp.video.Year"},
106113
};
107114

108-
const std::map<uint16_t, std::string> audioEncodingValues = {
115+
constexpr struct encoding {
116+
uint16_t first;
117+
std::string_view second;
118+
119+
bool operator==(uint16_t tag) const {
120+
return tag = first;
121+
};
122+
} audioEncodingValues[] = {
109123
{0x1, "Microsoft PCM"},
110124
{0x2, "Microsoft ADPCM"},
111125
{0x3, "Microsoft IEEE float"},
@@ -351,7 +365,7 @@ const std::map<uint16_t, std::string> audioEncodingValues = {
351365
{0xffff, "Development"},
352366
};
353367

354-
} // namespace Exiv2::Internal
368+
} // namespace
355369
// *****************************************************************************
356370
// class member definitions
357371

@@ -625,7 +639,7 @@ void RiffVideo::readStreamFormat(uint64_t size_) {
625639
xmpData_["Xmp.video.NumIfImpColours"] = "All";
626640
} else if (streamType_ == Audio) {
627641
uint16_t format_tag = readWORDTag(io_);
628-
if (auto it = Internal::audioEncodingValues.find(format_tag); it != Internal::audioEncodingValues.end())
642+
if (auto it = Exiv2::find(audioEncodingValues, format_tag))
629643
xmpData_["Xmp.audio.Compressor"] = it->second;
630644
else
631645
xmpData_["Xmp.audio.Compressor"] = format_tag;
@@ -657,7 +671,7 @@ void RiffVideo::readInfoListChunk(uint64_t size_) {
657671
std::string type = readStringTag(io_);
658672
size_t size = readDWORDTag(io_);
659673
std::string content = readStringTag(io_, size);
660-
if (auto it = Internal::infoTags.find(type); it != Internal::infoTags.end())
674+
if (auto it = Exiv2::find(infoTags, type))
661675
xmpData_[it->second] = content;
662676
current_size += DWORD * 2;
663677
current_size += size;

0 commit comments

Comments
 (0)