random fixes

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev 2023-03-09 17:53:44 -08:00
parent d6c1059485
commit ca95edc6bd
20 changed files with 42 additions and 60 deletions

View File

@ -172,7 +172,7 @@ Task::UniquePtr TaskFactory::create(TaskType type) {
return nullptr;
}
int setModeAndPrintStructure(Exiv2::PrintStructureOption option, const std::string& path, bool binary) {
static int setModeAndPrintStructure(Exiv2::PrintStructureOption option, const std::string& path, bool binary) {
int result = 0;
if (binary && option == Exiv2::kpsIccProfile) {
std::stringstream output(std::stringstream::out | std::stringstream::binary);
@ -1815,14 +1815,6 @@ int metacopy(const std::string& source, const std::string& tgt, Exiv2::ImageType
return rc;
} // metacopy
// Defined outside of the function so that Exiv2::find() can see it
struct String {
const char* s_;
bool operator==(const char* s) const {
return 0 == strcmp(s_, s);
}
};
void replace(std::string& text, const std::string& searchText, const std::string& replaceText) {
std::string::size_type index = 0;
while ((index = text.find(searchText, index)) != std::string::npos) {

View File

@ -59,6 +59,10 @@ class Task {
//! Virtual destructor.
virtual ~Task() = default;
Task() = default;
Task(const Task&) = default;
Task& operator=(const Task&) = default;
//! Virtual copy construction.
virtual UniquePtr clone() const = 0;

View File

@ -19,8 +19,11 @@ EXIV2API bool enableBMFF(bool enable = true);
#ifdef EXV_ENABLE_BMFF
namespace Exiv2 {
struct Iloc {
explicit Iloc(uint32_t ID = 0, uint32_t start = 0, uint32_t length = 0) : ID_(ID), start_(start), length_(length){};
explicit Iloc(uint32_t ID = 0, uint32_t start = 0, uint32_t length = 0) : ID_(ID), start_(start), length_(length) {
}
virtual ~Iloc() = default;
Iloc(const Iloc&) = default;
Iloc& operator=(const Iloc&) = default;
uint32_t ID_;
uint32_t start_;

View File

@ -70,7 +70,7 @@ class EXIV2API PsdImage : public Image {
/*!
@brief Provides the main implementation of writeMetadata() by
writing all buffered metadata to the provided BasicIo.
@param oIo BasicIo instance to write to (a temporary location).
@param outIo BasicIo instance to write to (a temporary location).
@return 4 if opening or writing to the associated BasicIo fails
*/

View File

@ -200,7 +200,7 @@ const std::map<AsfVideo::GUIDTag, std::string> GUIDReferenceTags = {
@param buf Exiv2 byte buffer
@return Returns true if the buffer data is equivalent to Header GUID.
*/
bool isASFType(const byte buf[]) {
static bool isASFType(const byte buf[]) {
return Header == AsfVideo::GUIDTag(buf);
}

View File

@ -441,7 +441,7 @@ uint64_t BmffImage::boxHandler(std::ostream& out /* = std::cout*/, Exiv2::PrintS
}
// save data for post-processing in meta box
if (offset && ldata && ID != unknownID_) {
ilocs_[ID] = Iloc(ID, offset, ldata);
ilocs_[ID] = Iloc{ID, offset, ldata};
}
}
}

View File

@ -76,7 +76,7 @@ constexpr TagDetails fujiTone[] = {{0, N_("Normal")}, {80, N_("Medium High
constexpr TagDetails fujiContrast[] = {{0, N_("Normal")}, {256, N_("High")}, {768, N_("Low")}};
//! WhiteBalanceFineTune, tag 0x100a
std::ostream& printFujiWhiteBalanceFineTune(std::ostream& os, const Value& value, const ExifData*) {
static std::ostream& printFujiWhiteBalanceFineTune(std::ostream& os, const Value& value, const ExifData*) {
if (value.typeId() == signedLong && value.size() == 8) {
auto longValue = dynamic_cast<const LongValue&>(value);
if (longValue.toInt64(0) % 20 == 0 && longValue.toInt64(1) % 20 == 0) {
@ -186,7 +186,7 @@ constexpr TagDetails fujiSHTone[] = {{-64, N_("+4")}, {-56, N_("+3.5")}, {-48, N
{32, N_("-2")}};
//! DigitalZoom, tag 0x1044
std::ostream& printFujiDigitalZoom(std::ostream& os, const Value& value, const ExifData*) {
static std::ostream& printFujiDigitalZoom(std::ostream& os, const Value& value, const ExifData*) {
if (value.typeId() == unsignedLong && value.size() == 4) {
os << (value.toFloat() / 8);
}
@ -208,7 +208,7 @@ constexpr TagDetails fujiCropMode[] = {
};
//! MonochromaticColor, tag 0x1049 and 0x104b
std::ostream& printFujiMonochromaticColor(std::ostream& os, const Value& value, const ExifData*) {
static std::ostream& printFujiMonochromaticColor(std::ostream& os, const Value& value, const ExifData*) {
if (value.size() == 1) {
auto v = static_cast<std::int8_t>(value.toInt64());
os << (v > 0 ? "+" : "") << static_cast<int>(v);
@ -235,7 +235,7 @@ constexpr TagDetails fujiDriveSettingByte1[] = {
{0, N_("Single")}, {1, N_("Continuous Low")}, {2, N_("Continuous High")}};
//! DriveSetting, tag 0x1103
std::ostream& printFujiDriveSetting(std::ostream& os, const Value& value, const ExifData*) {
static std::ostream& printFujiDriveSetting(std::ostream& os, const Value& value, const ExifData*) {
auto byte1 = value.toInt64() & 0xff;
auto byte2 = (value.toInt64() >> 8) & 0xff;
auto byte3 = (value.toInt64() >> 16) & 0xff;
@ -331,7 +331,7 @@ constexpr TagDetails fujiDRangePriorityFixed[] = {{1, N_("Weak")}, {2, N_("Stron
constexpr TagDetails fujiFaceElementType[] = {{1, N_("Face")}, {2, N_("Left Eye")}, {3, N_("Right Eye")}};
//! FaceElementType, tag 0x4203
std::ostream& printFujiFaceElementTypes(std::ostream& os, const Value& value, const ExifData*) {
static std::ostream& printFujiFaceElementTypes(std::ostream& os, const Value& value, const ExifData*) {
if (value.typeId() == asciiString || value.typeId() == unsignedShort) {
auto elements = value.count();

View File

@ -76,13 +76,13 @@ std::string getEnv(int env_var) {
}
/// @brief Convert an integer value to its hex character.
char to_hex(char code) {
static char to_hex(char code) {
static const char hex[] = "0123456789abcdef";
return hex[code & 15];
}
/// @brief Convert a hex character to its integer value.
char from_hex(char ch) {
static char from_hex(char ch) {
return isdigit(ch) ? ch - '0' : static_cast<char>(tolower(ch)) - 'a' + 10;
}

View File

@ -419,16 +419,6 @@ int IptcParser::decode(IptcData& iptcData, const byte* pData, size_t size) {
return 0;
} // IptcParser::decode
/*!
@brief Compare two iptc items by record. Return true if the record of
lhs is less than that of rhs.
This is a helper function for IptcParser::encode().
*/
bool cmpIptcdataByRecord(const Iptcdatum& lhs, const Iptcdatum& rhs) {
return lhs.record() < rhs.record();
}
DataBuf IptcParser::encode(const IptcData& iptcData) {
if (iptcData.empty())
return {};
@ -439,7 +429,8 @@ DataBuf IptcParser::encode(const IptcData& iptcData) {
// Copy the iptc data sets and sort them by record but preserve the order of datasets
IptcMetadata sortedIptcData;
std::copy(iptcData.begin(), iptcData.end(), std::back_inserter(sortedIptcData));
std::stable_sort(sortedIptcData.begin(), sortedIptcData.end(), cmpIptcdataByRecord);
std::stable_sort(sortedIptcData.begin(), sortedIptcData.end(),
[](const auto& l, const auto& r) { return l.record() < r.record(); });
for (const auto& iter : sortedIptcData) {
// marker, record Id, dataset num

View File

@ -858,7 +858,7 @@ struct NikonArrayIdx {
uint32_t start_; //!< Start of the encrypted data
};
#define NA ((uint32_t)-1)
#define NA std::numeric_limits<uint32_t>::max()
//! Nikon binary array version lookup table
constexpr NikonArrayIdx nikonArrayIdx[] = {

View File

@ -584,7 +584,7 @@ const MatroskaTag streamRate[] = {
bytes are used to calculate the rest of the Tag.
Returns Tag Value.
*/
[[nodiscard]] size_t returnTagValue(const byte* buf, size_t size) {
[[nodiscard]] static size_t returnTagValue(const byte* buf, size_t size) {
enforce(size > 0 && size <= 8, Exiv2::ErrorCode::kerCorruptedMetadata);
size_t b0 = buf[0] & (0xff >> size);

View File

@ -1076,7 +1076,7 @@ static ExifData::const_iterator findLensInfo(const ExifData* metadata) {
}
//! resolveLens0x32c print lens in human format
std::ostream& resolveLens0x32c(std::ostream& os, const Value& value, const ExifData* metadata) {
static std::ostream& resolveLens0x32c(std::ostream& os, const Value& value, const ExifData* metadata) {
try {
unsigned long index = 0;
@ -1102,7 +1102,7 @@ std::ostream& resolveLens0x32c(std::ostream& os, const Value& value, const ExifD
// #816 begin
//! resolveLens0x3ff print lens in human format
std::ostream& resolveLens0x3ff(std::ostream& os, const Value& value, const ExifData* metadata)
static std::ostream& resolveLens0x3ff(std::ostream& os, const Value& value, const ExifData* metadata)
// ----------------------------------------------------------------------
{
try {
@ -1165,7 +1165,7 @@ std::ostream& resolveLens0x3ff(std::ostream& os, const Value& value, const ExifD
// #1155
//! resolveLens0x8ff print lens in human format
std::ostream& resolveLens0x8ff(std::ostream& os, const Value& value, const ExifData* metadata)
static std::ostream& resolveLens0x8ff(std::ostream& os, const Value& value, const ExifData* metadata)
// ----------------------------------------------------------------------
{
try {
@ -1192,7 +1192,7 @@ std::ostream& resolveLens0x8ff(std::ostream& os, const Value& value, const ExifD
// #1155
//! resolveLens0x319 print lens in human format
std::ostream& resolveLens0x319(std::ostream& os, const Value& value, const ExifData* metadata)
static std::ostream& resolveLens0x319(std::ostream& os, const Value& value, const ExifData* metadata)
// ----------------------------------------------------------------------
{
try {
@ -1225,7 +1225,7 @@ std::ostream& resolveLens0x319(std::ostream& os, const Value& value, const ExifD
}
//! resolveLensType print lens in human format
std::ostream& resolveLensType(std::ostream& os, const Value& value, const ExifData* metadata) {
static std::ostream& resolveLensType(std::ostream& os, const Value& value, const ExifData* metadata) {
return EXV_PRINT_COMBITAG_MULTI(pentaxLensType, 2, 1, 2)(os, value, metadata);
}
@ -1247,7 +1247,7 @@ constexpr LensIdFct lensIdFct[] = {
};
//! A lens id and a pretty-print function for special treatment of the id.
std::ostream& printLensType(std::ostream& os, const Value& value, const ExifData* metadata) {
static std::ostream& printLensType(std::ostream& os, const Value& value, const ExifData* metadata) {
// #1034
const std::string undefined("undefined");
const std::string section("pentax");

View File

@ -173,7 +173,7 @@ static bool tEXtToDataBuf(const byte* bytes, size_t length, DataBuf& result) {
return true;
}
std::string::size_type findi(const std::string& str, const std::string& substr) {
static std::string::size_type findi(const std::string& str, const std::string& substr) {
return str.find(substr);
}
@ -374,7 +374,7 @@ void PngImage::printStructure(std::ostream& out, PrintStructureOption option, si
}
}
void readChunk(DataBuf& buffer, BasicIo& io) {
static void readChunk(DataBuf& buffer, BasicIo& io) {
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Exiv2::PngImage::readMetadata: Position: " << io.tell() << std::endl;
#endif

View File

@ -447,7 +447,7 @@ enum audioDescTags { AudioFormat, AudioVendorID = 4, AudioChannels, AudioSampleR
@param str char* Pointer to string
@return Returns true if the buffer value is equal to string.
*/
bool equalsQTimeTag(Exiv2::DataBuf& buf, const char* str) {
static bool equalsQTimeTag(Exiv2::DataBuf& buf, const char* str) {
for (int i = 0; i < 4; ++i)
if (tolower(buf.data()[i]) != tolower(str[i]))
return false;
@ -460,7 +460,7 @@ bool equalsQTimeTag(Exiv2::DataBuf& buf, const char* str) {
@param buf Data buffer that will contain Tag to compare
@return Returns true, if Tag is found in the ignoreList[]
*/
bool ignoreList(Exiv2::DataBuf& buf) {
static bool ignoreList(Exiv2::DataBuf& buf) {
const char ignoreList[13][5] = {
"mdat", "edts", "junk", "iods", "alis", "stsc", "stsz", "stco", "ctts", "stss", "skip", "wide", "cmvd",
};
@ -479,7 +479,7 @@ bool ignoreList(Exiv2::DataBuf& buf) {
@param buf Data buffer that will contain Tag to compare
@return Returns true, if Tag is found in the ignoreList[]
*/
bool dataIgnoreList(Exiv2::DataBuf& buf) {
static bool dataIgnoreList(Exiv2::DataBuf& buf) {
const char ignoreList[8][5] = {
"moov", "mdia", "minf", "dinf", "alis", "stbl", "cmov", "meta",
};

View File

@ -41,7 +41,7 @@ constexpr TagDetails samsung2ColorSpace[] = {{0, N_("sRGB")}, {1, N_("Adobe RGB"
constexpr TagDetails samsung2SmartRange[] = {{0, N_("Off")}, {1, N_("On")}};
//! Print the camera temperature
std::ostream& printCameraTemperature(std::ostream& os, const Value& value, const ExifData*) {
static std::ostream& printCameraTemperature(std::ostream& os, const Value& value, const ExifData*) {
if (value.count() != 1 || value.typeId() != signedRational) {
return os << value;
}
@ -49,7 +49,7 @@ std::ostream& printCameraTemperature(std::ostream& os, const Value& value, const
}
//! Print the 35mm focal length
std::ostream& printFocalLength35(std::ostream& os, const Value& value, const ExifData*) {
static std::ostream& printFocalLength35(std::ostream& os, const Value& value, const ExifData*) {
std::ios::fmtflags f(os.flags());
if (value.count() != 1 || value.typeId() != unsignedLong) {
return os << value;
@ -145,7 +145,7 @@ constexpr TagDetails samsungPwMode[] = {{0, N_("Standard")}, {1, N_("Vivid")},
{9, N_("Custom1")}, {10, N_("Custom2")}, {11, N_("Custom3")}};
//! Print the PictureWizard Color tag value
std::ostream& printPwColor(std::ostream& os, const Value& value, const ExifData*) {
static std::ostream& printPwColor(std::ostream& os, const Value& value, const ExifData*) {
if (value.count() != 1 || value.typeId() != unsignedShort) {
return os << value;
}
@ -158,7 +158,7 @@ std::ostream& printPwColor(std::ostream& os, const Value& value, const ExifData*
}
//! Print the tag value minus 4
std::ostream& printValueMinus4(std::ostream& os, const Value& value, const ExifData*) {
static std::ostream& printValueMinus4(std::ostream& os, const Value& value, const ExifData*) {
if (value.count() != 1 || value.typeId() != unsignedShort) {
return os << value;
}

View File

@ -569,8 +569,6 @@ class TiffEntry : public TiffEntryBase {
//! Constructor
TiffEntry(uint16_t tag, IfdId group) : TiffEntryBase(tag, group) {
}
//! Virtual destructor.
~TiffEntry() override = default;
//@}
protected:
@ -603,8 +601,6 @@ class TiffDataEntryBase : public TiffEntryBase {
TiffDataEntryBase(uint16_t tag, IfdId group, uint16_t szTag, IfdId szGroup) :
TiffEntryBase(tag, group), szTag_(szTag), szGroup_(szGroup) {
}
//! Virtual destructor.
~TiffDataEntryBase() override = default;
//@}
//! @name Manipulators
@ -790,8 +786,6 @@ class TiffSizeEntry : public TiffEntryBase {
TiffSizeEntry(uint16_t tag, IfdId group, uint16_t dtTag, IfdId dtGroup) :
TiffEntryBase(tag, group), dtTag_(dtTag), dtGroup_(dtGroup) {
}
//! Virtual destructor.
~TiffSizeEntry() override = default;
//@}
//! @name Accessors
@ -1420,8 +1414,6 @@ class TiffBinaryElement : public TiffEntryBase {
//@{
//! Constructor
TiffBinaryElement(uint16_t tag, IfdId group);
//! Virtual destructor.
~TiffBinaryElement() override = default;
//@}
//! @name Manipulators

View File

@ -227,7 +227,6 @@ void printNode(const std::string& schemaNs, const std::string& propPath, const s
//! Make an XMP key from a schema namespace and property path
Exiv2::XmpKey::UniquePtr makeXmpKey(const std::string& schemaNs, const std::string& propPath);
#endif // EXV_HAVE_XMP_TOOLKIT
//! Helper class used to serialize critical sections
class AutoLock {
@ -248,6 +247,7 @@ class AutoLock {
Exiv2::XmpParser::XmpLockFct xmpLockFct_;
void* pLockData_;
};
#endif // EXV_HAVE_XMP_TOOLKIT
} // namespace
// *****************************************************************************

View File

@ -52,4 +52,4 @@ TEST(AsfVideo, readMetadata) {
auto data = asf.xmpData();
ASSERT_FALSE(data.empty());
ASSERT_EQ(xmpData["Xmp.video.TotalStream"].count(), 4);
}
}

View File

@ -52,4 +52,4 @@ TEST(MatroskaVideo, readMetadata) {
auto data = mkv.xmpData();
ASSERT_FALSE(data.empty());
ASSERT_EQ(xmpData["Xmp.video.TotalStream"].count(), 4);
}
}

View File

@ -52,4 +52,4 @@ TEST(RiffVideo, readMetadata) {
auto data = riff.xmpData();
ASSERT_FALSE(data.empty());
ASSERT_EQ(xmpData["Xmp.video.TotalStream"].count(), 4);
}
}