Replace raw loop for any_of
This commit is contained in:
parent
59f4d0de27
commit
476a5e23f9
@ -36,6 +36,7 @@ add_library( exiv2lib_int OBJECT
|
||||
tifffwd_int.hpp
|
||||
timegm.h
|
||||
unused.h
|
||||
utils.hpp utils.cpp
|
||||
)
|
||||
|
||||
set(PUBLIC_HEADERS
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
#include "basicio.hpp"
|
||||
#include "error.hpp"
|
||||
#include "futils.hpp"
|
||||
#include "utils.hpp"
|
||||
#include "version.hpp"
|
||||
|
||||
// + standard includes
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
#include "tiffvisitor_int.hpp"
|
||||
#include "tiffimage.hpp"
|
||||
#include "tiffimage_int.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
// + standard includes
|
||||
#include <string>
|
||||
@ -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-"};
|
||||
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)
|
||||
|
||||
9
src/utils.cpp
Normal file
9
src/utils.cpp
Normal file
@ -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
src/utils.hpp
Normal file
11
src/utils.hpp
Normal file
@ -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
|
||||
Loading…
Reference in New Issue
Block a user