Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move enums from tags_int.hpp to tags.hpp #2276

Merged
merged 3 commits into from
Jul 12, 2022

Conversation

kevinbackhouse
Copy link
Collaborator

@kevinbackhouse kevinbackhouse commented Jul 8, 2022

This moves the declarations of enums IfdId and SectionId from src/tags_int.hpp to include/exiv2/tags.hpp. I think it makes the code a bit cleaner because now the TagInfo struct can use those enums rather than int.

But maybe there's a reason why IfdId and SectionId shouldn't be included in the public interface that I'm not aware of? If so, I'll close this PR.

@kevinbackhouse kevinbackhouse added this to the v1.00 milestone Jul 8, 2022
@codecov
Copy link

codecov bot commented Jul 8, 2022

Codecov Report

Merging #2276 (3ef783e) into main (a22aea0) will decrease coverage by 0.00%.
The diff coverage is 63.63%.

@@            Coverage Diff             @@
##             main    #2276      +/-   ##
==========================================
- Coverage   63.48%   63.47%   -0.01%     
==========================================
  Files         118      118              
  Lines       19598    19579      -19     
  Branches     9556     9549       -7     
==========================================
- Hits        12442    12428      -14     
+ Misses       5092     5091       -1     
+ Partials     2064     2060       -4     
Impacted Files Coverage Δ
include/exiv2/exif.hpp 100.00% <ø> (ø)
include/exiv2/tags.hpp 33.33% <0.00%> (-66.67%) ⬇️
src/canonmn_int.cpp 71.55% <ø> (ø)
src/casiomn_int.cpp 6.89% <ø> (ø)
src/cr2header_int.cpp 68.42% <0.00%> (ø)
src/cr2image.cpp 19.48% <ø> (ø)
src/fujimn_int.cpp 100.00% <ø> (ø)
src/minoltamn_int.cpp 55.06% <ø> (ø)
src/nikonmn_int.cpp 57.14% <ø> (+0.03%) ⬆️
src/olympusmn_int.cpp 38.38% <ø> (ø)
... and 33 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a22aea0...3ef783e. Read the comment docs.

piponazo
piponazo previously approved these changes Jul 11, 2022
Copy link
Collaborator

@piponazo piponazo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not have anything against moving that enum to the API, and it makes sense to have it there so that TagInfo can reuse it. 👍

@@ -47,18 +47,192 @@ struct EXIV2API GroupInfo::GroupName {
std::string g_; //!< Group name
};

//! Type to specify the IFD to which a metadata belongs
enum IfdId {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion] Did you think about making this enumeration a scoped enum (enum class)? I think it would help for code readability.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good suggestion!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a commit that does this. It's a big diff! I used a script to make most of the changes.

@mergify mergify bot dismissed piponazo’s stale review July 11, 2022 21:11

Pull request has been modified.

@neheb
Copy link
Collaborator

neheb commented Jul 11, 2022

--- ./src/image_int.hpp	(original)
+++ ./src/image_int.hpp	(reformatted)
@@ -65,7 +65,7 @@
   explicit binaryToStringHelper(const Slice<T> myBuf) noexcept : buf_(myBuf) {
   }
-  friend std::ostream& operator<< <T>(std::ostream& stream, const binaryToStringHelper<T>& binToStr);
+  friend std::ostream& operator<<<T>(std::ostream& stream, const binaryToStringHelper<T>& binToStr);
   // the Slice is stored by value to avoid dangling references, in case we
   // invoke:

This is a difference between clang-format-12 and 14. Needs to be updated IMO.

if (!ti)
return sectionInfo[unknownTag.sectionId_].name_;
return sectionInfo[ti->sectionId_].name_;
return sectionInfo[static_cast<int>(unknownTag.sectionId_)].name_;

Check warning

Code scanning / CodeQL

Unsafe vector access

Unsafe use of operator\[\]. Use the at() method instead.
return sectionInfo[unknownTag.sectionId_].name_;
return sectionInfo[ti->sectionId_].name_;
return sectionInfo[static_cast<int>(unknownTag.sectionId_)].name_;
return sectionInfo[static_cast<int>(ti->sectionId_)].name_;

Check warning

Code scanning / CodeQL

Unsafe vector access

Unsafe use of operator\[\]. Use the at() method instead.
Copy link
Collaborator

@piponazo piponazo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot! Specially for the additional effort for the final commit 👏

@piponazo
Copy link
Collaborator

This is a difference between clang-format-12 and 14. Needs to be updated IMO.

Few months ago when I introduced the clang-format workflow we discussed about this and we decided to use the clang-version coming with ubuntu-latest. However, if this is bothering you guys, I do not any objection to upgrade to clang-format-14. It can be done by just updating this file: .github/workflows/on_push_clang_format.yml. More information about the action can be found here:

https://github.com/DoozyX/clang-format-lint-action

@kevinbackhouse
Copy link
Collaborator Author

@piponazo @neheb: Regarding the clang-format version, I think the best choice is whatever people are most likely to have installed on their computers. I'm running Ubuntu 22.04, which comes with clang 14, but I expect most people are using Macs or Windows, and I don't know which version is the default on those platforms.

I can easily use a docker container to run version 12 if necessary, so I'm happy to work around this if 12 is the most popular choice.

@kevinbackhouse kevinbackhouse merged commit 0558662 into Exiv2:main Jul 12, 2022
@kevinbackhouse kevinbackhouse deleted the TagInfo-enums branch July 12, 2022 09:23
@jim-easterbrook
Copy link
Contributor

But maybe there's a reason why IfdId and SectionId shouldn't be included in the public interface that I'm not aware of? If so, I'll close this PR.

I just happened across this, making IfdId internal 11 years ago: https://dev.exiv2.org/issues/721

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants