From 77e79b32f5a7adccc1977fc160ed4d286a0a03b3 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 5 Mar 2022 01:07:36 -0800 Subject: [PATCH 1/9] manual braced init conversion clang-tidy's not converting these for some reason. Signed-off-by: Rosen Penev --- samples/geotag.cpp | 8 ++++---- src/helper_functions.cpp | 2 +- src/pngchunk_int.cpp | 2 +- src/preview.cpp | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/samples/geotag.cpp b/samples/geotag.cpp index c94dbb32..2a18be4f 100644 --- a/samples/geotag.cpp +++ b/samples/geotag.cpp @@ -230,7 +230,7 @@ std::string Position::toExifTimeStamp(std::string& t) sscanf(arg,"%d%c%d%c%d%c%d%c%d%c%d",&YY,&a,&MM,&b,&DD,&c,&HH,&d,&mm,&e,&SS1); } snprintf(result,sizeof(result),"%d/1 %d/1 %d/1",HH,mm,SS1); - return std::string(result); + return result; } std::string Position::toExifString(double d) @@ -238,7 +238,7 @@ std::string Position::toExifString(double d) char result[200]; d *= 100; snprintf(result, sizeof(result), "%d/100", abs(static_cast(d))); - return std::string(result); + return result; } std::string Position::toExifString(double d,bool bRational,bool bLat) @@ -259,7 +259,7 @@ std::string Position::toExifString(double d,bool bRational,bool bLat) snprintf(result,sizeof(result),"%d/1 %d/1 %d/1" ,deg,min,sec); else snprintf(result,sizeof(result),"%03d%s%02d'%02d\"%s" ,deg,gDeg,min,sec,NSEW); - return std::string(result); + return result; } std::string Position::toString() const @@ -268,7 +268,7 @@ std::string Position::toString() const std::string sLat = Position::toExifString(lat_,false,true ); std::string sLon = Position::toExifString(lon_,false,false); snprintf(result,sizeof(result),"%s %s %-8.3f",sLon.c_str(),sLat.c_str(),ele_); - return std::string(result); + return result; } // defaults diff --git a/src/helper_functions.cpp b/src/helper_functions.cpp index 413664c5..07820fc1 100644 --- a/src/helper_functions.cpp +++ b/src/helper_functions.cpp @@ -9,5 +9,5 @@ std::string string_from_unterminated(const char* data, size_t data_length) return {}; } const size_t StringLength = strnlen(data, data_length); - return std::string(data, StringLength); + return {data, StringLength}; } diff --git a/src/pngchunk_int.cpp b/src/pngchunk_int.cpp index 81cdfcae..64b996e0 100644 --- a/src/pngchunk_int.cpp +++ b/src/pngchunk_int.cpp @@ -425,7 +425,7 @@ namespace Exiv2::Internal { } } while (zlibResult == Z_BUF_ERROR); - return std::string(arr.c_str(), arr.size()); + return {arr.c_str(), arr.size()}; } // PngChunk::zlibCompress diff --git a/src/preview.cpp b/src/preview.cpp index 9f62f54a..44c79751 100644 --- a/src/preview.cpp +++ b/src/preview.cpp @@ -1129,6 +1129,6 @@ namespace Exiv2 { buf = loader->getData(); } - return PreviewImage(properties, std::move(buf)); + return {properties, std::move(buf)}; } } // namespace Exiv2 From e6d3315160fee55fdc26d573d99f7754b5e8cbcb Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 5 Mar 2022 01:10:01 -0800 Subject: [PATCH 2/9] clang-tidy: use emplace_back Signed-off-by: Rosen Penev --- src/version.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.cpp b/src/version.cpp index 12c1ce76..e14648ac 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -194,7 +194,7 @@ static std::vector getLoadedLibraries() } #endif if (libs.empty()) - libs.push_back("unknown"); + libs.emplace_back("unknown"); return libs; } From 5833101b9b278480533584fd8f23694ce9591200 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 5 Mar 2022 01:13:43 -0800 Subject: [PATCH 3/9] manual nullptr conversions Mostly not caught because I'm not running clang-tidy on Windows. Signed-off-by: Rosen Penev --- include/exiv2/slice.hpp | 4 +--- samples/exifprint.cpp | 2 +- src/basicio.cpp | 6 +++-- src/futils.cpp | 22 +++++++++---------- src/makernote_int.cpp | 2 +- src/tiffcomposite_int.cpp | 2 +- src/version.cpp | 4 ++-- src/xmp.cpp | 46 +++++++++++++++++++-------------------- 8 files changed, 44 insertions(+), 44 deletions(-) diff --git a/include/exiv2/slice.hpp b/include/exiv2/slice.hpp index c533d231..f6cbfa24 100644 --- a/include/exiv2/slice.hpp +++ b/include/exiv2/slice.hpp @@ -248,7 +248,6 @@ namespace Exiv2 const value_type& at(size_t index) const { - // TODO: use using base_type::at once we have C++11 return base_type::at(index); } @@ -412,8 +411,7 @@ namespace Exiv2 */ PtrSliceStorage(storage_type ptr, size_t /*begin*/, size_t /*end*/) : data_(ptr) { - // TODO: change this to nullptr once we use C++11 - if (ptr == NULL) { + if (!ptr) { throw std::invalid_argument("Null pointer passed to slice constructor"); } } diff --git a/samples/exifprint.cpp b/samples/exifprint.cpp index 1a7e8f67..65ff5e47 100644 --- a/samples/exifprint.cpp +++ b/samples/exifprint.cpp @@ -29,7 +29,7 @@ static const Exiv2::TagInfo* findTag(const Exiv2::TagInfo* pList,uint16_t tag) { while ( pList->tag_ != 0xffff && pList->tag_ != tag ) pList++; - return pList->tag_ != 0xffff ? pList : NULL; + return pList->tag_ != 0xffff ? pList : nullptr; } diff --git a/src/basicio.cpp b/src/basicio.cpp index 921f570e..bb1744d2 100644 --- a/src/basicio.cpp +++ b/src/basicio.cpp @@ -375,7 +375,8 @@ namespace Exiv2 { if (hKernel) { ReplaceFileA_t pfcn_ReplaceFileA = (ReplaceFileA_t)GetProcAddress(hKernel, "ReplaceFileA"); if (pfcn_ReplaceFileA) { - BOOL ret = pfcn_ReplaceFileA(pf, fileIo->path().c_str(), NULL, REPLACEFILE_IGNORE_MERGE_ERRORS, NULL, NULL); + BOOL ret = pfcn_ReplaceFileA(pf, fileIo->path().c_str(), nullptr, + REPLACEFILE_IGNORE_MERGE_ERRORS, nullptr, nullptr); if (ret == 0) { if (GetLastError() == ERROR_FILE_NOT_FOUND) { fs::rename(fileIo->path().c_str(), pf); @@ -1834,7 +1835,8 @@ namespace Exiv2 { size_t curlWriter(char* data, size_t size, size_t nmemb, std::string* writerData) { - if (writerData == NULL) return 0; + if (writerData == nullptr) + return 0; writerData->append(data, size*nmemb); return size * nmemb; } diff --git a/src/futils.cpp b/src/futils.cpp index 4640df80..34f76f39 100644 --- a/src/futils.cpp +++ b/src/futils.cpp @@ -354,28 +354,28 @@ namespace Exiv2 { { std::string ret("unknown"); #if defined(WIN32) - HANDLE processHandle = NULL; + HANDLE processHandle = nullptr; processHandle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, GetCurrentProcessId()); - if (processHandle != NULL) { + if (processHandle) { TCHAR filename[MAX_PATH]; - if (GetModuleFileNameEx(processHandle, NULL, filename, MAX_PATH) != 0) { + if (GetModuleFileNameEx(processHandle, nullptr, filename, MAX_PATH) != 0) { ret = filename; } CloseHandle(processHandle); } - #elif defined(__APPLE__) - #ifdef EXV_HAVE_LIBPROC_H +#elif defined(__APPLE__) +#ifdef EXV_HAVE_LIBPROC_H const int pid = getpid(); char pathbuf[PROC_PIDPATHINFO_MAXSIZE]; if (proc_pidpath (pid, pathbuf, sizeof(pathbuf)) > 0) { ret = pathbuf; } - #endif - #elif defined(__FreeBSD__) +#endif +#elif defined(__FreeBSD__) unsigned int n; char buffer[PATH_MAX] = {}; struct procstat* procstat = procstat_open_sysctl(); - struct kinfo_proc* procs = procstat ? procstat_getprocs(procstat, KERN_PROC_PID, getpid(), &n) : NULL; + struct kinfo_proc* procs = procstat ? procstat_getprocs(procstat, KERN_PROC_PID, getpid(), &n) : nullptr; if ( procs ) { procstat_getpathname(procstat, procs, buffer, PATH_MAX); ret = std::string(buffer); @@ -383,7 +383,7 @@ namespace Exiv2 { // release resources if ( procs ) procstat_freeprocs(procstat, procs); if ( procstat ) procstat_close(procstat); - #elif defined(__sun__) +#elif defined(__sun__) // https://stackoverflow.com/questions/47472762/on-solaris-how-to-get-the-full-path-of-executable-of-running-process-programatic const char* proc = Internal::stringFormat("/proc/%d/path/a.out",getpid()).c_str(); char path[500]; @@ -392,7 +392,7 @@ namespace Exiv2 { path[l]=0; ret = path; } - #elif defined(__unix__) +#elif defined(__unix__) // http://stackoverflow.com/questions/606041/how-do-i-get-the-path-of-a-process-in-unix-linux char path[500]; ssize_t l = readlink ("/proc/self/exe", path,sizeof(path)-1); @@ -400,7 +400,7 @@ namespace Exiv2 { path[l]=0; ret = path; } - #endif +#endif const size_t idxLastSeparator = ret.find_last_of(EXV_SEPARATOR_STR); return ret.substr(0, idxLastSeparator); diff --git a/src/makernote_int.cpp b/src/makernote_int.cpp index 10707a78..cd638cfa 100644 --- a/src/makernote_int.cpp +++ b/src/makernote_int.cpp @@ -81,7 +81,7 @@ namespace Exiv2::Internal { #if defined(_MSC_VER) || defined(__MINGW__) char buffer[1024]; - if (SUCCEEDED(SHGetFolderPathA(NULL, CSIDL_PROFILE, NULL, 0, buffer))) { + if (SUCCEEDED(SHGetFolderPathA(nullptr, CSIDL_PROFILE, nullptr, 0, buffer))) { currentPath = buffer; } #else diff --git a/src/tiffcomposite_int.cpp b/src/tiffcomposite_int.cpp index d72dcba1..d3c07f73 100644 --- a/src/tiffcomposite_int.cpp +++ b/src/tiffcomposite_int.cpp @@ -1522,7 +1522,7 @@ namespace Exiv2::Internal { if (component->tag() == 0x014a) { // Hack: delay writing of sub-IFD image data to get the order correct #ifndef SUPPRESS_WARNINGS - if (pSubIfd != 0) { + if (pSubIfd) { EXV_ERROR << "Multiple sub-IFD image data tags found\n"; } #endif diff --git a/src/version.cpp b/src/version.cpp index e14648ac..1616341b 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -155,8 +155,8 @@ static std::vector getLoadedLibraries() if ( isatty(STDIN_FILENO) ) { unsigned int n; struct procstat* procstat = procstat_open_sysctl(); - struct kinfo_proc* procs = procstat ? procstat_getprocs(procstat, KERN_PROC_PID, getpid(), &n) : NULL; - struct filestat_list* files = procs ? procstat_getfiles(procstat, procs, true) : NULL; + struct kinfo_proc* procs = procstat ? procstat_getprocs(procstat, KERN_PROC_PID, getpid(), &n) : nullptr; + struct filestat_list* files = procs ? procstat_getfiles(procstat, procs, true) : nullptr; if ( files ) { filestat* entry; STAILQ_FOREACH(entry, files, next) { diff --git a/src/xmp.cpp b/src/xmp.cpp index 47d96531..12a1eb7e 100644 --- a/src/xmp.cpp +++ b/src/xmp.cpp @@ -570,28 +570,28 @@ namespace Exiv2 { pLockData_ = pLockData; initialized_ = SXMPMeta::Initialize(); #ifdef EXV_ADOBE_XMPSDK - SXMPMeta::RegisterNamespace("http://ns.adobe.com/lightroom/1.0/", "lr",NULL); - SXMPMeta::RegisterNamespace("http://rs.tdwg.org/dwc/index.htm", "dwc",NULL); - SXMPMeta::RegisterNamespace("http://purl.org/dc/terms/", "dcterms",NULL); - SXMPMeta::RegisterNamespace("http://www.digikam.org/ns/1.0/", "digiKam",NULL); - SXMPMeta::RegisterNamespace("http://www.digikam.org/ns/kipi/1.0/", "kipi",NULL); - SXMPMeta::RegisterNamespace("http://ns.microsoft.com/photo/1.0/", "MicrosoftPhoto",NULL); - SXMPMeta::RegisterNamespace("http://ns.acdsee.com/iptc/1.0/", "acdsee",NULL); - SXMPMeta::RegisterNamespace("http://iptc.org/std/Iptc4xmpExt/2008-02-29/", "iptcExt",NULL); - SXMPMeta::RegisterNamespace("http://ns.useplus.org/ldf/xmp/1.0/", "plus",NULL); - SXMPMeta::RegisterNamespace("http://ns.iview-multimedia.com/mediapro/1.0/", "mediapro",NULL); - SXMPMeta::RegisterNamespace("http://ns.microsoft.com/expressionmedia/1.0/", "expressionmedia",NULL); - SXMPMeta::RegisterNamespace("http://ns.microsoft.com/photo/1.2/", "MP",NULL); - SXMPMeta::RegisterNamespace("http://ns.microsoft.com/photo/1.2/t/RegionInfo#", "MPRI",NULL); - SXMPMeta::RegisterNamespace("http://ns.microsoft.com/photo/1.2/t/Region#", "MPReg",NULL); - SXMPMeta::RegisterNamespace("http://ns.google.com/photos/1.0/panorama/", "GPano",NULL); - SXMPMeta::RegisterNamespace("http://www.metadataworkinggroup.com/schemas/regions/", "mwg-rs",NULL); - SXMPMeta::RegisterNamespace("http://www.metadataworkinggroup.com/schemas/keywords/", "mwg-kw",NULL); - SXMPMeta::RegisterNamespace("http://ns.adobe.com/xmp/sType/Area#", "stArea",NULL); - SXMPMeta::RegisterNamespace("http://cipa.jp/exif/1.0/", "exifEX",NULL); - SXMPMeta::RegisterNamespace("http://ns.adobe.com/camera-raw-saved-settings/1.0/", "crss",NULL); - SXMPMeta::RegisterNamespace("http://www.audio/", "audio",NULL); - SXMPMeta::RegisterNamespace("http://www.video/", "video",NULL); + SXMPMeta::RegisterNamespace("http://ns.adobe.com/lightroom/1.0/", "lr", nullptr); + SXMPMeta::RegisterNamespace("http://rs.tdwg.org/dwc/index.htm", "dwc", nullptr); + SXMPMeta::RegisterNamespace("http://purl.org/dc/terms/", "dcterms", nullptr); + SXMPMeta::RegisterNamespace("http://www.digikam.org/ns/1.0/", "digiKam", nullptr); + SXMPMeta::RegisterNamespace("http://www.digikam.org/ns/kipi/1.0/", "kipi", nullptr); + SXMPMeta::RegisterNamespace("http://ns.microsoft.com/photo/1.0/", "MicrosoftPhoto", nullptr); + SXMPMeta::RegisterNamespace("http://ns.acdsee.com/iptc/1.0/", "acdsee", nullptr); + SXMPMeta::RegisterNamespace("http://iptc.org/std/Iptc4xmpExt/2008-02-29/", "iptcExt", nullptr); + SXMPMeta::RegisterNamespace("http://ns.useplus.org/ldf/xmp/1.0/", "plus", nullptr); + SXMPMeta::RegisterNamespace("http://ns.iview-multimedia.com/mediapro/1.0/", "mediapro", nullptr); + SXMPMeta::RegisterNamespace("http://ns.microsoft.com/expressionmedia/1.0/", "expressionmedia", nullptr); + SXMPMeta::RegisterNamespace("http://ns.microsoft.com/photo/1.2/", "MP", nullptr); + SXMPMeta::RegisterNamespace("http://ns.microsoft.com/photo/1.2/t/RegionInfo#", "MPRI", nullptr); + SXMPMeta::RegisterNamespace("http://ns.microsoft.com/photo/1.2/t/Region#", "MPReg", nullptr); + SXMPMeta::RegisterNamespace("http://ns.google.com/photos/1.0/panorama/", "GPano", nullptr); + SXMPMeta::RegisterNamespace("http://www.metadataworkinggroup.com/schemas/regions/", "mwg-rs", nullptr); + SXMPMeta::RegisterNamespace("http://www.metadataworkinggroup.com/schemas/keywords/", "mwg-kw", nullptr); + SXMPMeta::RegisterNamespace("http://ns.adobe.com/xmp/sType/Area#", "stArea", nullptr); + SXMPMeta::RegisterNamespace("http://cipa.jp/exif/1.0/", "exifEX", nullptr); + SXMPMeta::RegisterNamespace("http://ns.adobe.com/camera-raw-saved-settings/1.0/", "crss", nullptr); + SXMPMeta::RegisterNamespace("http://www.audio/", "audio", nullptr); + SXMPMeta::RegisterNamespace("http://www.video/", "video", nullptr); #else SXMPMeta::RegisterNamespace("http://ns.adobe.com/lightroom/1.0/", "lr"); SXMPMeta::RegisterNamespace("http://rs.tdwg.org/dwc/index.htm", "dwc"); @@ -700,7 +700,7 @@ namespace Exiv2 { AutoLock autoLock(xmpLockFct_, pLockData_); SXMPMeta::DeleteNamespace(ns.c_str()); #ifdef EXV_ADOBE_XMPSDK - SXMPMeta::RegisterNamespace(ns.c_str(), prefix.c_str(),NULL); + SXMPMeta::RegisterNamespace(ns.c_str(), prefix.c_str(), nullptr); #else SXMPMeta::RegisterNamespace(ns.c_str(), prefix.c_str()); #endif From 6d1fa2ecea1bd2c673c1617cec9917faaf606a1a Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 5 Mar 2022 01:49:27 -0800 Subject: [PATCH 4/9] clang-tidy: use empty() instead of size() Signed-off-by: Rosen Penev --- app/actions.cpp | 4 ++-- app/exiv2.cpp | 2 +- src/crwimage_int.cpp | 10 ++++------ src/jp2image.cpp | 3 +-- src/jpgimage.cpp | 2 +- src/pngchunk_int.cpp | 4 ++-- src/pngimage.cpp | 7 +++---- src/psdimage.cpp | 4 ++-- src/tiffcomposite_int.cpp | 2 +- src/tiffvisitor_int.cpp | 11 ++++++----- 10 files changed, 23 insertions(+), 26 deletions(-) diff --git a/app/actions.cpp b/app/actions.cpp index a53fd35e..46130052 100644 --- a/app/actions.cpp +++ b/app/actions.cpp @@ -902,7 +902,7 @@ namespace Action { if (dontOverwrite(thumbPath)) return 0; if (Params::instance().verbose_) { Exiv2::DataBuf buf = exifThumb.copy(); - if (buf.size() != 0) { + if (!buf.empty()) { std::cout << _("Writing thumbnail") << " (" << exifThumb.mimeType() << ", " << buf.size() << " " << _("Bytes") << ") " << _("to file") << " " << thumbPath << std::endl; @@ -1150,7 +1150,7 @@ namespace Action { image->readMetadata(); // clear existing profile, assign the blob and rewrite image image->clearIccProfile(); - if ( iccProfileBlob.size() ) { + if (!iccProfileBlob.empty()) { image->setIccProfile(std::move(iccProfileBlob)); } image->writeMetadata(); diff --git a/app/exiv2.cpp b/app/exiv2.cpp index 48d19687..64171e9e 100644 --- a/app/exiv2.cpp +++ b/app/exiv2.cpp @@ -1010,7 +1010,7 @@ void Params::getStdin(Exiv2::DataBuf& buf) } // copy stdinBuf to buf - if ( stdinBuf.size() ) { + if (!stdinBuf.empty()) { buf.alloc(stdinBuf.size()); buf.copyBytes(0,stdinBuf.c_data(),buf.size()); } diff --git a/src/crwimage_int.cpp b/src/crwimage_int.cpp index 82e414c7..ab6c4753 100644 --- a/src/crwimage_int.cpp +++ b/src/crwimage_int.cpp @@ -1063,12 +1063,11 @@ namespace Exiv2::Internal { // Try the undecoded tag encodeBasic(image, pCrwMapping, pHead); } - if (buf.size() > 0) { + if (!buf.empty()) { // Write the number of shorts to the beginning of buf buf.write_uint16(0, static_cast(buf.size()), pHead->byteOrder()); pHead->add(pCrwMapping->crwTagId_, pCrwMapping->crwDir_, std::move(buf)); - } - else { + } else { pHead->remove(pCrwMapping->crwTagId_, pCrwMapping->crwDir_); } } // CrwMap::encodeArray @@ -1154,10 +1153,9 @@ namespace Exiv2::Internal { ExifThumbC exifThumb(image.exifData()); DataBuf buf = exifThumb.copy(); - if (buf.size() != 0) { + if (!buf.empty()) { pHead->add(pCrwMapping->crwTagId_, pCrwMapping->crwDir_, std::move(buf)); - } - else { + } else { pHead->remove(pCrwMapping->crwTagId_, pCrwMapping->crwDir_); } } // CrwMap::encode0x2008 diff --git a/src/jp2image.cpp b/src/jp2image.cpp index 8ff222cd..a9eee89c 100644 --- a/src/jp2image.cpp +++ b/src/jp2image.cpp @@ -845,8 +845,7 @@ static void boxes_check(size_t b,size_t m) // Update Iptc data to a new UUID box DataBuf rawIptc = IptcParser::encode(iptcData_); - if (rawIptc.size() > 0) - { + if (!rawIptc.empty()) { DataBuf boxData(8 + 16 + rawIptc.size()); ul2Data(boxDataSize, static_cast(boxData.size()), Exiv2::bigEndian); ul2Data(boxUUIDtype, kJp2BoxTypeUuid, Exiv2::bigEndian); diff --git a/src/jpgimage.cpp b/src/jpgimage.cpp index 8b08ce3b..5c1b6baf 100644 --- a/src/jpgimage.cpp +++ b/src/jpgimage.cpp @@ -419,7 +419,7 @@ namespace Exiv2 { } DataBuf profile(Safe::add(iccProfile_.size(), icc_size)); - if ( iccProfile_.size() ) { + if (!iccProfile_.empty()) { profile.copyBytes(0, iccProfile_.c_data(), iccProfile_.size()); } profile.copyBytes(iccProfile_.size(), buf.c_data(2+14), icc_size); diff --git a/src/pngchunk_int.cpp b/src/pngchunk_int.cpp index 64b996e0..53105c22 100644 --- a/src/pngchunk_int.cpp +++ b/src/pngchunk_int.cpp @@ -240,7 +240,7 @@ namespace Exiv2::Internal { if (keySize >= 21 && memcmp("Raw profile type iptc", key, 21) == 0 && pImage->iptcData().empty()) { DataBuf psData = readRawProfile(arr, false); - if (psData.size() > 0) { + if (!psData.empty()) { Blob iptcBlob; const byte* record = nullptr; uint32_t sizeIptc = 0; @@ -303,7 +303,7 @@ namespace Exiv2::Internal { // We look if an Adobe XMP string exist. if (keySize >= 17 && memcmp("XML:com.adobe.xmp", key, 17) == 0 && pImage->xmpData().empty()) { - if (arr.size() > 0) { + if (!arr.empty()) { std::string& xmpPacket = pImage->xmpPacket(); xmpPacket.assign(arr.c_str(), arr.size()); std::string::size_type idx = xmpPacket.find_first_of('<'); diff --git a/src/pngimage.cpp b/src/pngimage.cpp index 952a3d5f..d2f2f36c 100644 --- a/src/pngimage.cpp +++ b/src/pngimage.cpp @@ -342,7 +342,7 @@ namespace Exiv2 { #if EXIV2_DEBUG_MESSAGES std::cerr << Exiv2::Internal::binaryToString(makeSlice(parsedBuf.c_data(), parsedBuf.size()>50?50:parsedBuf.size(),0)) << std::endl; #endif - if ( parsedBuf.size() ) { + if (!parsedBuf.empty()) { if ( bExif ) { // create memio object with the data, then print the structure MemIo p(parsedBuf.c_data(6), parsedBuf.size()-6); @@ -354,7 +354,7 @@ namespace Exiv2 { } } - if ( bSoft && dataBuf.size() > 0) { + if (bSoft && !dataBuf.empty()) { DataBuf s(dataBuf.size()+1); // allocate buffer with an extra byte s.copyBytes(0,dataBuf.c_data(),dataBuf.size());// copy in the dataBuf s.write_uint8(dataBuf.size(), 0); // nul terminate it @@ -621,8 +621,7 @@ namespace Exiv2 { { // Update IPTC data to a new PNG chunk DataBuf newPsData = Photoshop::setIptcIrb(nullptr, 0, iptcData_); - if (newPsData.size() > 0) - { + if (!newPsData.empty()) { std::string rawIptc(newPsData.c_str(), newPsData.size()); std::string chunk = PngChunk::makeMetadataChunk(rawIptc, mdIptc); if (outIo.write(reinterpret_cast(chunk.data()), chunk.size()) != chunk.size()) { diff --git a/src/psdimage.cpp b/src/psdimage.cpp index 118f352b..de491f95 100644 --- a/src/psdimage.cpp +++ b/src/psdimage.cpp @@ -250,7 +250,7 @@ namespace Exiv2 { throw Error(kerFailedToReadImageData); ByteOrder bo = ExifParser::decode(exifData_, rawExif.c_data(), rawExif.size()); setByteOrder(bo); - if (rawExif.size() > 0 && byteOrder() == invalidByteOrder) { + if (!rawExif.empty() && byteOrder() == invalidByteOrder) { #ifndef SUPPRESS_WARNINGS EXV_WARNING << "Failed to decode Exif metadata.\n"; #endif @@ -579,7 +579,7 @@ namespace Exiv2 { if (iptcData.count() > 0) { DataBuf rawIptc = IptcParser::encode(iptcData); - if (rawIptc.size() > 0) { + if (!rawIptc.empty()) { #ifdef EXIV2_DEBUG_MESSAGES std::cerr << std::hex << "write: resourceId: " << kPhotoshopResourceID_IPTC_NAA << "\n"; std::cerr << std::dec << "Writing IPTC_NAA: size: " << rawIptc.size() << "\n"; diff --git a/src/tiffcomposite_int.cpp b/src/tiffcomposite_int.cpp index d3c07f73..4fb378e6 100644 --- a/src/tiffcomposite_int.cpp +++ b/src/tiffcomposite_int.cpp @@ -1391,7 +1391,7 @@ namespace Exiv2::Internal { cryptFct = sonyTagEncipher; } DataBuf buf = cryptFct(tag(), mio.mmap(), static_cast(mio.size()), pRoot_); - if ( buf.size()) { + if (!buf.empty()) { mio.seek(0,Exiv2::FileIo::beg); mio.write(buf.c_data(), buf.size()); } diff --git a/src/tiffvisitor_int.cpp b/src/tiffvisitor_int.cpp index f66bd4f0..b6e22fb4 100644 --- a/src/tiffvisitor_int.cpp +++ b/src/tiffvisitor_int.cpp @@ -599,7 +599,7 @@ namespace Exiv2::Internal { if (pos != exifData_.end()) { irbKey.setIdx(pos->idx()); } - if (rawIptc.size() != 0 && (del || pos == exifData_.end())) { + if (!rawIptc.empty() && (del || pos == exifData_.end())) { auto value = Value::create(unsignedLong); DataBuf buf; if (rawIptc.size() % 4 != 0) { @@ -622,7 +622,7 @@ namespace Exiv2::Internal { pos->value().copy(irbBuf.data(), invalidByteOrder); irbBuf = Photoshop::setIptcIrb(irbBuf.c_data(), irbBuf.size(), iptcData_); exifData_.erase(pos); - if (irbBuf.size() != 0) { + if (!irbBuf.empty()) { auto value = Value::create(unsignedByte); value->read(irbBuf.data(), static_cast(irbBuf.size()), invalidByteOrder); Exifdatum iptcDatum(irbKey, value.get()); @@ -815,7 +815,7 @@ namespace Exiv2::Internal { if (cryptFct != nullptr) { const byte* pData = object->pData(); DataBuf buf = cryptFct(object->tag(), pData, size, pRoot_); - if (buf.size() > 0) { + if (!buf.empty()) { pData = buf.c_data(); size = static_cast(buf.size()); } @@ -930,7 +930,7 @@ namespace Exiv2::Internal { std::cerr << "Writing data area for " << key << "\n"; #endif DataBuf buf = object->pValue()->dataArea(); - if ( buf.size() > 0 ) { + if (!buf.empty()) { memcpy(object->pDataArea_, buf.c_data(), buf.size()); if (object->sizeDataArea_ > static_cast(buf.size())) { memset(object->pDataArea_ + buf.size(), @@ -1639,7 +1639,8 @@ namespace Exiv2::Internal { std::shared_ptr buf = std::make_shared( cryptFct(object->tag(), pData, size, pRoot_) ); - if (buf->size() > 0) object->setData(buf); + if (!buf->empty()) + object->setData(buf); } const ArrayDef* defs = object->def(); From 133849c39448592107249f16794e513b88e89717 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 5 Mar 2022 02:18:56 -0800 Subject: [PATCH 5/9] clang-tidy: remove pointless get() Signed-off-by: Rosen Penev --- src/exif.cpp | 4 ++-- src/tiffimage_int.cpp | 10 +++++----- src/tiffvisitor_int.cpp | 4 ++-- src/xmp.cpp | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/exif.cpp b/src/exif.cpp index 651911da..2d1fa222 100644 --- a/src/exif.cpp +++ b/src/exif.cpp @@ -434,7 +434,7 @@ namespace Exiv2 { size_t ExifThumbC::writeFile(const std::string& path) const { auto thumbnail = Thumbnail::create(exifData_); - if (!thumbnail.get()) + if (!thumbnail) return 0; std::string name = path + thumbnail->extension(); @@ -448,7 +448,7 @@ namespace Exiv2 { const char* ExifThumbC::mimeType() const { auto thumbnail = Thumbnail::create(exifData_); - if (!thumbnail.get()) + if (!thumbnail) return ""; return thumbnail->mimeType(); } diff --git a/src/tiffimage_int.cpp b/src/tiffimage_int.cpp index 67d0d292..eb221adf 100644 --- a/src/tiffimage_int.cpp +++ b/src/tiffimage_int.cpp @@ -2043,7 +2043,7 @@ namespace Exiv2::Internal { } auto rootDir = parse(pData, size, root, pHeader); - if (nullptr != rootDir.get()) { + if (rootDir) { TiffDecoder decoder(exifData, iptcData, xmpData, @@ -2081,7 +2081,7 @@ namespace Exiv2::Internal { auto parsedTree = parse(pData, size, root, pHeader); PrimaryGroups primaryGroups; findPrimaryGroups(primaryGroups, parsedTree.get()); - if (nullptr != parsedTree.get()) { + if (parsedTree) { // Attempt to update existing TIFF components based on metadata entries TiffEncoder encoder(exifData, iptcData, @@ -2096,14 +2096,14 @@ namespace Exiv2::Internal { } if (writeMethod == wmIntrusive) { auto createdTree = TiffCreator::create(root, ifdIdNotSet); - if (nullptr != parsedTree.get()) { + if (parsedTree) { // Copy image tags from the original image to the composite TiffCopier copier(createdTree.get(), root, pHeader, &primaryGroups); parsedTree->accept(copier); } // Add entries from metadata to composite - TiffEncoder encoder(exifData, iptcData, xmpData, createdTree.get(), parsedTree.get() == nullptr, - &primaryGroups, pHeader, findEncoderFct); + TiffEncoder encoder(exifData, iptcData, xmpData, createdTree.get(), parsedTree == nullptr, &primaryGroups, + pHeader, findEncoderFct); encoder.add(createdTree.get(), parsedTree.get(), root); // Write binary representation from the composite tree DataBuf header = pHeader->write(); diff --git a/src/tiffvisitor_int.cpp b/src/tiffvisitor_int.cpp index b6e22fb4..cad91733 100644 --- a/src/tiffvisitor_int.cpp +++ b/src/tiffvisitor_int.cpp @@ -1588,7 +1588,7 @@ namespace Exiv2::Internal { } } auto v = Value::create(typeId); - enforce(v.get() != nullptr, kerCorruptedMetadata); + enforce(v != nullptr, kerCorruptedMetadata); v->read(pData, size, byteOrder()); object->setValue(std::move(v)); @@ -1690,7 +1690,7 @@ namespace Exiv2::Internal { if (bo == invalidByteOrder) bo = byteOrder(); TypeId typeId = toTypeId(object->elDef()->tiffType_, object->tag(), object->group()); auto v = Value::create(typeId); - enforce(v.get() != nullptr, kerCorruptedMetadata); + enforce(v != nullptr, kerCorruptedMetadata); v->read(pData, size, bo); object->setValue(std::move(v)); diff --git a/src/xmp.cpp b/src/xmp.cpp index 12a1eb7e..fdaf7110 100644 --- a/src/xmp.cpp +++ b/src/xmp.cpp @@ -794,7 +794,7 @@ namespace Exiv2 { } val->value_[propValue] = text; } - xmpData.add(*key.get(), val.get()); + xmpData.add(*key, val.get()); continue; } if ( XMP_PropIsArray(opt) @@ -825,7 +825,7 @@ namespace Exiv2 { printNode(schemaNs, propPath, propValue, opt); val->read(propValue); } - xmpData.add(*key.get(), val.get()); + xmpData.add(*key, val.get()); continue; } } @@ -835,12 +835,12 @@ namespace Exiv2 { // Create a metadatum with only XMP options val->setXmpArrayType(xmpArrayType(opt)); val->setXmpStruct(xmpStruct(opt)); - xmpData.add(*key.get(), val.get()); + xmpData.add(*key, val.get()); continue; } if (XMP_PropIsSimple(opt) || XMP_PropIsQualifier(opt)) { val->read(propValue); - xmpData.add(*key.get(), val.get()); + xmpData.add(*key, val.get()); continue; } // Don't let any node go by unnoticed From 63e41c3aeb47638738fb4d2774744f90a0c7c26c Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 5 Mar 2022 02:35:14 -0800 Subject: [PATCH 6/9] clang-tidy: simplify bool Signed-off-by: Rosen Penev --- src/crwimage_int.cpp | 5 ++--- src/pngimage.cpp | 19 +++++++------------ 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/crwimage_int.cpp b/src/crwimage_int.cpp index ab6c4753..7d9274ce 100644 --- a/src/crwimage_int.cpp +++ b/src/crwimage_int.cpp @@ -345,11 +345,10 @@ namespace Exiv2::Internal { append(blob, reinterpret_cast(signature_), 8); o += 8; // Pad as needed - if (pPadding_.empty() == false) { + if (!pPadding_.empty()) { assert(padded_ == offset_ - o); append(blob, pPadding_.data(), padded_); - } - else { + } else { for (uint32_t i = o; i < offset_; ++i) { blob.push_back(0); ++o; diff --git a/src/pngimage.cpp b/src/pngimage.cpp index d2f2f36c..b82e6bee 100644 --- a/src/pngimage.cpp +++ b/src/pngimage.cpp @@ -681,22 +681,17 @@ namespace Exiv2 { } else if (!strcmp(szChunk, "tEXt") || !strcmp(szChunk, "zTXt") || !strcmp(szChunk, "iTXt") || !strcmp(szChunk, "iCCP")) { DataBuf key = PngChunk::keyTXTChunk(chunkBuf, true); - if (key.empty() == false && ( - compare("Raw profile type exif", key, 21) || - compare("Raw profile type APP1", key, 21) || - compare("Raw profile type iptc", key, 21) || - compare("Raw profile type xmp", key, 20) || - compare("XML:com.adobe.xmp", key, 17) || - compare("icc", key, 3) || // see test/data/imagemagick.png - compare("ICC", key, 3) || - compare("Description", key, 11))) - { + if (!key.empty() && + (compare("Raw profile type exif", key, 21) || compare("Raw profile type APP1", key, 21) || + compare("Raw profile type iptc", key, 21) || compare("Raw profile type xmp", key, 20) || + compare("XML:com.adobe.xmp", key, 17) || + compare("icc", key, 3) || // see test/data/imagemagick.png + compare("ICC", key, 3) || compare("Description", key, 11))) { #ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PngImage::doWriteMetadata: strip " << szChunk << " chunk (length: " << dataOffset << ")" << std::endl; #endif - } else - { + } else { #ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PngImage::doWriteMetadata: write " << szChunk << " chunk (length: " << dataOffset << ")" << std::endl; From 8cda090e58a1a816e2c8f6acbf8f749aea6b15ec Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 5 Mar 2022 02:41:39 -0800 Subject: [PATCH 7/9] clang-tidy: get rid of compare() usage Signed-off-by: Rosen Penev --- src/jpgimage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jpgimage.cpp b/src/jpgimage.cpp index 5c1b6baf..1aa076d1 100644 --- a/src/jpgimage.cpp +++ b/src/jpgimage.cpp @@ -606,7 +606,7 @@ namespace Exiv2 { enforce(start <= size, kerInvalidXmpText); out.write(reinterpret_cast(&xmp[start]), size - start); done = !bExtXMP; - } else if (option == kpsIccProfile && signature.compare(iccId_) == 0) { + } else if (option == kpsIccProfile && signature == iccId_) { // extract ICCProfile if (size >= 16) { out.write(buf.c_str(16), size - 16); From 95355fe21420ed2722bbcd61840ba2de2851abc9 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 5 Mar 2022 02:44:07 -0800 Subject: [PATCH 8/9] clang-tidy: remove C casts Signed-off-by: Rosen Penev --- src/jpgimage.cpp | 2 +- src/pngimage.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/jpgimage.cpp b/src/jpgimage.cpp index 1aa076d1..ed3c4692 100644 --- a/src/jpgimage.cpp +++ b/src/jpgimage.cpp @@ -1058,7 +1058,7 @@ namespace Exiv2 { uint8_t pad[2]; pad[0] = static_cast(chunk + 1); pad[1] = static_cast(chunks); - outIo.write((const byte*)iccId_, 12); + outIo.write(reinterpret_cast(iccId_), 12); outIo.write((const byte*)pad, 2); if (outIo.write(iccProfile_.c_data(chunk * chunk_size), bytes) != bytes) throw Error(kerImageWriteFailed); diff --git a/src/pngimage.cpp b/src/pngimage.cpp index b82e6bee..39946f0f 100644 --- a/src/pngimage.cpp +++ b/src/pngimage.cpp @@ -39,8 +39,8 @@ const unsigned char pngBlank[] = { 0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00, namespace { - const auto nullComp = (const Exiv2::byte*)"\0\0"; - const auto typeICCP = (const Exiv2::byte*)"iCCP"; + const auto nullComp = reinterpret_cast("\0\0"); + const auto typeICCP = reinterpret_cast("iCCP"); inline bool compare(const char* str, const Exiv2::DataBuf& buf, size_t length) { assert(strlen(str) <= length); @@ -641,7 +641,7 @@ namespace Exiv2 { // calculate CRC uLong tmp = crc32(0L, Z_NULL, 0); tmp = crc32(tmp, typeICCP, 4); - tmp = crc32(tmp, (const Bytef*)profileName_.data(), nameLength); + tmp = crc32(tmp, reinterpret_cast(profileName_.data()), nameLength); tmp = crc32(tmp, nullComp, 2); tmp = crc32(tmp, compressed.c_data(), static_cast(compressed.size())); byte crc[4]; From def782fb65720e65e814e7b1015efd9b12e38212 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 5 Mar 2022 16:43:19 -0800 Subject: [PATCH 9/9] replace several typedefs with using Signed-off-by: Rosen Penev --- include/exiv2/basicio.hpp | 2 +- include/exiv2/datasets.hpp | 8 +- include/exiv2/error.hpp | 8 +- include/exiv2/exif.hpp | 6 +- include/exiv2/image.hpp | 12 ++- include/exiv2/ini.hpp | 5 +- include/exiv2/iptc.hpp | 6 +- include/exiv2/metadatum.hpp | 2 +- include/exiv2/preview.hpp | 23 +++--- include/exiv2/properties.hpp | 4 +- include/exiv2/slice.hpp | 85 +++++--------------- include/exiv2/tags.hpp | 10 +-- include/exiv2/types.hpp | 147 ++++++++++++++++------------------- include/exiv2/value.hpp | 56 ++++++------- include/exiv2/xmp_exiv2.hpp | 8 +- samples/Jzon.h | 20 ++--- 16 files changed, 171 insertions(+), 231 deletions(-) diff --git a/include/exiv2/basicio.hpp b/include/exiv2/basicio.hpp index 198c05cb..ce6bc33d 100644 --- a/include/exiv2/basicio.hpp +++ b/include/exiv2/basicio.hpp @@ -36,7 +36,7 @@ namespace Exiv2 { class EXIV2API BasicIo { public: //! BasicIo auto_ptr type - typedef std::unique_ptr UniquePtr; + using UniquePtr = std::unique_ptr; //! Seek starting positions enum Position { beg, cur, end }; diff --git a/include/exiv2/datasets.hpp b/include/exiv2/datasets.hpp index 0d5be0d9..7dd4a37a 100644 --- a/include/exiv2/datasets.hpp +++ b/include/exiv2/datasets.hpp @@ -245,7 +245,7 @@ namespace Exiv2 { class EXIV2API IptcKey : public Key { public: //! Shortcut for an %IptcKey auto pointer. - typedef std::unique_ptr UniquePtr; + using UniquePtr = std::unique_ptr; //! @name Creators //@{ @@ -322,10 +322,10 @@ namespace Exiv2 { /*! @brief typedef for string:string map */ - typedef std::map Dictionary; + using Dictionary = std::map; -// ***************************************************************************** -// free functions + // ***************************************************************************** + // free functions //! Output operator for dataSet EXIV2API std::ostream& operator<<(std::ostream& os, const DataSet& dataSet); diff --git a/include/exiv2/error.hpp b/include/exiv2/error.hpp index 5776f2ce..31a9e7f5 100644 --- a/include/exiv2/error.hpp +++ b/include/exiv2/error.hpp @@ -68,7 +68,7 @@ namespace Exiv2 { specific way. The default handler sends the log message to standard error. */ - typedef void (*Handler)(int, const char*); + using Handler = void (*)(int, const char*); //! @name Creators //@{ @@ -290,10 +290,10 @@ namespace Exiv2 { }; // class BasicError //! Error class used for exceptions (std::string based) - typedef BasicError Error; + using Error = BasicError; -// ***************************************************************************** -// free functions, template and inline definitions + // ***************************************************************************** + // free functions, template and inline definitions //! Return the error message for the error with code \em code. const char* errMsg(int code); diff --git a/include/exiv2/exif.hpp b/include/exiv2/exif.hpp index 18cda666..71124f83 100644 --- a/include/exiv2/exif.hpp +++ b/include/exiv2/exif.hpp @@ -354,7 +354,7 @@ namespace Exiv2 { }; // class ExifThumb //! Container type to hold all metadata - typedef std::list ExifMetadata; + using ExifMetadata = std::list; /*! @brief A container for Exif data. This is a top-level class of the %Exiv2 @@ -371,9 +371,9 @@ namespace Exiv2 { class EXIV2API ExifData { public: //! ExifMetadata iterator type - typedef ExifMetadata::iterator iterator; + using iterator = ExifMetadata::iterator; //! ExifMetadata const iterator type - typedef ExifMetadata::const_iterator const_iterator; + using const_iterator = ExifMetadata::const_iterator; //! @name Manipulators //@{ diff --git a/include/exiv2/image.hpp b/include/exiv2/image.hpp index 808b3ac7..d8e4f795 100644 --- a/include/exiv2/image.hpp +++ b/include/exiv2/image.hpp @@ -31,14 +31,12 @@ namespace Exiv2 { }; //! List of native previews. This is meant to be used only by the PreviewManager. - typedef std::vector NativePreviewList; + using NativePreviewList = std::vector; /*! @brief Options for printStructure */ - typedef enum { kpsNone, kpsBasic, kpsXMP, kpsRecursive - , kpsIccProfile , kpsIptcErase - } PrintStructureOption; + enum PrintStructureOption { kpsNone, kpsBasic, kpsXMP, kpsRecursive, kpsIccProfile, kpsIptcErase }; /*! @brief Abstract base class defining the interface for an image. This is @@ -53,7 +51,7 @@ namespace Exiv2 { class EXIV2API Image { public: //! Image auto_ptr type - typedef std::unique_ptr UniquePtr; + using UniquePtr = std::unique_ptr; //! @name Creators //@{ @@ -490,9 +488,9 @@ namespace Exiv2 { }; // class Image //! Type for function pointer that creates new Image instances - typedef Image::UniquePtr (*NewInstanceFct)(BasicIo::UniquePtr io, bool create); + using NewInstanceFct = Image::UniquePtr (*)(BasicIo::UniquePtr io, bool create); //! Type for function pointer that checks image types - typedef bool (*IsThisTypeFct)(BasicIo& iIo, bool advance); + using IsThisTypeFct = bool (*)(BasicIo& iIo, bool advance); /*! @brief Returns an Image instance of the specified type. diff --git a/include/exiv2/ini.hpp b/include/exiv2/ini.hpp index 1c255633..c45905fc 100755 --- a/include/exiv2/ini.hpp +++ b/include/exiv2/ini.hpp @@ -25,11 +25,10 @@ extern "C" { #endif //! @brief typedef for prototype of handler function. -typedef int (*ini_handler)(void* user, const char* section, - const char* name, const char* value); +using ini_handler = int (*)(void* user, const char* section, const char* name, const char* value); //! Typedef for prototype of fgets-style reader function. -typedef char* (*ini_reader)(char* str, int num, void* stream); +using ini_reader = char* (*)(char* str, int num, void* stream); /*! @brief Parse given INI-style file. May have [section]s, name=value pairs diff --git a/include/exiv2/iptc.hpp b/include/exiv2/iptc.hpp index a64274a8..a2dfd02c 100644 --- a/include/exiv2/iptc.hpp +++ b/include/exiv2/iptc.hpp @@ -138,7 +138,7 @@ namespace Exiv2 { }; // class Iptcdatum //! Container type to hold all metadata - typedef std::vector IptcMetadata; + using IptcMetadata = std::vector; /*! @brief A container for IPTC data. This is a top-level class of the %Exiv2 library. @@ -153,9 +153,9 @@ namespace Exiv2 { class EXIV2API IptcData { public: //! IptcMetadata iterator type - typedef IptcMetadata::iterator iterator; + using iterator = IptcMetadata::iterator; //! IptcMetadata const iterator type - typedef IptcMetadata::const_iterator const_iterator; + using const_iterator = IptcMetadata::const_iterator; // Use the compiler generated constructors and assignment operator diff --git a/include/exiv2/metadatum.hpp b/include/exiv2/metadatum.hpp index 5a5cb514..811d0d1f 100644 --- a/include/exiv2/metadatum.hpp +++ b/include/exiv2/metadatum.hpp @@ -27,7 +27,7 @@ namespace Exiv2 { class EXIV2API Key { public: //! Shortcut for a %Key auto pointer. - typedef std::unique_ptr UniquePtr; + using UniquePtr = std::unique_ptr; //! @name Creators //@{ diff --git a/include/exiv2/preview.hpp b/include/exiv2/preview.hpp index 04396933..f28c2ab0 100644 --- a/include/exiv2/preview.hpp +++ b/include/exiv2/preview.hpp @@ -12,11 +12,11 @@ // namespace extensions namespace Exiv2 { -// ***************************************************************************** -// class definitions + // ***************************************************************************** + // class definitions //! Type of preview image. - typedef int PreviewId; + using PreviewId = int; /*! @brief Preview image properties. @@ -37,13 +37,14 @@ namespace Exiv2 { }; //! Container type to hold all preview images metadata. - typedef std::vector PreviewPropertiesList; + using PreviewPropertiesList = std::vector; /*! @brief Class that holds preview image properties and data buffer. */ class EXIV2API PreviewImage { friend class PreviewManager; + public: //! @name Constructors //@{ @@ -111,10 +112,10 @@ namespace Exiv2 { //! Private constructor PreviewImage(PreviewProperties properties, DataBuf&& data); - PreviewProperties properties_; //!< Preview image properties - DataBuf preview_; //!< Preview image data + PreviewProperties properties_; //!< Preview image properties + DataBuf preview_; //!< Preview image data - }; // class PreviewImage + }; // class PreviewImage /*! @brief Class for extracting preview images from image metadata. @@ -142,9 +143,9 @@ namespace Exiv2 { //@} private: - const Image& image_; + const Image& image_; - }; // class PreviewManager -} // namespace Exiv2 + }; // class PreviewManager +} // namespace Exiv2 -#endif // #ifndef PREVIEW_HPP_ +#endif // #ifndef PREVIEW_HPP_ diff --git a/include/exiv2/properties.hpp b/include/exiv2/properties.hpp index 05d011b7..b77e2548 100644 --- a/include/exiv2/properties.hpp +++ b/include/exiv2/properties.hpp @@ -198,7 +198,7 @@ namespace Exiv2 { */ static void unregisterNs(); //! Type for the namespace registry - typedef std::map NsRegistry; + using NsRegistry = std::map; /*! @brief Get the registered namespace for a specific \em prefix from the registry. */ @@ -221,7 +221,7 @@ namespace Exiv2 { { public: //! Shortcut for an %XmpKey auto pointer. - typedef std::unique_ptr UniquePtr; + using UniquePtr = std::unique_ptr; //! @name Creators //@{ diff --git a/include/exiv2/slice.hpp b/include/exiv2/slice.hpp index f6cbfa24..5477e66f 100644 --- a/include/exiv2/slice.hpp +++ b/include/exiv2/slice.hpp @@ -12,53 +12,6 @@ namespace Exiv2 { namespace Internal { - // TODO: remove these custom implementations once we have C++11 - template - struct remove_const - { - typedef T type; - }; - - template - struct remove_const - { - typedef T type; - }; - - template - struct remove_volatile - { - typedef T type; - }; - template - struct remove_volatile - { - typedef T type; - }; - template - struct remove_cv - { - typedef typename remove_const::type>::type type; - }; - - template - struct remove_pointer - { - typedef T type; - }; - - template - struct remove_pointer - { - typedef T type; - }; - - template - struct remove_pointer - { - typedef T type; - }; - /*! * Common base class of all slice implementations. * @@ -133,9 +86,9 @@ namespace Exiv2 template