clang-tidy: C casts to C++
Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
parent
a98954a98e
commit
cf963e9e4d
@ -137,7 +137,7 @@ int main(int argc, char* const argv[]) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// Create the required action class
|
// Create the required action class
|
||||||
auto task = Action::TaskFactory::instance().create(Action::TaskType(params.action_));
|
auto task = Action::TaskFactory::instance().create(static_cast<Action::TaskType>(params.action_));
|
||||||
|
|
||||||
// Process all files
|
// Process all files
|
||||||
auto filesCount = params.files_.size();
|
auto filesCount = params.files_.size();
|
||||||
|
|||||||
@ -31,10 +31,10 @@ int main(int argc, char* const argv[]) {
|
|||||||
// This is the quickest way to add (simple) Exif data. If a metadatum for
|
// This is the quickest way to add (simple) Exif data. If a metadatum for
|
||||||
// a given key already exists, its value is overwritten. Otherwise a new
|
// a given key already exists, its value is overwritten. Otherwise a new
|
||||||
// tag is added.
|
// tag is added.
|
||||||
exifData["Exif.Image.Model"] = "Test 1"; // AsciiValue
|
exifData["Exif.Image.Model"] = "Test 1"; // AsciiValue
|
||||||
exifData["Exif.Image.SamplesPerPixel"] = uint16_t(162); // UShortValue
|
exifData["Exif.Image.SamplesPerPixel"] = static_cast<uint16_t>(162); // UShortValue
|
||||||
exifData["Exif.Image.XResolution"] = -2; // LongValue
|
exifData["Exif.Image.XResolution"] = -2; // LongValue
|
||||||
exifData["Exif.Image.YResolution"] = Exiv2::Rational(-2, 3); // RationalValue
|
exifData["Exif.Image.YResolution"] = Exiv2::Rational(-2, 3); // RationalValue
|
||||||
std::cout << "Added a few tags the quick way.\n";
|
std::cout << "Added a few tags the quick way.\n";
|
||||||
|
|
||||||
// Create a ASCII string value (note the use of create)
|
// Create a ASCII string value (note the use of create)
|
||||||
|
|||||||
@ -34,9 +34,9 @@ int main(int argc, char* const argv[]) {
|
|||||||
std::cout << "Copy construction, non-intrusive changes\n";
|
std::cout << "Copy construction, non-intrusive changes\n";
|
||||||
Exiv2::ExifData ed1(ed);
|
Exiv2::ExifData ed1(ed);
|
||||||
ed1["Exif.Image.DateTime"] = "Sunday, 11am";
|
ed1["Exif.Image.DateTime"] = "Sunday, 11am";
|
||||||
ed1["Exif.Image.Orientation"] = uint16_t(2);
|
ed1["Exif.Image.Orientation"] = static_cast<uint16_t>(2);
|
||||||
ed1["Exif.Photo.DateTimeOriginal"] = "Sunday, 11am";
|
ed1["Exif.Photo.DateTimeOriginal"] = "Sunday, 11am";
|
||||||
ed1["Exif.Photo.MeteringMode"] = uint16_t(1);
|
ed1["Exif.Photo.MeteringMode"] = static_cast<uint16_t>(1);
|
||||||
ed1["Exif.Iop.InteroperabilityIndex"] = "123";
|
ed1["Exif.Iop.InteroperabilityIndex"] = "123";
|
||||||
// ed1["Exif.Thumbnail.Orientation"] = uint16_t(2);
|
// ed1["Exif.Thumbnail.Orientation"] = uint16_t(2);
|
||||||
write(file, ed1);
|
write(file, ed1);
|
||||||
@ -61,11 +61,11 @@ int main(int argc, char* const argv[]) {
|
|||||||
ed3["Exif.Thumbnail.Artist"] = "Test 6 Ifd1 tag";
|
ed3["Exif.Thumbnail.Artist"] = "Test 6 Ifd1 tag";
|
||||||
ed3 = ed;
|
ed3 = ed;
|
||||||
ed3["Exif.Image.DateTime"] = "Sunday, 11am";
|
ed3["Exif.Image.DateTime"] = "Sunday, 11am";
|
||||||
ed3["Exif.Image.Orientation"] = uint16_t(2);
|
ed3["Exif.Image.Orientation"] = static_cast<uint16_t>(2);
|
||||||
ed3["Exif.Photo.DateTimeOriginal"] = "Sunday, 11am";
|
ed3["Exif.Photo.DateTimeOriginal"] = "Sunday, 11am";
|
||||||
ed3["Exif.Photo.MeteringMode"] = uint16_t(1);
|
ed3["Exif.Photo.MeteringMode"] = static_cast<uint16_t>(1);
|
||||||
ed3["Exif.Iop.InteroperabilityIndex"] = "123";
|
ed3["Exif.Iop.InteroperabilityIndex"] = "123";
|
||||||
ed3["Exif.Thumbnail.Orientation"] = uint16_t(2);
|
ed3["Exif.Thumbnail.Orientation"] = static_cast<uint16_t>(2);
|
||||||
write(file, ed3);
|
write(file, ed3);
|
||||||
print(file);
|
print(file);
|
||||||
std::cout << "----------------------------------------------\n";
|
std::cout << "----------------------------------------------\n";
|
||||||
@ -78,9 +78,9 @@ int main(int argc, char* const argv[]) {
|
|||||||
ed4["Exif.Image.DateTime"] = "Sunday, 11am and ten minutes";
|
ed4["Exif.Image.DateTime"] = "Sunday, 11am and ten minutes";
|
||||||
ed4["Exif.Image.Orientation"] = "2 3 4 5";
|
ed4["Exif.Image.Orientation"] = "2 3 4 5";
|
||||||
ed4["Exif.Photo.DateTimeOriginal"] = "Sunday, 11am and ten minutes";
|
ed4["Exif.Photo.DateTimeOriginal"] = "Sunday, 11am and ten minutes";
|
||||||
ed4["Exif.Photo.MeteringMode"] = uint16_t(1);
|
ed4["Exif.Photo.MeteringMode"] = static_cast<uint16_t>(1);
|
||||||
ed4["Exif.Iop.InteroperabilityIndex"] = "123";
|
ed4["Exif.Iop.InteroperabilityIndex"] = "123";
|
||||||
ed4["Exif.Thumbnail.Orientation"] = uint16_t(2);
|
ed4["Exif.Thumbnail.Orientation"] = static_cast<uint16_t>(2);
|
||||||
write(file, ed4);
|
write(file, ed4);
|
||||||
print(file);
|
print(file);
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,7 @@ int main(int argc, char* const argv[]) try {
|
|||||||
iptcData["Iptc.Application2.Headline"] = "The headline I am";
|
iptcData["Iptc.Application2.Headline"] = "The headline I am";
|
||||||
iptcData["Iptc.Application2.Keywords"] = "Yet another keyword";
|
iptcData["Iptc.Application2.Keywords"] = "Yet another keyword";
|
||||||
iptcData["Iptc.Application2.DateCreated"] = "2004-8-3";
|
iptcData["Iptc.Application2.DateCreated"] = "2004-8-3";
|
||||||
iptcData["Iptc.Application2.Urgency"] = uint16_t(1);
|
iptcData["Iptc.Application2.Urgency"] = static_cast<uint16_t>(1);
|
||||||
iptcData["Iptc.Envelope.ModelVersion"] = 42;
|
iptcData["Iptc.Envelope.ModelVersion"] = 42;
|
||||||
iptcData["Iptc.Envelope.TimeSent"] = "14:41:0-05:00";
|
iptcData["Iptc.Envelope.TimeSent"] = "14:41:0-05:00";
|
||||||
iptcData["Iptc.Application2.RasterizedCaption"] = "230 42 34 2 90 84 23 146";
|
iptcData["Iptc.Application2.RasterizedCaption"] = "230 42 34 2 90 84 23 146";
|
||||||
|
|||||||
@ -34,12 +34,12 @@ int main(int argc, char* const argv[]) {
|
|||||||
// set/add metadata
|
// set/add metadata
|
||||||
std::cout << "Modify the metadata ...\n";
|
std::cout << "Modify the metadata ...\n";
|
||||||
Exiv2::ExifData exifData;
|
Exiv2::ExifData exifData;
|
||||||
exifData["Exif.Photo.UserComment"] = "Hello World"; // AsciiValue
|
exifData["Exif.Photo.UserComment"] = "Hello World"; // AsciiValue
|
||||||
exifData["Exif.Image.Software"] = "Exiv2"; // AsciiValue
|
exifData["Exif.Image.Software"] = "Exiv2"; // AsciiValue
|
||||||
exifData["Exif.Image.Copyright"] = "Exiv2"; // AsciiValue
|
exifData["Exif.Image.Copyright"] = "Exiv2"; // AsciiValue
|
||||||
exifData["Exif.Image.Make"] = "Canon"; // AsciiValue
|
exifData["Exif.Image.Make"] = "Canon"; // AsciiValue
|
||||||
exifData["Exif.Canon.OwnerName"] = "Tuan"; // UShortValue
|
exifData["Exif.Canon.OwnerName"] = "Tuan"; // UShortValue
|
||||||
exifData["Exif.CanonCs.LensType"] = uint16_t(65535); // LongValue
|
exifData["Exif.CanonCs.LensType"] = static_cast<uint16_t>(65535); // LongValue
|
||||||
Exiv2::Value::UniquePtr v = Exiv2::Value::create(Exiv2::asciiString);
|
Exiv2::Value::UniquePtr v = Exiv2::Value::create(Exiv2::asciiString);
|
||||||
v->read("2013:06:09 14:30:30");
|
v->read("2013:06:09 14:30:30");
|
||||||
Exiv2::ExifKey key("Exif.Image.DateTime");
|
Exiv2::ExifKey key("Exif.Image.DateTime");
|
||||||
|
|||||||
@ -56,11 +56,11 @@ int main(int argc, char* const argv[]) {
|
|||||||
edMn1["Exif.Image.Make"] = "Canon";
|
edMn1["Exif.Image.Make"] = "Canon";
|
||||||
edMn1["Exif.Image.Model"] = "Canon PowerShot S40";
|
edMn1["Exif.Image.Model"] = "Canon PowerShot S40";
|
||||||
edMn1["Exif.Canon.0xabcd"] = "A Canon makernote tag";
|
edMn1["Exif.Canon.0xabcd"] = "A Canon makernote tag";
|
||||||
edMn1["Exif.CanonCs.0x0002"] = uint16_t(41);
|
edMn1["Exif.CanonCs.0x0002"] = static_cast<uint16_t>(41);
|
||||||
edMn1["Exif.CanonSi.0x0005"] = uint16_t(42);
|
edMn1["Exif.CanonSi.0x0005"] = static_cast<uint16_t>(42);
|
||||||
edMn1["Exif.CanonCf.0x0001"] = uint16_t(43);
|
edMn1["Exif.CanonCf.0x0001"] = static_cast<uint16_t>(43);
|
||||||
edMn1["Exif.CanonPi.0x0001"] = uint16_t(44);
|
edMn1["Exif.CanonPi.0x0001"] = static_cast<uint16_t>(44);
|
||||||
edMn1["Exif.CanonPa.0x0001"] = uint16_t(45);
|
edMn1["Exif.CanonPa.0x0001"] = static_cast<uint16_t>(45);
|
||||||
write(file, edMn1);
|
write(file, edMn1);
|
||||||
print(file);
|
print(file);
|
||||||
|
|
||||||
@ -69,8 +69,8 @@ int main(int argc, char* const argv[]) {
|
|||||||
image->readMetadata();
|
image->readMetadata();
|
||||||
|
|
||||||
Exiv2::ExifData& rEd = image->exifData();
|
Exiv2::ExifData& rEd = image->exifData();
|
||||||
rEd["Exif.CanonCs.0x0001"] = uint16_t(88);
|
rEd["Exif.CanonCs.0x0001"] = static_cast<uint16_t>(88);
|
||||||
rEd["Exif.CanonSi.0x0004"] = uint16_t(99);
|
rEd["Exif.CanonSi.0x0004"] = static_cast<uint16_t>(99);
|
||||||
image->writeMetadata();
|
image->writeMetadata();
|
||||||
print(file);
|
print(file);
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ int main(int argc, char* const argv[]) {
|
|||||||
Exiv2::ExifData edMn7;
|
Exiv2::ExifData edMn7;
|
||||||
edMn7["Exif.Image.Make"] = "OLYMPUS CORPORATION";
|
edMn7["Exif.Image.Make"] = "OLYMPUS CORPORATION";
|
||||||
edMn7["Exif.Image.Model"] = "C8080WZ";
|
edMn7["Exif.Image.Model"] = "C8080WZ";
|
||||||
edMn7["Exif.Olympus.0x0201"] = uint16_t(1);
|
edMn7["Exif.Olympus.0x0201"] = static_cast<uint16_t>(1);
|
||||||
write(file, edMn7);
|
write(file, edMn7);
|
||||||
print(file);
|
print(file);
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ int main(int argc, char* const argv[]) {
|
|||||||
Exiv2::ExifData edMn8;
|
Exiv2::ExifData edMn8;
|
||||||
edMn8["Exif.Image.Make"] = "Panasonic";
|
edMn8["Exif.Image.Make"] = "Panasonic";
|
||||||
edMn8["Exif.Image.Model"] = "DMC-FZ5";
|
edMn8["Exif.Image.Model"] = "DMC-FZ5";
|
||||||
edMn8["Exif.Panasonic.0x0001"] = uint16_t(1);
|
edMn8["Exif.Panasonic.0x0001"] = static_cast<uint16_t>(1);
|
||||||
write(file, edMn8);
|
write(file, edMn8);
|
||||||
print(file);
|
print(file);
|
||||||
|
|
||||||
@ -142,13 +142,13 @@ int main(int argc, char* const argv[]) {
|
|||||||
Exiv2::ExifData edMn10;
|
Exiv2::ExifData edMn10;
|
||||||
edMn10["Exif.Image.Make"] = "Minolta";
|
edMn10["Exif.Image.Make"] = "Minolta";
|
||||||
edMn10["Exif.Image.Model"] = "A fancy Minolta camera";
|
edMn10["Exif.Image.Model"] = "A fancy Minolta camera";
|
||||||
edMn10["Exif.Minolta.ColorMode"] = uint32_t(1);
|
edMn10["Exif.Minolta.ColorMode"] = static_cast<uint32_t>(1);
|
||||||
edMn10["Exif.MinoltaCsNew.WhiteBalance"] = uint32_t(2);
|
edMn10["Exif.MinoltaCsNew.WhiteBalance"] = static_cast<uint32_t>(2);
|
||||||
edMn10["Exif.MinoltaCs5D.WhiteBalance"] = uint16_t(3);
|
edMn10["Exif.MinoltaCs5D.WhiteBalance"] = static_cast<uint16_t>(3);
|
||||||
edMn10["Exif.MinoltaCs5D.ColorTemperature"] = int16_t(-1);
|
edMn10["Exif.MinoltaCs5D.ColorTemperature"] = static_cast<int16_t>(-1);
|
||||||
edMn10["Exif.MinoltaCs7D.WhiteBalance"] = uint16_t(4);
|
edMn10["Exif.MinoltaCs7D.WhiteBalance"] = static_cast<uint16_t>(4);
|
||||||
edMn10["Exif.MinoltaCs7D.ExposureCompensation"] = int16_t(-2);
|
edMn10["Exif.MinoltaCs7D.ExposureCompensation"] = static_cast<int16_t>(-2);
|
||||||
edMn10["Exif.MinoltaCs7D.ColorTemperature"] = int16_t(-3);
|
edMn10["Exif.MinoltaCs7D.ColorTemperature"] = static_cast<int16_t>(-3);
|
||||||
write(file, edMn10);
|
write(file, edMn10);
|
||||||
print(file);
|
print(file);
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,7 @@ int main() try {
|
|||||||
xmpData["Xmp.dc.one"] = -1;
|
xmpData["Xmp.dc.one"] = -1;
|
||||||
xmpData["Xmp.dc.two"] = 3.1415;
|
xmpData["Xmp.dc.two"] = 3.1415;
|
||||||
xmpData["Xmp.dc.three"] = Exiv2::Rational(5, 7);
|
xmpData["Xmp.dc.three"] = Exiv2::Rational(5, 7);
|
||||||
xmpData["Xmp.dc.four"] = uint16_t(255);
|
xmpData["Xmp.dc.four"] = static_cast<uint16_t>(255);
|
||||||
xmpData["Xmp.dc.five"] = 256;
|
xmpData["Xmp.dc.five"] = 256;
|
||||||
xmpData["Xmp.dc.six"] = false;
|
xmpData["Xmp.dc.six"] = false;
|
||||||
|
|
||||||
|
|||||||
@ -1584,7 +1584,7 @@ bool convertStringCharsetIconv(std::string& str, const char* from, const char* t
|
|||||||
size_t outbytesleft = sizeof(outbuf);
|
size_t outbytesleft = sizeof(outbuf);
|
||||||
size_t rc = iconv(cd, &inptr, &inbytesleft, &outptr, &outbytesleft);
|
size_t rc = iconv(cd, &inptr, &inbytesleft, &outptr, &outbytesleft);
|
||||||
const size_t outbytesProduced = sizeof(outbuf) - outbytesleft;
|
const size_t outbytesProduced = sizeof(outbuf) - outbytesleft;
|
||||||
if (rc == size_t(-1) && errno != E2BIG) {
|
if (rc == static_cast<size_t>(-1) && errno != E2BIG) {
|
||||||
#ifndef SUPPRESS_WARNINGS
|
#ifndef SUPPRESS_WARNINGS
|
||||||
EXV_WARNING << "iconv: " << strError() << " inbytesleft = " << inbytesleft << "\n";
|
EXV_WARNING << "iconv: " << strError() << " inbytesleft = " << inbytesleft << "\n";
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -108,7 +108,7 @@ void CrwParser::decode(CrwImage* pCrwImage, const byte* pData, size_t size) {
|
|||||||
// a hack to get absolute offset of preview image inside CRW structure
|
// a hack to get absolute offset of preview image inside CRW structure
|
||||||
auto preview = header.findComponent(0x2007, 0x0000);
|
auto preview = header.findComponent(0x2007, 0x0000);
|
||||||
if (preview) {
|
if (preview) {
|
||||||
(pCrwImage->exifData())["Exif.Image2.JPEGInterchangeFormat"] = uint32_t(preview->pData() - pData);
|
(pCrwImage->exifData())["Exif.Image2.JPEGInterchangeFormat"] = static_cast<uint32_t>(preview->pData() - pData);
|
||||||
(pCrwImage->exifData())["Exif.Image2.JPEGInterchangeFormatLength"] = static_cast<uint32_t>(preview->size());
|
(pCrwImage->exifData())["Exif.Image2.JPEGInterchangeFormatLength"] = static_cast<uint32_t>(preview->size());
|
||||||
}
|
}
|
||||||
} // CrwParser::decode
|
} // CrwParser::decode
|
||||||
|
|||||||
@ -301,7 +301,7 @@ int Exifdatum::ifdId() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char* Exifdatum::ifdName() const {
|
const char* Exifdatum::ifdName() const {
|
||||||
return key_ ? Internal::ifdName(Internal::IfdId(key_->ifdId())) : "";
|
return key_ ? Internal::ifdName(static_cast<Internal::IfdId>(key_->ifdId())) : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
int Exifdatum::idx() const {
|
int Exifdatum::idx() const {
|
||||||
@ -422,11 +422,11 @@ void ExifThumb::setJpegThumbnail(const std::string& path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ExifThumb::setJpegThumbnail(const byte* buf, size_t size) {
|
void ExifThumb::setJpegThumbnail(const byte* buf, size_t size) {
|
||||||
exifData_["Exif.Thumbnail.Compression"] = uint16_t(6);
|
exifData_["Exif.Thumbnail.Compression"] = static_cast<uint16_t>(6);
|
||||||
Exifdatum& format = exifData_["Exif.Thumbnail.JPEGInterchangeFormat"];
|
Exifdatum& format = exifData_["Exif.Thumbnail.JPEGInterchangeFormat"];
|
||||||
format = uint32_t(0);
|
format = static_cast<uint32_t>(0);
|
||||||
format.setDataArea(buf, size);
|
format.setDataArea(buf, size);
|
||||||
exifData_["Exif.Thumbnail.JPEGInterchangeFormatLength"] = uint32_t(size);
|
exifData_["Exif.Thumbnail.JPEGInterchangeFormatLength"] = static_cast<uint32_t>(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExifThumb::erase() {
|
void ExifThumb::erase() {
|
||||||
|
|||||||
@ -336,7 +336,7 @@ int Exiv2::http(Exiv2::Dictionary& request, Exiv2::Dictionary& response, std::st
|
|||||||
|
|
||||||
if (n != FINISH || !OK(status)) {
|
if (n != FINISH || !OK(status)) {
|
||||||
snprintf(buffer, sizeof buffer, "wsa_error = %d,n = %d,sleep_ = %d status = %d", WSAGetLastError(), n,
|
snprintf(buffer, sizeof buffer, "wsa_error = %d,n = %d,sleep_ = %d status = %d", WSAGetLastError(), n,
|
||||||
int(sleep_.count()), status);
|
static_cast<int>(sleep_.count()), status);
|
||||||
error(errors, buffer, nullptr, nullptr, 0);
|
error(errors, buffer, nullptr, nullptr, 0);
|
||||||
} else if (bSearching && OK(status)) {
|
} else if (bSearching && OK(status)) {
|
||||||
if (end) {
|
if (end) {
|
||||||
|
|||||||
@ -1036,7 +1036,7 @@ const Exiv2::Value* getExifValue(Exiv2::Internal::TiffComponent* pRoot, const ui
|
|||||||
std::string getExifModel(Exiv2::Internal::TiffComponent* pRoot) {
|
std::string getExifModel(Exiv2::Internal::TiffComponent* pRoot) {
|
||||||
// Lookup the Exif.Image.Model tag
|
// Lookup the Exif.Image.Model tag
|
||||||
const auto value = getExifValue(pRoot, 0x0110, Exiv2::Internal::ifd0Id);
|
const auto value = getExifValue(pRoot, 0x0110, Exiv2::Internal::ifd0Id);
|
||||||
return (!value || value->count() == 0) ? std::string("") : std::string(value->toString());
|
return (!value || value->count() == 0) ? std::string("") : static_cast<std::string>(value->toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ncrypt(Exiv2::byte* pData, uint32_t size, uint32_t count, uint32_t serial) {
|
void ncrypt(Exiv2::byte* pData, uint32_t size, uint32_t count, uint32_t serial) {
|
||||||
|
|||||||
@ -583,7 +583,7 @@ std::ostream& MinoltaMakerNote::printMinoltaExposureManualBias5D(std::ostream& o
|
|||||||
std::ios::fmtflags f(os.flags());
|
std::ios::fmtflags f(os.flags());
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss.copyfmt(os);
|
oss.copyfmt(os);
|
||||||
os << std::fixed << std::setprecision(2) << (float(value.toInt64() - 128) / 24);
|
os << std::fixed << std::setprecision(2) << (static_cast<float>(value.toInt64() - 128) / 24);
|
||||||
os.copyfmt(oss);
|
os.copyfmt(oss);
|
||||||
os.flags(f);
|
os.flags(f);
|
||||||
return os;
|
return os;
|
||||||
@ -595,7 +595,7 @@ std::ostream& MinoltaMakerNote::printMinoltaExposureCompensation5D(std::ostream&
|
|||||||
std::ios::fmtflags f(os.flags());
|
std::ios::fmtflags f(os.flags());
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss.copyfmt(os);
|
oss.copyfmt(os);
|
||||||
os << std::fixed << std::setprecision(2) << (float(value.toInt64() - 300) / 100);
|
os << std::fixed << std::setprecision(2) << (static_cast<float>(value.toInt64() - 300) / 100);
|
||||||
os.copyfmt(oss);
|
os.copyfmt(oss);
|
||||||
os.flags(f);
|
os.flags(f);
|
||||||
return os;
|
return os;
|
||||||
|
|||||||
@ -3013,7 +3013,7 @@ std::ostream& Nikon3MakerNote::printFlashCompensation(std::ostream& os, const Va
|
|||||||
}
|
}
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss.copyfmt(os);
|
oss.copyfmt(os);
|
||||||
float temp = (value.toFloat() / float(-6.0));
|
float temp = (value.toFloat() / static_cast<float>(-6.0));
|
||||||
|
|
||||||
if (temp == 0)
|
if (temp == 0)
|
||||||
os << 0;
|
os << 0;
|
||||||
@ -3064,7 +3064,7 @@ std::ostream& Nikon3MakerNote::printFlashGroupAData(std::ostream& os, const Valu
|
|||||||
|
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss.copyfmt(os);
|
oss.copyfmt(os);
|
||||||
double temp = value.toFloat() / double(-6.0);
|
double temp = value.toFloat() / (-6.0);
|
||||||
|
|
||||||
auto pos = metadata->findKey(ExifKey("Exif.NikonFl7.FlashGroupAControlData"));
|
auto pos = metadata->findKey(ExifKey("Exif.NikonFl7.FlashGroupAControlData"));
|
||||||
if (pos == metadata->end() || pos->count() != 1 || pos->typeId() != unsignedByte) {
|
if (pos == metadata->end() || pos->count() != 1 || pos->typeId() != unsignedByte) {
|
||||||
@ -3100,7 +3100,7 @@ std::ostream& Nikon3MakerNote::printFlashGroupBData(std::ostream& os, const Valu
|
|||||||
|
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss.copyfmt(os);
|
oss.copyfmt(os);
|
||||||
double temp = value.toFloat() / double(-6.0);
|
double temp = value.toFloat() / (-6.0);
|
||||||
|
|
||||||
auto pos = metadata->findKey(ExifKey("Exif.NikonFl7.FlashGroupBCControlData"));
|
auto pos = metadata->findKey(ExifKey("Exif.NikonFl7.FlashGroupBCControlData"));
|
||||||
if (pos == metadata->end() || pos->count() != 1 || pos->typeId() != unsignedByte) {
|
if (pos == metadata->end() || pos->count() != 1 || pos->typeId() != unsignedByte) {
|
||||||
@ -3136,7 +3136,7 @@ std::ostream& Nikon3MakerNote::printFlashGroupCData(std::ostream& os, const Valu
|
|||||||
|
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss.copyfmt(os);
|
oss.copyfmt(os);
|
||||||
double temp = value.toFloat() / double(-6.0);
|
double temp = value.toFloat() / (-6.0);
|
||||||
|
|
||||||
auto pos = metadata->findKey(ExifKey("Exif.NikonFl7.FlashGroupBCControlData"));
|
auto pos = metadata->findKey(ExifKey("Exif.NikonFl7.FlashGroupBCControlData"));
|
||||||
if (pos == metadata->end() || pos->count() != 1 || pos->typeId() != unsignedByte) {
|
if (pos == metadata->end() || pos->count() != 1 || pos->typeId() != unsignedByte) {
|
||||||
@ -3172,8 +3172,8 @@ std::ostream& Nikon3MakerNote::printTimeZone(std::ostream& os, const Value& valu
|
|||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss.copyfmt(os);
|
oss.copyfmt(os);
|
||||||
char sign = value.toInt64() < 0 ? '-' : '+';
|
char sign = value.toInt64() < 0 ? '-' : '+';
|
||||||
long h = long(std::abs(static_cast<int>(value.toFloat() / 60.0F))) % 24;
|
long h = static_cast<long>(std::abs(static_cast<int>(value.toFloat() / 60.0F))) % 24;
|
||||||
long min = long(std::abs(static_cast<int>(value.toFloat() - h * 60))) % 60;
|
long min = static_cast<long>(std::abs(static_cast<int>(value.toFloat() - h * 60))) % 60;
|
||||||
os << std::fixed << "UTC " << sign << std::setw(2) << std::setfill('0') << h << ":" << std::setw(2)
|
os << std::fixed << "UTC " << sign << std::setw(2) << std::setfill('0') << h << ":" << std::setw(2)
|
||||||
<< std::setfill('0') << min;
|
<< std::setfill('0') << min;
|
||||||
os.copyfmt(oss);
|
os.copyfmt(oss);
|
||||||
|
|||||||
@ -224,7 +224,7 @@ void PngImage::printStructure(std::ostream& out, PrintStructureOption option, in
|
|||||||
|
|
||||||
// test that we haven't hit EOF, or wanting to read excessive data
|
// test that we haven't hit EOF, or wanting to read excessive data
|
||||||
long restore = io_->tell();
|
long restore = io_->tell();
|
||||||
if (restore == -1 || dataOffset > uint32_t(0x7FFFFFFF) || dataOffset > imgSize - restore) {
|
if (restore == -1 || dataOffset > static_cast<uint32_t>(0x7FFFFFFF) || dataOffset > imgSize - restore) {
|
||||||
throw Exiv2::Error(ErrorCode::kerFailedToReadImageData);
|
throw Exiv2::Error(ErrorCode::kerFailedToReadImageData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -408,7 +408,7 @@ void PngImage::readMetadata() {
|
|||||||
// Decode chunk data length.
|
// Decode chunk data length.
|
||||||
uint32_t chunkLength = cheaderBuf.read_uint32(0, Exiv2::bigEndian);
|
uint32_t chunkLength = cheaderBuf.read_uint32(0, Exiv2::bigEndian);
|
||||||
long pos = io_->tell();
|
long pos = io_->tell();
|
||||||
if (pos == -1 || chunkLength > uint32_t(0x7FFFFFFF) || chunkLength > imgSize - pos) {
|
if (pos == -1 || chunkLength > static_cast<uint32_t>(0x7FFFFFFF) || chunkLength > imgSize - pos) {
|
||||||
throw Exiv2::Error(ErrorCode::kerFailedToReadImageData);
|
throw Exiv2::Error(ErrorCode::kerFailedToReadImageData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -349,7 +349,7 @@ PreviewProperties Loader::getProperties() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PreviewId Loader::getNumLoaders() {
|
PreviewId Loader::getNumLoaders() {
|
||||||
return PreviewId(std::size(loaderList_));
|
return static_cast<PreviewId>(std::size(loaderList_));
|
||||||
}
|
}
|
||||||
|
|
||||||
LoaderNative::LoaderNative(PreviewId id, const Image& image, int parIdx) : Loader(id, image) {
|
LoaderNative::LoaderNative(PreviewId id, const Image& image, int parIdx) : Loader(id, image) {
|
||||||
@ -753,7 +753,7 @@ DataBuf LoaderTiff::getData() const {
|
|||||||
|
|
||||||
// Fix compression value in the CR2 IFD2 image
|
// Fix compression value in the CR2 IFD2 image
|
||||||
if (0 == strcmp(group_, "Image2") && image_.mimeType() == "image/x-canon-cr2") {
|
if (0 == strcmp(group_, "Image2") && image_.mimeType() == "image/x-canon-cr2") {
|
||||||
preview["Exif.Image.Compression"] = uint16_t(1);
|
preview["Exif.Image.Compression"] = static_cast<uint16_t>(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// write new image
|
// write new image
|
||||||
|
|||||||
@ -46,7 +46,7 @@ namespace Internal {
|
|||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct is_signed {
|
struct is_signed {
|
||||||
enum { VALUE = T(-1) < T(0) };
|
enum { VALUE = static_cast<T>(-1) < static_cast<T>(0) };
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@ -54,7 +54,7 @@ void IoWrapper::setTarget(int id, int64_t target) {
|
|||||||
throw Error(ErrorCode::kerOffsetOutOfRange);
|
throw Error(ErrorCode::kerOffsetOutOfRange);
|
||||||
}
|
}
|
||||||
if (pow_)
|
if (pow_)
|
||||||
pow_->setTarget(OffsetWriter::OffsetId(id), static_cast<uint32_t>(target));
|
pow_->setTarget(static_cast<OffsetWriter::OffsetId>(id), static_cast<uint32_t>(target));
|
||||||
}
|
}
|
||||||
|
|
||||||
TiffComponent::TiffComponent(uint16_t tag, IfdId group) : tag_(tag), group_(group) {
|
TiffComponent::TiffComponent(uint16_t tag, IfdId group) : tag_(tag), group_(group) {
|
||||||
@ -388,7 +388,7 @@ bool TiffBinaryArray::initialize(IfdId group) {
|
|||||||
if (arraySet_[idx].cfg_.group_ == group) {
|
if (arraySet_[idx].cfg_.group_ == group) {
|
||||||
arrayCfg_ = &arraySet_[idx].cfg_;
|
arrayCfg_ = &arraySet_[idx].cfg_;
|
||||||
arrayDef_ = arraySet_[idx].def_;
|
arrayDef_ = arraySet_[idx].def_;
|
||||||
defSize_ = int(arraySet_[idx].defSize_);
|
defSize_ = static_cast<int>(arraySet_[idx].defSize_);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -403,7 +403,7 @@ bool TiffBinaryArray::initialize(TiffComponent* pRoot) {
|
|||||||
if (idx > -1) {
|
if (idx > -1) {
|
||||||
arrayCfg_ = &arraySet_[idx].cfg_;
|
arrayCfg_ = &arraySet_[idx].cfg_;
|
||||||
arrayDef_ = arraySet_[idx].def_;
|
arrayDef_ = arraySet_[idx].def_;
|
||||||
defSize_ = int(arraySet_[idx].defSize_);
|
defSize_ = static_cast<int>(arraySet_[idx].defSize_);
|
||||||
}
|
}
|
||||||
return idx > -1;
|
return idx > -1;
|
||||||
}
|
}
|
||||||
@ -825,7 +825,7 @@ uint32_t TiffComponent::write(IoWrapper& ioWrapper, ByteOrder byteOrder, int64_t
|
|||||||
|
|
||||||
uint32_t TiffDirectory::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int64_t offset, uint32_t valueIdx,
|
uint32_t TiffDirectory::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int64_t offset, uint32_t valueIdx,
|
||||||
uint32_t dataIdx, uint32_t& imageIdx) {
|
uint32_t dataIdx, uint32_t& imageIdx) {
|
||||||
bool isRootDir = (imageIdx == uint32_t(-1));
|
bool isRootDir = (imageIdx == static_cast<uint32_t>(-1));
|
||||||
|
|
||||||
// Number of components to write
|
// Number of components to write
|
||||||
const size_t compCount = count();
|
const size_t compCount = count();
|
||||||
@ -935,7 +935,8 @@ uint32_t TiffDirectory::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int64
|
|||||||
|
|
||||||
// 4th: Write next-IFD
|
// 4th: Write next-IFD
|
||||||
if (pNext_ && sizeNext) {
|
if (pNext_ && sizeNext) {
|
||||||
idx += pNext_->write(ioWrapper, byteOrder, offset + idx, uint32_t(-1), uint32_t(-1), imageIdx);
|
idx += pNext_->write(ioWrapper, byteOrder, offset + idx, static_cast<uint32_t>(-1), static_cast<uint32_t>(-1),
|
||||||
|
imageIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5th, at the root directory level only: write image data
|
// 5th, at the root directory level only: write image data
|
||||||
@ -1065,7 +1066,8 @@ uint32_t TiffMnEntry::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int64_t
|
|||||||
if (!mn_) {
|
if (!mn_) {
|
||||||
return TiffEntryBase::doWrite(ioWrapper, byteOrder, offset, valueIdx, dataIdx, imageIdx);
|
return TiffEntryBase::doWrite(ioWrapper, byteOrder, offset, valueIdx, dataIdx, imageIdx);
|
||||||
}
|
}
|
||||||
return mn_->write(ioWrapper, byteOrder, offset + valueIdx, uint32_t(-1), uint32_t(-1), imageIdx);
|
return mn_->write(ioWrapper, byteOrder, offset + valueIdx, static_cast<uint32_t>(-1), static_cast<uint32_t>(-1),
|
||||||
|
imageIdx);
|
||||||
} // TiffMnEntry::doWrite
|
} // TiffMnEntry::doWrite
|
||||||
|
|
||||||
uint32_t TiffIfdMakernote::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int64_t offset, uint32_t /*valueIdx*/,
|
uint32_t TiffIfdMakernote::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int64_t offset, uint32_t /*valueIdx*/,
|
||||||
@ -1073,7 +1075,8 @@ uint32_t TiffIfdMakernote::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, in
|
|||||||
mnOffset_ = static_cast<uint32_t>(offset);
|
mnOffset_ = static_cast<uint32_t>(offset);
|
||||||
setImageByteOrder(byteOrder);
|
setImageByteOrder(byteOrder);
|
||||||
auto len = static_cast<uint32_t>(writeHeader(ioWrapper, this->byteOrder()));
|
auto len = static_cast<uint32_t>(writeHeader(ioWrapper, this->byteOrder()));
|
||||||
len += ifd_.write(ioWrapper, this->byteOrder(), offset - baseOffset() + len, uint32_t(-1), uint32_t(-1), imageIdx);
|
len += ifd_.write(ioWrapper, this->byteOrder(), offset - baseOffset() + len, static_cast<uint32_t>(-1),
|
||||||
|
static_cast<uint32_t>(-1), imageIdx);
|
||||||
return len;
|
return len;
|
||||||
} // TiffIfdMakernote::doWrite
|
} // TiffIfdMakernote::doWrite
|
||||||
|
|
||||||
@ -1196,7 +1199,8 @@ uint32_t TiffSubIfd::doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, int6
|
|||||||
uint32_t& imageIdx) const {
|
uint32_t& imageIdx) const {
|
||||||
uint32_t len = 0;
|
uint32_t len = 0;
|
||||||
for (auto&& ifd : ifds_) {
|
for (auto&& ifd : ifds_) {
|
||||||
len += ifd->write(ioWrapper, byteOrder, offset + dataIdx + len, uint32_t(-1), uint32_t(-1), imageIdx);
|
len += ifd->write(ioWrapper, byteOrder, offset + dataIdx + len, static_cast<uint32_t>(-1),
|
||||||
|
static_cast<uint32_t>(-1), imageIdx);
|
||||||
}
|
}
|
||||||
// Align data to word boundary
|
// Align data to word boundary
|
||||||
uint32_t align = (len & 1);
|
uint32_t align = (len & 1);
|
||||||
@ -1484,7 +1488,7 @@ static const TagInfo* findTagInfo(uint16_t tag, IfdId group) {
|
|||||||
// *************************************************************************
|
// *************************************************************************
|
||||||
// free functions
|
// free functions
|
||||||
TypeId toTypeId(TiffType tiffType, uint16_t tag, IfdId group) {
|
TypeId toTypeId(TiffType tiffType, uint16_t tag, IfdId group) {
|
||||||
auto ti = TypeId(tiffType);
|
auto ti = static_cast<TypeId>(tiffType);
|
||||||
// On the fly type conversion for Exif.Photo.UserComment, Exif.GPSProcessingMethod, GPSAreaInformation
|
// On the fly type conversion for Exif.Photo.UserComment, Exif.GPSProcessingMethod, GPSAreaInformation
|
||||||
if (const TagInfo* pTag = ti == undefined ? findTagInfo(tag, group) : nullptr) {
|
if (const TagInfo* pTag = ti == undefined ? findTagInfo(tag, group) : nullptr) {
|
||||||
if (pTag->typeId_ == comment) {
|
if (pTag->typeId_ == comment) {
|
||||||
|
|||||||
@ -1892,8 +1892,9 @@ WriteMethod TiffParserWorker::encode(BasicIo& io, const byte* pData, size_t size
|
|||||||
DataBuf header = pHeader->write();
|
DataBuf header = pHeader->write();
|
||||||
auto tempIo = MemIo();
|
auto tempIo = MemIo();
|
||||||
IoWrapper ioWrapper(tempIo, header.c_data(), header.size(), pOffsetWriter);
|
IoWrapper ioWrapper(tempIo, header.c_data(), header.size(), pOffsetWriter);
|
||||||
auto imageIdx(uint32_t(-1));
|
auto imageIdx(static_cast<uint32_t>(-1));
|
||||||
createdTree->write(ioWrapper, pHeader->byteOrder(), header.size(), uint32_t(-1), uint32_t(-1), imageIdx);
|
createdTree->write(ioWrapper, pHeader->byteOrder(), header.size(), static_cast<uint32_t>(-1),
|
||||||
|
static_cast<uint32_t>(-1), imageIdx);
|
||||||
if (pOffsetWriter)
|
if (pOffsetWriter)
|
||||||
pOffsetWriter->writeOffsets(tempIo);
|
pOffsetWriter->writeOffsets(tempIo);
|
||||||
io.transfer(tempIo); // may throw
|
io.transfer(tempIo); // may throw
|
||||||
|
|||||||
@ -465,7 +465,7 @@ void hexdump(std::ostream& os, const byte* buf, size_t len, size_t offset) {
|
|||||||
do {
|
do {
|
||||||
byte c = buf[i];
|
byte c = buf[i];
|
||||||
os << std::setw(2) << std::setfill('0') << std::right << std::hex << static_cast<int>(c) << " ";
|
os << std::setw(2) << std::setfill('0') << std::right << std::hex << static_cast<int>(c) << " ";
|
||||||
ss << (static_cast<int>(c) >= 31 && static_cast<int>(c) < 127 ? char(buf[i]) : '.');
|
ss << (static_cast<int>(c) >= 31 && static_cast<int>(c) < 127 ? static_cast<char>(buf[i]) : '.');
|
||||||
} while (++i < len && i % 16 != 0);
|
} while (++i < len && i % 16 != 0);
|
||||||
std::string::size_type width = 9 + ((i - 1) % 16 + 1) * 3;
|
std::string::size_type width = 9 + ((i - 1) % 16 + 1) * 3;
|
||||||
os << (width > pos ? "" : align.substr(width)) << ss.str() << "\n";
|
os << (width > pos ? "" : align.substr(width)) << ss.str() << "\n";
|
||||||
|
|||||||
@ -23,8 +23,8 @@ namespace {
|
|||||||
[[maybe_unused]] std::string binaryToHex(const uint8_t* data, size_t size) {
|
[[maybe_unused]] std::string binaryToHex(const uint8_t* data, size_t size) {
|
||||||
std::stringstream hexOutput;
|
std::stringstream hexOutput;
|
||||||
|
|
||||||
auto tl = size_t(size / 16) * 16;
|
auto tl = static_cast<size_t>(size / 16) * 16;
|
||||||
auto tl_offset = size_t(size) - tl;
|
auto tl_offset = size - tl;
|
||||||
|
|
||||||
for (size_t loop = 0; loop < size; loop++) {
|
for (size_t loop = 0; loop < size; loop++) {
|
||||||
if (data[loop] < 16) {
|
if (data[loop] < 16) {
|
||||||
@ -37,8 +37,8 @@ namespace {
|
|||||||
if ((loop % 16) == 15 || loop == (tl + tl_offset - 1)) {
|
if ((loop % 16) == 15 || loop == (tl + tl_offset - 1)) {
|
||||||
int max = 15;
|
int max = 15;
|
||||||
if (loop >= tl) {
|
if (loop >= tl) {
|
||||||
max = int(tl_offset) - 1;
|
max = static_cast<int>(tl_offset) - 1;
|
||||||
for (int offset = 0; offset < int(16 - tl_offset); offset++) {
|
for (int offset = 0; offset < static_cast<int>(16 - tl_offset); offset++) {
|
||||||
if ((offset % 8) == 7) {
|
if ((offset % 8) == 7) {
|
||||||
hexOutput << " ";
|
hexOutput << " ";
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user