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

Refactoring & cleanup #2109

Merged
merged 25 commits into from
Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3d370cc
Improvements in urlencode
piponazo Feb 16, 2022
f1ff3aa
Make urldecode in-place
piponazo Feb 16, 2022
6f762b4
Use std::filesystem for fileExist
piponazo Feb 16, 2022
0726104
Hide pathOfFileUrl in the only place where it is used
piponazo Feb 16, 2022
45300ad
BasicIo::path() returns const ref
piponazo Feb 16, 2022
8b2d173
ReplaceStringInPlace does it in-place now
piponazo Feb 16, 2022
9b3a643
Use rename from filesystem
piponazo Feb 16, 2022
56b5ab9
Use remove from filesystem
piponazo Feb 16, 2022
a6185d2
Image::setComment now takes string_view
piponazo Feb 16, 2022
798cf9b
Remove dead code (winNumberOfLinks)
piponazo Feb 17, 2022
c0b663b
Remove dead code (LSTAT)
piponazo Feb 17, 2022
1d243ed
Remove dead code: copyXattrFrom
piponazo Feb 17, 2022
ea201ce
Remove dead code
piponazo Feb 17, 2022
d11479e
Replace dynamic C array by std::vector
piponazo Feb 17, 2022
59f4d0d
cppcheck: reduce scope of variables
piponazo Feb 17, 2022
476a5e2
Replace raw loop for any_of
piponazo Feb 17, 2022
b543f3e
Use filesystem in getExiv2ConfigPath
piponazo Feb 18, 2022
7e5ba7c
Remove many redundant or not needed header inclusions
piponazo Feb 18, 2022
7caf409
Use fs::file_size instead of stat
piponazo Feb 18, 2022
f060b58
Clean config.h from old stuff
piponazo Feb 18, 2022
76f01fd
Clean more header inclusions
piponazo Feb 18, 2022
9fb43f2
Use standard [[maybe_unused]]
piponazo Feb 18, 2022
f774a3b
Fix build on linux
piponazo Feb 18, 2022
8b3da36
Improvements from code review
piponazo Feb 19, 2022
21eb0ce
Fix build when EXIV2_BUILD_MESSAGES is ON
piponazo Feb 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ add_library( exiv2lib_int OBJECT
tifffwd_int.hpp
timegm.h
unused.h
utils.hpp utils.cpp
)

set(PUBLIC_HEADERS
Expand Down
6 changes: 1 addition & 5 deletions src/epsimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "basicio.hpp"
#include "error.hpp"
#include "futils.hpp"
#include "utils.hpp"
#include "version.hpp"

// + standard includes
Expand Down Expand Up @@ -103,11 +104,6 @@ namespace {
// closing part of all valid XMP trailers
const std::string xmpTrailerEnd = "?>";

constexpr bool startsWith(const std::string_view& s, const std::string_view& start)
{
return s.find(start) == 0;
}

//! Write data into temp file, taking care of errors
void writeTemp(BasicIo& tempIo, const byte* data, size_t size)
{
Expand Down
8 changes: 3 additions & 5 deletions src/makernote_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "tiffvisitor_int.hpp"
#include "tiffimage.hpp"
#include "tiffimage_int.hpp"
#include "utils.hpp"

// + standard includes
#include <string>
Expand Down Expand Up @@ -1223,11 +1224,8 @@ namespace Exiv2 {
{
// Not valid for models beginning
std::string model = getExifModel(pRoot);
for (auto& m : { "SLT-", "HV", "ILCA-" }) {
if (model.find(m) == 0)
return -1;
}
return 0;
const std::vector<std::string> strs { "SLT-", "HV", "ILCA-"};
piponazo marked this conversation as resolved.
Show resolved Hide resolved
return std::any_of(strs.begin(), strs.end(), [&model](auto& m){return startsWith(model, m);}) ? -1 : 0;
}

int sonyMisc2bSelector(uint16_t /*tag*/, const byte* /*pData*/, uint32_t /*size*/, TiffComponent* const pRoot)
Expand Down
9 changes: 9 additions & 0 deletions src/utils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "utils.hpp"

namespace Exiv2
{
bool startsWith(const std::string_view& s, const std::string_view& start)
{
return s.find(start) == 0;
}
}
11 changes: 11 additions & 0 deletions src/utils.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef EXIV2_UTILS_HPP
#define EXIV2_UTILS_HPP

#include <string_view>

namespace Exiv2
{
bool startsWith(const std::string_view& s, const std::string_view& start);
}

#endif // EXIV2_UTILS_HPP