Simplify code around UniquePtr(s) & use make_unique over new
This commit is contained in:
+90
-91
@@ -200,15 +200,15 @@ namespace Action {
|
||||
TaskFactory::TaskFactory()
|
||||
{
|
||||
// Register a prototype of each known task
|
||||
registerTask(adjust, Task::UniquePtr(new Adjust));
|
||||
registerTask(print, Task::UniquePtr(new Print));
|
||||
registerTask(rename, Task::UniquePtr(new Rename));
|
||||
registerTask(erase, Task::UniquePtr(new Erase));
|
||||
registerTask(extract, Task::UniquePtr(new Extract));
|
||||
registerTask(insert, Task::UniquePtr(new Insert));
|
||||
registerTask(modify, Task::UniquePtr(new Modify));
|
||||
registerTask(fixiso, Task::UniquePtr(new FixIso));
|
||||
registerTask(fixcom, Task::UniquePtr(new FixCom));
|
||||
registerTask(adjust, std::make_unique<Adjust>());
|
||||
registerTask(print, std::make_unique<Print>());
|
||||
registerTask(rename, std::make_unique<Rename>());
|
||||
registerTask(erase, std::make_unique<Erase>());
|
||||
registerTask(extract, std::make_unique<Extract>());
|
||||
registerTask(insert, std::make_unique<Insert>());
|
||||
registerTask(modify, std::make_unique<Modify>());
|
||||
registerTask(fixiso, std::make_unique<FixIso>());
|
||||
registerTask(fixcom, std::make_unique<FixCom>());
|
||||
} // TaskFactory c'tor
|
||||
|
||||
Task::UniquePtr TaskFactory::create(TaskType type)
|
||||
@@ -287,12 +287,12 @@ namespace Action {
|
||||
int Print::printSummary()
|
||||
{
|
||||
if (!Exiv2::fileExists(path_, true)) {
|
||||
std::cerr << path_ << ": "
|
||||
<< _("Failed to open the file\n");
|
||||
std::cerr << path_ << ": " << _("Failed to open the file\n");
|
||||
return -1;
|
||||
}
|
||||
Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(path_);
|
||||
assert(image.get() != 0);
|
||||
|
||||
auto image = Exiv2::ImageFactory::open(path_);
|
||||
assert(image);
|
||||
image->readMetadata();
|
||||
Exiv2::ExifData& exifData = image->exifData();
|
||||
align_ = 16;
|
||||
@@ -421,12 +421,12 @@ namespace Action {
|
||||
int Print::printList()
|
||||
{
|
||||
if (!Exiv2::fileExists(path_, true)) {
|
||||
std::cerr << path_
|
||||
<< ": " << _("Failed to open the file\n");
|
||||
std::cerr << path_ << ": " << _("Failed to open the file\n");
|
||||
return -1;
|
||||
}
|
||||
Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(path_);
|
||||
assert(image.get() != 0);
|
||||
|
||||
auto image = Exiv2::ImageFactory::open(path_);
|
||||
assert(image);
|
||||
image->readMetadata();
|
||||
// Set defaults for metadata types and data columns
|
||||
if (Params::instance().printTags_ == Exiv2::mdNone) {
|
||||
@@ -626,12 +626,12 @@ namespace Action {
|
||||
int Print::printComment()
|
||||
{
|
||||
if (!Exiv2::fileExists(path_, true)) {
|
||||
std::cerr << path_
|
||||
<< ": " << _("Failed to open the file\n");
|
||||
std::cerr << path_ << ": " << _("Failed to open the file\n");
|
||||
return -1;
|
||||
}
|
||||
Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(path_);
|
||||
assert(image.get() != 0);
|
||||
|
||||
auto image = Exiv2::ImageFactory::open(path_);
|
||||
assert(image);
|
||||
image->readMetadata();
|
||||
if (Params::instance().verbose_) {
|
||||
std::cout << _("JPEG comment") << ": ";
|
||||
@@ -643,12 +643,12 @@ namespace Action {
|
||||
int Print::printPreviewList()
|
||||
{
|
||||
if (!Exiv2::fileExists(path_, true)) {
|
||||
std::cerr << path_
|
||||
<< ": " << _("Failed to open the file\n");
|
||||
std::cerr << path_ << ": " << _("Failed to open the file\n");
|
||||
return -1;
|
||||
}
|
||||
Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(path_);
|
||||
assert(image.get() != 0);
|
||||
|
||||
auto image = Exiv2::ImageFactory::open(path_);
|
||||
assert(image);
|
||||
image->readMetadata();
|
||||
bool const manyFiles = Params::instance().files_.size() > 1;
|
||||
int cnt = 0;
|
||||
@@ -682,15 +682,15 @@ namespace Action {
|
||||
{
|
||||
try {
|
||||
if (!Exiv2::fileExists(path, true)) {
|
||||
std::cerr << path
|
||||
<< ": " << _("Failed to open the file\n");
|
||||
std::cerr << path << ": " << _("Failed to open the file\n");
|
||||
return -1;
|
||||
}
|
||||
Timestamp ts;
|
||||
if (Params::instance().preserve_) ts.read(path);
|
||||
if (Params::instance().preserve_)
|
||||
ts.read(path);
|
||||
|
||||
Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(path);
|
||||
assert(image.get() != 0);
|
||||
auto image = Exiv2::ImageFactory::open(path);
|
||||
assert(image);
|
||||
image->readMetadata();
|
||||
Exiv2::ExifData& exifData = image->exifData();
|
||||
if (exifData.empty()) {
|
||||
@@ -750,7 +750,8 @@ namespace Action {
|
||||
std::cerr << "Exiv2 exception in rename action for file " << path
|
||||
<< ":\n" << e << "\n";
|
||||
return 1;
|
||||
}} // Rename::run
|
||||
}
|
||||
}
|
||||
|
||||
Rename::UniquePtr Rename::clone() const
|
||||
{
|
||||
@@ -763,19 +764,20 @@ namespace Action {
|
||||
}
|
||||
|
||||
int Erase::run(const std::string& path)
|
||||
{
|
||||
try {
|
||||
path_ = path;
|
||||
|
||||
if (!Exiv2::fileExists(path_, true)) {
|
||||
std::cerr << path_
|
||||
<< ": " << _("Failed to open the file\n");
|
||||
std::cerr << path_ << ": " << _("Failed to open the file\n");
|
||||
return -1;
|
||||
}
|
||||
Timestamp ts;
|
||||
if (Params::instance().preserve_) ts.read(path);
|
||||
if (Params::instance().preserve_)
|
||||
ts.read(path);
|
||||
|
||||
Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(path_);
|
||||
assert(image.get() != 0);
|
||||
auto image = Exiv2::ImageFactory::open(path_);
|
||||
assert(image);
|
||||
image->readMetadata();
|
||||
// Thumbnail must be before Exif
|
||||
int rc = 0;
|
||||
@@ -813,7 +815,8 @@ namespace Action {
|
||||
std::cerr << "Exiv2 exception in erase action for file " << path
|
||||
<< ":\n" << e << "\n";
|
||||
return 1;
|
||||
} // Erase::run
|
||||
}
|
||||
}
|
||||
|
||||
int Erase::eraseThumbnail(Exiv2::Image* image)
|
||||
{
|
||||
@@ -931,17 +934,15 @@ namespace Action {
|
||||
int Extract::writeThumbnail() const
|
||||
{
|
||||
if (!Exiv2::fileExists(path_, true)) {
|
||||
std::cerr << path_
|
||||
<< ": " << _("Failed to open the file\n");
|
||||
std::cerr << path_ << ": " << _("Failed to open the file\n");
|
||||
return -1;
|
||||
}
|
||||
Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(path_);
|
||||
assert(image.get() != 0);
|
||||
auto image = Exiv2::ImageFactory::open(path_);
|
||||
assert(image);
|
||||
image->readMetadata();
|
||||
Exiv2::ExifData& exifData = image->exifData();
|
||||
if (exifData.empty()) {
|
||||
std::cerr << path_
|
||||
<< ": " << _("No Exif data found in the file\n");
|
||||
std::cerr << path_ << ": " << _("No Exif data found in the file\n");
|
||||
return -3;
|
||||
}
|
||||
int rc = 0;
|
||||
@@ -980,12 +981,12 @@ namespace Action {
|
||||
int Extract::writePreviews() const
|
||||
{
|
||||
if (!Exiv2::fileExists(path_, true)) {
|
||||
std::cerr << path_
|
||||
<< ": " << _("Failed to open the file\n");
|
||||
std::cerr << path_ << ": " << _("Failed to open the file\n");
|
||||
return -1;
|
||||
}
|
||||
Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(path_);
|
||||
assert(image.get() != 0);
|
||||
|
||||
auto image = Exiv2::ImageFactory::open(path_);
|
||||
assert(image);
|
||||
image->readMetadata();
|
||||
|
||||
Exiv2::PreviewManager pvMgr(*image);
|
||||
@@ -1016,16 +1017,15 @@ namespace Action {
|
||||
{
|
||||
int rc = 0;
|
||||
if (!Exiv2::fileExists(path_, true)) {
|
||||
std::cerr << path_
|
||||
<< ": " << _("Failed to open the file\n");
|
||||
std::cerr << path_ << ": " << _("Failed to open the file\n");
|
||||
rc = -1;
|
||||
}
|
||||
|
||||
bool bStdout = target == "-" ;
|
||||
|
||||
if ( rc == 0 ) {
|
||||
Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(path_);
|
||||
assert(image.get() != 0);
|
||||
auto image = Exiv2::ImageFactory::open(path_);
|
||||
assert(image);
|
||||
image->readMetadata();
|
||||
if ( !image->iccProfileDefined() ) {
|
||||
std::cerr << _("No embedded iccProfile: ") << path_ << std::endl;
|
||||
@@ -1169,8 +1169,8 @@ namespace Action {
|
||||
for ( long i = 0 ; i < xmpBlob.size() ; i++ ) {
|
||||
xmpPacket += static_cast<char>(xmpBlob.read_uint8(i));
|
||||
}
|
||||
Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(path);
|
||||
assert(image.get() != 0);
|
||||
auto image = Exiv2::ImageFactory::open(path);
|
||||
assert(image);
|
||||
image->readMetadata();
|
||||
image->clearXmpData();
|
||||
image->setXmpPacket(xmpPacket);
|
||||
@@ -1213,8 +1213,8 @@ namespace Action {
|
||||
|
||||
// read in the metadata
|
||||
if ( rc == 0 ) {
|
||||
Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(path);
|
||||
assert(image.get() != 0);
|
||||
auto image = Exiv2::ImageFactory::open(path);
|
||||
assert(image);
|
||||
image->readMetadata();
|
||||
// clear existing profile, assign the blob and rewrite image
|
||||
image->clearIccProfile();
|
||||
@@ -1240,8 +1240,8 @@ namespace Action {
|
||||
<< ": " << _("Failed to open the file\n");
|
||||
return -1;
|
||||
}
|
||||
Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(path);
|
||||
assert(image.get() != 0);
|
||||
auto image = Exiv2::ImageFactory::open(path);
|
||||
assert(image);
|
||||
image->readMetadata();
|
||||
Exiv2::ExifThumb exifThumb(image->exifData());
|
||||
exifThumb.setJpegThumbnail(thumbPath);
|
||||
@@ -1264,15 +1264,15 @@ namespace Action {
|
||||
{
|
||||
try {
|
||||
if (!Exiv2::fileExists(path, true)) {
|
||||
std::cerr << path
|
||||
<< ": " << _("Failed to open the file\n");
|
||||
std::cerr << path << ": " << _("Failed to open the file\n");
|
||||
return -1;
|
||||
}
|
||||
Timestamp ts;
|
||||
if (Params::instance().preserve_) ts.read(path);
|
||||
if (Params::instance().preserve_)
|
||||
ts.read(path);
|
||||
|
||||
Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(path);
|
||||
assert(image.get() != 0);
|
||||
auto image = Exiv2::ImageFactory::open(path);
|
||||
assert(image);
|
||||
image->readMetadata();
|
||||
|
||||
int rc = applyCommands(image.get());
|
||||
@@ -1347,7 +1347,7 @@ namespace Action {
|
||||
Exiv2::ExifData& exifData = pImage->exifData();
|
||||
Exiv2::IptcData& iptcData = pImage->iptcData();
|
||||
Exiv2::XmpData& xmpData = pImage->xmpData();
|
||||
Exiv2::Value::UniquePtr value = Exiv2::Value::create(modifyCmd.typeId_);
|
||||
auto value = Exiv2::Value::create(modifyCmd.typeId_);
|
||||
int rc = value->read(modifyCmd.value_);
|
||||
if (0 == rc) {
|
||||
if (modifyCmd.metadataId_ == exif) {
|
||||
@@ -1501,15 +1501,15 @@ namespace Action {
|
||||
dayAdjustment_ = Params::instance().yodAdjust_[Params::yodDay].adjustment_;
|
||||
|
||||
if (!Exiv2::fileExists(path, true)) {
|
||||
std::cerr << path
|
||||
<< ": " << _("Failed to open the file\n");
|
||||
std::cerr << path << ": " << _("Failed to open the file\n");
|
||||
return -1;
|
||||
}
|
||||
Timestamp ts;
|
||||
if (Params::instance().preserve_) ts.read(path);
|
||||
if (Params::instance().preserve_)
|
||||
ts.read(path);
|
||||
|
||||
Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(path);
|
||||
assert(image.get() != 0);
|
||||
auto image = Exiv2::ImageFactory::open(path);
|
||||
assert(image);
|
||||
image->readMetadata();
|
||||
Exiv2::ExifData& exifData = image->exifData();
|
||||
if (exifData.empty()) {
|
||||
@@ -1633,20 +1633,19 @@ namespace Action {
|
||||
{
|
||||
try {
|
||||
if (!Exiv2::fileExists(path, true)) {
|
||||
std::cerr << path
|
||||
<< ": " <<_("Failed to open the file\n");
|
||||
std::cerr << path << ": " <<_("Failed to open the file\n");
|
||||
return -1;
|
||||
}
|
||||
Timestamp ts;
|
||||
if (Params::instance().preserve_) ts.read(path);
|
||||
if (Params::instance().preserve_)
|
||||
ts.read(path);
|
||||
|
||||
Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(path);
|
||||
assert(image.get() != 0);
|
||||
auto image = Exiv2::ImageFactory::open(path);
|
||||
assert(image);
|
||||
image->readMetadata();
|
||||
Exiv2::ExifData& exifData = image->exifData();
|
||||
if (exifData.empty()) {
|
||||
std::cerr << path
|
||||
<< ": " << _("No Exif data found in the file\n");
|
||||
std::cerr << path << ": " << _("No Exif data found in the file\n");
|
||||
return -3;
|
||||
}
|
||||
auto md = Exiv2::isoSpeed(exifData);
|
||||
@@ -1692,20 +1691,19 @@ namespace Action {
|
||||
{
|
||||
try {
|
||||
if (!Exiv2::fileExists(path, true)) {
|
||||
std::cerr << path
|
||||
<< ": " <<_("Failed to open the file\n");
|
||||
std::cerr << path << ": " <<_("Failed to open the file\n");
|
||||
return -1;
|
||||
}
|
||||
Timestamp ts;
|
||||
if (Params::instance().preserve_) ts.read(path);
|
||||
if (Params::instance().preserve_)
|
||||
ts.read(path);
|
||||
|
||||
Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(path);
|
||||
assert(image.get() != 0);
|
||||
auto image = Exiv2::ImageFactory::open(path);
|
||||
assert(image);
|
||||
image->readMetadata();
|
||||
Exiv2::ExifData& exifData = image->exifData();
|
||||
if (exifData.empty()) {
|
||||
std::cerr << path
|
||||
<< ": " << _("No Exif data found in the file\n");
|
||||
std::cerr << path << ": " << _("No Exif data found in the file\n");
|
||||
return -3;
|
||||
}
|
||||
auto pos = exifData.findKey(Exiv2::ExifKey("Exif.Photo.UserComment"));
|
||||
@@ -1891,8 +1889,7 @@ namespace {
|
||||
// read the source metadata
|
||||
int rc = -1 ;
|
||||
if (!Exiv2::fileExists(source, true)) {
|
||||
std::cerr << source
|
||||
<< ": " << _("Failed to open the file\n");
|
||||
std::cerr << source << ": " << _("Failed to open the file\n");
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1900,11 +1897,13 @@ namespace {
|
||||
bool bStdout = tgt == "-";
|
||||
|
||||
Exiv2::DataBuf stdIn;
|
||||
if ( bStdin ) Params::instance().getStdin(stdIn);
|
||||
Exiv2::BasicIo::UniquePtr ioStdin = Exiv2::BasicIo::UniquePtr(new Exiv2::MemIo(stdIn.c_data(),stdIn.size()));
|
||||
if ( bStdin )
|
||||
Params::instance().getStdin(stdIn);
|
||||
|
||||
Exiv2::Image::UniquePtr sourceImage = bStdin ? Exiv2::ImageFactory::open(std::move(ioStdin)) : Exiv2::ImageFactory::open(source);
|
||||
assert(sourceImage.get() != 0);
|
||||
auto ioStdin = std::make_unique<Exiv2::MemIo>(stdIn.c_data(),stdIn.size());
|
||||
auto sourceImage = bStdin ? Exiv2::ImageFactory::open(std::move(ioStdin)) : Exiv2::ImageFactory::open(source);
|
||||
|
||||
assert(sourceImage);
|
||||
sourceImage->readMetadata();
|
||||
|
||||
// Apply any modification commands to the source image on-the-fly
|
||||
@@ -1913,14 +1912,14 @@ namespace {
|
||||
// Open or create the target file
|
||||
std::string target(bStdout ? temporaryPath() : tgt);
|
||||
|
||||
Exiv2::Image::UniquePtr targetImage;
|
||||
std::unique_ptr<Exiv2::Image> targetImage;
|
||||
if (Exiv2::fileExists(target)) {
|
||||
targetImage = Exiv2::ImageFactory::open(target);
|
||||
assert(targetImage.get() != 0);
|
||||
assert(targetImage);
|
||||
targetImage->readMetadata();
|
||||
} else {
|
||||
targetImage = Exiv2::ImageFactory::create(targetType, target);
|
||||
assert(targetImage.get() != 0);
|
||||
assert(targetImage);
|
||||
}
|
||||
|
||||
// Copy each type of metadata
|
||||
|
||||
+1
-1
@@ -712,7 +712,7 @@ namespace Exiv2
|
||||
// free functions
|
||||
Image::UniquePtr newBmffInstance(BasicIo::UniquePtr io, bool create)
|
||||
{
|
||||
Image::UniquePtr image(new BmffImage(std::move(io), create));
|
||||
auto image = std::make_unique<BmffImage>(std::move(io), create);
|
||||
if (!image->good()) {
|
||||
image.reset();
|
||||
}
|
||||
|
||||
+1
-1
@@ -122,7 +122,7 @@ namespace Exiv2
|
||||
// free functions
|
||||
Image::UniquePtr newBmpInstance(BasicIo::UniquePtr io, bool /*create*/)
|
||||
{
|
||||
Image::UniquePtr image(new BmpImage(std::move(io)));
|
||||
auto image = std::make_unique<BmpImage>(std::move(io));
|
||||
if (!image->good()) {
|
||||
image.reset();
|
||||
}
|
||||
|
||||
+1
-1
@@ -196,7 +196,7 @@ namespace Exiv2 {
|
||||
// free functions
|
||||
Image::UniquePtr newCr2Instance(BasicIo::UniquePtr io, bool create)
|
||||
{
|
||||
Image::UniquePtr image(new Cr2Image(std::move(io), create));
|
||||
auto image = std::make_unique<Cr2Image>(std::move(io), create);
|
||||
if (!image->good()) {
|
||||
image.reset();
|
||||
}
|
||||
|
||||
+12
-14
@@ -132,8 +132,7 @@ namespace Exiv2 {
|
||||
CrwParser::encode(blob, buf.c_data(), buf.size(), this);
|
||||
|
||||
// Write new buffer to file
|
||||
MemIo::UniquePtr tempIo(new MemIo);
|
||||
assert(tempIo.get() != 0);
|
||||
auto tempIo = std::make_unique<MemIo>();
|
||||
tempIo->write((!blob.empty() ? &blob[0] : nullptr), static_cast<long>(blob.size()));
|
||||
io_->close();
|
||||
io_->transfer(*tempIo); // may throw
|
||||
@@ -146,15 +145,15 @@ namespace Exiv2 {
|
||||
assert(pData != 0);
|
||||
|
||||
// Parse the image, starting with a CIFF header component
|
||||
CiffHeader::UniquePtr head(new CiffHeader);
|
||||
head->read(pData, size);
|
||||
CiffHeader header;
|
||||
header.read(pData, size);
|
||||
#ifdef EXIV2_DEBUG_MESSAGES
|
||||
head->print(std::cerr);
|
||||
header.print(std::cerr);
|
||||
#endif
|
||||
head->decode(*pCrwImage);
|
||||
header.decode(*pCrwImage);
|
||||
|
||||
// a hack to get absolute offset of preview image inside CRW structure
|
||||
CiffComponent* preview = head->findComponent(0x2007, 0x0000);
|
||||
CiffComponent* preview = header.findComponent(0x2007, 0x0000);
|
||||
if (preview) {
|
||||
(pCrwImage->exifData())["Exif.Image2.JPEGInterchangeFormat"] = uint32_t(preview->pData() - pData);
|
||||
(pCrwImage->exifData())["Exif.Image2.JPEGInterchangeFormatLength"] = preview->size();
|
||||
@@ -169,23 +168,22 @@ namespace Exiv2 {
|
||||
)
|
||||
{
|
||||
// Parse image, starting with a CIFF header component
|
||||
CiffHeader::UniquePtr head(new CiffHeader);
|
||||
CiffHeader header;
|
||||
if (size != 0) {
|
||||
head->read(pData, size);
|
||||
header.read(pData, size);
|
||||
}
|
||||
|
||||
// Encode Exif tags from image into the CRW parse tree and write the
|
||||
// structure to the binary image blob
|
||||
CrwMap::encode(head.get(), *pCrwImage);
|
||||
head->write(blob);
|
||||
|
||||
} // CrwParser::encode
|
||||
CrwMap::encode(&header, *pCrwImage);
|
||||
header.write(blob);
|
||||
}
|
||||
|
||||
// *************************************************************************
|
||||
// free functions
|
||||
Image::UniquePtr newCrwInstance(BasicIo::UniquePtr io, bool create)
|
||||
{
|
||||
Image::UniquePtr image(new CrwImage(std::move(io), create));
|
||||
auto image = std::make_unique<CrwImage>(std::move(io), create);
|
||||
if (!image->good()) {
|
||||
image.reset();
|
||||
}
|
||||
|
||||
@@ -316,10 +316,10 @@ namespace Exiv2 {
|
||||
|
||||
for (uint16_t i = 0; i < count; ++i) {
|
||||
uint16_t tag = getUShort(pData + o, byteOrder);
|
||||
CiffComponent::UniquePtr m;
|
||||
std::unique_ptr<CiffComponent> m;
|
||||
switch (CiffComponent::typeId(tag)) {
|
||||
case directory: m = CiffComponent::UniquePtr(new CiffDirectory); break;
|
||||
default: m = CiffComponent::UniquePtr(new CiffEntry); break;
|
||||
case directory: m = std::make_unique<CiffDirectory>(); break;
|
||||
default: m = std::make_unique<CiffEntry>(); break;
|
||||
}
|
||||
m->setDir(this->tag());
|
||||
m->read(pData, size, o, byteOrder);
|
||||
@@ -533,9 +533,8 @@ namespace Exiv2 {
|
||||
<< ", " << _("size") << " = " << std::dec << size_
|
||||
<< ", " << _("offset") << " = " << offset_ << "\n";
|
||||
|
||||
Value::UniquePtr value;
|
||||
if (typeId() != directory) {
|
||||
value = Value::create(typeId());
|
||||
auto value = Value::create(typeId());
|
||||
value->read(pData_, size_, byteOrder);
|
||||
if (value->size() < 100) {
|
||||
os << prefix << *value << "\n";
|
||||
@@ -679,7 +678,7 @@ namespace Exiv2 {
|
||||
}
|
||||
if (cc_ == nullptr) {
|
||||
// Directory doesn't exist yet, add it
|
||||
m_ = UniquePtr(new CiffDirectory(csd.crwDir_, csd.parent_));
|
||||
m_ = std::make_unique<CiffDirectory>(csd.crwDir_, csd.parent_);
|
||||
cc_ = m_.get();
|
||||
add(std::move(m_));
|
||||
}
|
||||
@@ -809,7 +808,7 @@ namespace Exiv2 {
|
||||
|
||||
// Make
|
||||
ExifKey key1("Exif.Image.Make");
|
||||
Value::UniquePtr value1 = Value::create(ciffComponent.typeId());
|
||||
auto value1 = Value::create(ciffComponent.typeId());
|
||||
uint32_t i = 0;
|
||||
while (i < ciffComponent.size() && ciffComponent.pData()[i++] != '\0') {
|
||||
// empty
|
||||
@@ -819,7 +818,7 @@ namespace Exiv2 {
|
||||
|
||||
// Model
|
||||
ExifKey key2("Exif.Image.Model");
|
||||
Value::UniquePtr value2 = Value::create(ciffComponent.typeId());
|
||||
auto value2 = Value::create(ciffComponent.typeId());
|
||||
uint32_t j = i;
|
||||
while (i < ciffComponent.size() && ciffComponent.pData()[i++] != '\0') {
|
||||
// empty
|
||||
@@ -951,7 +950,7 @@ namespace Exiv2 {
|
||||
assert(pCrwMapping != 0);
|
||||
// create a key and value pair
|
||||
ExifKey key(pCrwMapping->tag_, Internal::groupName(pCrwMapping->ifdId_));
|
||||
Value::UniquePtr value;
|
||||
std::unique_ptr<Value> value;
|
||||
if (ciffComponent.typeId() != directory) {
|
||||
value = Value::create(ciffComponent.typeId());
|
||||
uint32_t size = 0;
|
||||
|
||||
+67
-68
@@ -124,7 +124,7 @@ namespace {
|
||||
}
|
||||
|
||||
//! Get the current write position of temp file, taking care of errors
|
||||
uint32_t posTemp(BasicIo& tempIo)
|
||||
uint32_t posTemp(const BasicIo& tempIo)
|
||||
{
|
||||
const long pos = tempIo.tell();
|
||||
if (pos == -1) {
|
||||
@@ -802,9 +802,8 @@ namespace {
|
||||
}
|
||||
|
||||
// create temporary output file
|
||||
BasicIo::UniquePtr tempIo(new MemIo);
|
||||
assert (tempIo.get() != 0);
|
||||
if (!tempIo->isopen()) {
|
||||
MemIo tempIo;
|
||||
if (!tempIo.isopen()) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
EXV_WARNING << "Unable to create temporary file for writing.\n";
|
||||
#endif
|
||||
@@ -839,10 +838,10 @@ namespace {
|
||||
// assemble result EPS document
|
||||
if (dosEps) {
|
||||
// DOS EPS header will be written afterwards
|
||||
writeTemp(*tempIo, std::string(30, '\x00'));
|
||||
writeTemp(tempIo, std::string(30, '\x00'));
|
||||
}
|
||||
const std::string containsXmpLine = deleteXmp ? "%ADO_ContainsXMP: NoMain" : "%ADO_ContainsXMP: MainFirst";
|
||||
const uint32_t posEpsNew = posTemp(*tempIo);
|
||||
const uint32_t posEpsNew = posTemp(tempIo);
|
||||
size_t prevPos = posEps;
|
||||
size_t prevSkipPos = prevPos;
|
||||
for (auto&& pos : positions) {
|
||||
@@ -857,12 +856,12 @@ namespace {
|
||||
#endif
|
||||
throw Error(kerImageWriteFailed);
|
||||
}
|
||||
writeTemp(*tempIo, data + prevSkipPos, pos - prevSkipPos);
|
||||
writeTemp(tempIo, data + prevSkipPos, pos - prevSkipPos);
|
||||
const size_t posLineEnd = readLine(line, data, pos, posEndEps);
|
||||
size_t skipPos = pos;
|
||||
// add last line ending if necessary
|
||||
if (pos == posEndEps && pos >= 1 && data[pos - 1] != '\r' && data[pos - 1] != '\n') {
|
||||
writeTemp(*tempIo, lineEnding);
|
||||
writeTemp(tempIo, lineEnding);
|
||||
#ifdef DEBUG
|
||||
EXV_DEBUG << "readWriteEpsMetadata: Added missing line ending of last line\n";
|
||||
#endif
|
||||
@@ -870,7 +869,7 @@ namespace {
|
||||
// update and complement DSC comments
|
||||
if (pos == posLanguageLevel && posLanguageLevel != posEndEps && !deleteXmp && !useFlexibleEmbedding) {
|
||||
if (line == "%%LanguageLevel:1" || line == "%%LanguageLevel: 1") {
|
||||
writeTemp(*tempIo, "%%LanguageLevel: 2" + lineEnding);
|
||||
writeTemp(tempIo, "%%LanguageLevel: 2" + lineEnding);
|
||||
skipPos = posLineEnd;
|
||||
#ifdef DEBUG
|
||||
EXV_DEBUG << "readWriteEpsMetadata: Skipping to " << skipPos << " at " << __FILE__ << ":" << __LINE__ << "\n";
|
||||
@@ -879,7 +878,7 @@ namespace {
|
||||
}
|
||||
if (pos == posContainsXmp && posContainsXmp != posEndEps) {
|
||||
if (line != containsXmpLine) {
|
||||
writeTemp(*tempIo, containsXmpLine + lineEnding);
|
||||
writeTemp(tempIo, containsXmpLine + lineEnding);
|
||||
skipPos = posLineEnd;
|
||||
#ifdef DEBUG
|
||||
EXV_DEBUG << "readWriteEpsMetadata: Skipping to " << skipPos << " at " << __FILE__ << ":" << __LINE__ << "\n";
|
||||
@@ -887,14 +886,14 @@ namespace {
|
||||
}
|
||||
}
|
||||
if (pos == posExiv2Version && posExiv2Version != posEndEps) {
|
||||
writeTemp(*tempIo, "%Exiv2Version: " + versionNumberHexString() + lineEnding);
|
||||
writeTemp(tempIo, "%Exiv2Version: " + versionNumberHexString() + lineEnding);
|
||||
skipPos = posLineEnd;
|
||||
#ifdef DEBUG
|
||||
EXV_DEBUG << "readWriteEpsMetadata: Skipping to " << skipPos << " at " << __FILE__ << ":" << __LINE__ << "\n";
|
||||
#endif
|
||||
}
|
||||
if (pos == posExiv2Website && posExiv2Website != posEndEps) {
|
||||
writeTemp(*tempIo, "%Exiv2Website: http://www.exiv2.org/" + lineEnding);
|
||||
writeTemp(tempIo, "%Exiv2Website: http://www.exiv2.org/" + lineEnding);
|
||||
skipPos = posLineEnd;
|
||||
#ifdef DEBUG
|
||||
EXV_DEBUG << "readWriteEpsMetadata: Skipping to " << skipPos << " at " << __FILE__ << ":" << __LINE__ << "\n";
|
||||
@@ -902,43 +901,43 @@ namespace {
|
||||
}
|
||||
if (pos == posEndComments) {
|
||||
if (posLanguageLevel == posEndEps && !deleteXmp && !useFlexibleEmbedding) {
|
||||
writeTemp(*tempIo, "%%LanguageLevel: 2" + lineEnding);
|
||||
writeTemp(tempIo, "%%LanguageLevel: 2" + lineEnding);
|
||||
}
|
||||
if (posContainsXmp == posEndEps) {
|
||||
writeTemp(*tempIo, containsXmpLine + lineEnding);
|
||||
writeTemp(tempIo, containsXmpLine + lineEnding);
|
||||
}
|
||||
if (posPages == posEndEps) {
|
||||
writeTemp(*tempIo, "%%Pages: 1" + lineEnding);
|
||||
writeTemp(tempIo, "%%Pages: 1" + lineEnding);
|
||||
}
|
||||
if (posExiv2Version == posEndEps) {
|
||||
writeTemp(*tempIo, "%Exiv2Version: " + versionNumberHexString() + lineEnding);
|
||||
writeTemp(tempIo, "%Exiv2Version: " + versionNumberHexString() + lineEnding);
|
||||
}
|
||||
if (posExiv2Website == posEndEps) {
|
||||
writeTemp(*tempIo, "%Exiv2Website: http://www.exiv2.org/" + lineEnding);
|
||||
writeTemp(tempIo, "%Exiv2Website: http://www.exiv2.org/" + lineEnding);
|
||||
}
|
||||
readLine(line, data, posEndComments, posEndEps);
|
||||
if (line != "%%EndComments") {
|
||||
writeTemp(*tempIo, "%%EndComments" + lineEnding);
|
||||
writeTemp(tempIo, "%%EndComments" + lineEnding);
|
||||
}
|
||||
}
|
||||
if (pos == posPage) {
|
||||
if (!startsWith(line, "%%Page:")) {
|
||||
writeTemp(*tempIo, "%%Page: 1 1" + lineEnding);
|
||||
writeTemp(*tempIo, "%%EndPageComments" + lineEnding);
|
||||
writeTemp(tempIo, "%%Page: 1 1" + lineEnding);
|
||||
writeTemp(tempIo, "%%EndPageComments" + lineEnding);
|
||||
}
|
||||
}
|
||||
if (pos == posBeginPageSetup) {
|
||||
if (line != "%%BeginPageSetup") {
|
||||
writeTemp(*tempIo, "%%BeginPageSetup" + lineEnding);
|
||||
writeTemp(tempIo, "%%BeginPageSetup" + lineEnding);
|
||||
}
|
||||
}
|
||||
if (useFlexibleEmbedding) {
|
||||
// insert XMP metadata into existing flexible embedding
|
||||
if (pos == xmpPos) {
|
||||
if (fixBeginXmlPacket) {
|
||||
writeTemp(*tempIo, "%begin_xml_packet: " + toString(xmpPacket.size()) + lineEnding);
|
||||
writeTemp(tempIo, "%begin_xml_packet: " + toString(xmpPacket.size()) + lineEnding);
|
||||
}
|
||||
writeTemp(*tempIo, xmpPacket);
|
||||
writeTemp(tempIo, xmpPacket);
|
||||
skipPos += xmpSize;
|
||||
#ifdef DEBUG
|
||||
EXV_DEBUG << "readWriteEpsMetadata: Skipping to " << skipPos << " at " << __FILE__ << ":" << __LINE__ << "\n";
|
||||
@@ -958,52 +957,52 @@ namespace {
|
||||
}
|
||||
// insert XMP metadata with new flexible embedding, if necessary
|
||||
if (pos == posEndPageSetup && !deleteXmp) {
|
||||
writeTemp(*tempIo, "%Exiv2BeginXMP: Before %%EndPageSetup" + lineEnding);
|
||||
writeTemp(tempIo, "%Exiv2BeginXMP: Before %%EndPageSetup" + lineEnding);
|
||||
if (corelDraw) {
|
||||
writeTemp(*tempIo, "%Exiv2Notice: The following line is needed by CorelDRAW." + lineEnding);
|
||||
writeTemp(*tempIo, "@rs" + lineEnding);
|
||||
writeTemp(tempIo, "%Exiv2Notice: The following line is needed by CorelDRAW." + lineEnding);
|
||||
writeTemp(tempIo, "@rs" + lineEnding);
|
||||
}
|
||||
if (posBeginPhotoshop != posEndEps) {
|
||||
writeTemp(*tempIo, "%Exiv2Notice: The following line is needed by Photoshop." + lineEnding);
|
||||
writeTemp(*tempIo, "%begin_xml_code" + lineEnding);
|
||||
writeTemp(tempIo, "%Exiv2Notice: The following line is needed by Photoshop." + lineEnding);
|
||||
writeTemp(tempIo, "%begin_xml_code" + lineEnding);
|
||||
}
|
||||
writeTemp(*tempIo, "/currentdistillerparams where" + lineEnding);
|
||||
writeTemp(*tempIo, "{pop currentdistillerparams /CoreDistVersion get 5000 lt} {true} ifelse" + lineEnding);
|
||||
writeTemp(*tempIo, "{userdict /Exiv2_pdfmark /cleartomark load put" + lineEnding);
|
||||
writeTemp(*tempIo, " userdict /Exiv2_metafile_pdfmark {flushfile cleartomark} bind put}" + lineEnding);
|
||||
writeTemp(*tempIo, "{userdict /Exiv2_pdfmark /pdfmark load put" + lineEnding);
|
||||
writeTemp(*tempIo, " userdict /Exiv2_metafile_pdfmark {/PUT pdfmark} bind put} ifelse" + lineEnding);
|
||||
writeTemp(*tempIo, "[/NamespacePush Exiv2_pdfmark" + lineEnding);
|
||||
writeTemp(*tempIo, "[/_objdef {Exiv2_metadata_stream} /type /stream /OBJ Exiv2_pdfmark" + lineEnding);
|
||||
writeTemp(*tempIo, "[{Exiv2_metadata_stream} 2 dict begin" + lineEnding);
|
||||
writeTemp(*tempIo, " /Type /Metadata def /Subtype /XML def currentdict end /PUT Exiv2_pdfmark" + lineEnding);
|
||||
writeTemp(*tempIo, "[{Exiv2_metadata_stream}" + lineEnding);
|
||||
writeTemp(*tempIo, " currentfile 0 (% &&end XMP packet marker&&)" + lineEnding);
|
||||
writeTemp(*tempIo, " /SubFileDecode filter Exiv2_metafile_pdfmark" + lineEnding);
|
||||
writeTemp(tempIo, "/currentdistillerparams where" + lineEnding);
|
||||
writeTemp(tempIo, "{pop currentdistillerparams /CoreDistVersion get 5000 lt} {true} ifelse" + lineEnding);
|
||||
writeTemp(tempIo, "{userdict /Exiv2_pdfmark /cleartomark load put" + lineEnding);
|
||||
writeTemp(tempIo, " userdict /Exiv2_metafile_pdfmark {flushfile cleartomark} bind put}" + lineEnding);
|
||||
writeTemp(tempIo, "{userdict /Exiv2_pdfmark /pdfmark load put" + lineEnding);
|
||||
writeTemp(tempIo, " userdict /Exiv2_metafile_pdfmark {/PUT pdfmark} bind put} ifelse" + lineEnding);
|
||||
writeTemp(tempIo, "[/NamespacePush Exiv2_pdfmark" + lineEnding);
|
||||
writeTemp(tempIo, "[/_objdef {Exiv2_metadata_stream} /type /stream /OBJ Exiv2_pdfmark" + lineEnding);
|
||||
writeTemp(tempIo, "[{Exiv2_metadata_stream} 2 dict begin" + lineEnding);
|
||||
writeTemp(tempIo, " /Type /Metadata def /Subtype /XML def currentdict end /PUT Exiv2_pdfmark" + lineEnding);
|
||||
writeTemp(tempIo, "[{Exiv2_metadata_stream}" + lineEnding);
|
||||
writeTemp(tempIo, " currentfile 0 (% &&end XMP packet marker&&)" + lineEnding);
|
||||
writeTemp(tempIo, " /SubFileDecode filter Exiv2_metafile_pdfmark" + lineEnding);
|
||||
if (posBeginPhotoshop != posEndEps) {
|
||||
writeTemp(*tempIo, "%Exiv2Notice: The following line is needed by Photoshop. "
|
||||
writeTemp(tempIo, "%Exiv2Notice: The following line is needed by Photoshop. "
|
||||
"Parameter must be exact size of XMP metadata." + lineEnding);
|
||||
writeTemp(*tempIo, "%begin_xml_packet: " + toString(xmpPacket.size()) + lineEnding);
|
||||
writeTemp(tempIo, "%begin_xml_packet: " + toString(xmpPacket.size()) + lineEnding);
|
||||
}
|
||||
writeTemp(*tempIo, xmpPacket);
|
||||
writeTemp(*tempIo, lineEnding);
|
||||
writeTemp(*tempIo, "% &&end XMP packet marker&&" + lineEnding);
|
||||
writeTemp(*tempIo, "[/Document 1 dict begin" + lineEnding);
|
||||
writeTemp(*tempIo, " /Metadata {Exiv2_metadata_stream} def currentdict end /BDC Exiv2_pdfmark" + lineEnding);
|
||||
writeTemp(tempIo, xmpPacket);
|
||||
writeTemp(tempIo, lineEnding);
|
||||
writeTemp(tempIo, "% &&end XMP packet marker&&" + lineEnding);
|
||||
writeTemp(tempIo, "[/Document 1 dict begin" + lineEnding);
|
||||
writeTemp(tempIo, " /Metadata {Exiv2_metadata_stream} def currentdict end /BDC Exiv2_pdfmark" + lineEnding);
|
||||
if (posBeginPhotoshop != posEndEps) {
|
||||
writeTemp(*tempIo, "%Exiv2Notice: The following line is needed by Photoshop." + lineEnding);
|
||||
writeTemp(*tempIo, "%end_xml_code" + lineEnding);
|
||||
writeTemp(tempIo, "%Exiv2Notice: The following line is needed by Photoshop." + lineEnding);
|
||||
writeTemp(tempIo, "%end_xml_code" + lineEnding);
|
||||
}
|
||||
if (corelDraw) {
|
||||
writeTemp(*tempIo, "%Exiv2Notice: The following line is needed by CorelDRAW." + lineEnding);
|
||||
writeTemp(*tempIo, "@sv" + lineEnding);
|
||||
writeTemp(tempIo, "%Exiv2Notice: The following line is needed by CorelDRAW." + lineEnding);
|
||||
writeTemp(tempIo, "@sv" + lineEnding);
|
||||
}
|
||||
writeTemp(*tempIo, "%Exiv2EndXMP" + lineEnding);
|
||||
writeTemp(tempIo, "%Exiv2EndXMP" + lineEnding);
|
||||
}
|
||||
}
|
||||
if (pos == posEndPageSetup) {
|
||||
if (line != "%%EndPageSetup") {
|
||||
writeTemp(*tempIo, "%%EndPageSetup" + lineEnding);
|
||||
writeTemp(tempIo, "%%EndPageSetup" + lineEnding);
|
||||
}
|
||||
}
|
||||
if (!useFlexibleEmbedding) {
|
||||
@@ -1014,33 +1013,33 @@ namespace {
|
||||
EXV_DEBUG << "readWriteEpsMetadata: Skipping to " << skipPos << " at " << __FILE__ << ":" << __LINE__ << "\n";
|
||||
#endif
|
||||
}
|
||||
writeTemp(*tempIo, "%%PageTrailer" + lineEnding);
|
||||
writeTemp(*tempIo, "%Exiv2BeginXMP: After %%PageTrailer" + lineEnding);
|
||||
writeTemp(*tempIo, "[/EMC Exiv2_pdfmark" + lineEnding);
|
||||
writeTemp(*tempIo, "[/NamespacePop Exiv2_pdfmark" + lineEnding);
|
||||
writeTemp(*tempIo, "%Exiv2EndXMP" + lineEnding);
|
||||
writeTemp(tempIo, "%%PageTrailer" + lineEnding);
|
||||
writeTemp(tempIo, "%Exiv2BeginXMP: After %%PageTrailer" + lineEnding);
|
||||
writeTemp(tempIo, "[/EMC Exiv2_pdfmark" + lineEnding);
|
||||
writeTemp(tempIo, "[/NamespacePop Exiv2_pdfmark" + lineEnding);
|
||||
writeTemp(tempIo, "%Exiv2EndXMP" + lineEnding);
|
||||
}
|
||||
}
|
||||
// add EOF comment if necessary
|
||||
if (pos == posEndEps && posEof == posEndEps) {
|
||||
writeTemp(*tempIo, "%%EOF" + lineEnding);
|
||||
writeTemp(tempIo, "%%EOF" + lineEnding);
|
||||
}
|
||||
prevPos = pos;
|
||||
prevSkipPos = skipPos;
|
||||
}
|
||||
const uint32_t posEndEpsNew = posTemp(*tempIo);
|
||||
const uint32_t posEndEpsNew = posTemp(tempIo);
|
||||
#ifdef DEBUG
|
||||
EXV_DEBUG << "readWriteEpsMetadata: New EPS size: " << (posEndEpsNew - posEpsNew) << "\n";
|
||||
#endif
|
||||
if (dosEps) {
|
||||
// write WMF and/or TIFF section if present
|
||||
writeTemp(*tempIo, data + posWmf, sizeWmf);
|
||||
writeTemp(*tempIo, data + posTiff, sizeTiff);
|
||||
writeTemp(tempIo, data + posWmf, sizeWmf);
|
||||
writeTemp(tempIo, data + posTiff, sizeTiff);
|
||||
#ifdef DEBUG
|
||||
EXV_DEBUG << "readWriteEpsMetadata: New DOS EPS total size: " << posTemp(*tempIo) << "\n";
|
||||
EXV_DEBUG << "readWriteEpsMetadata: New DOS EPS total size: " << posTemp(tempIo) << "\n";
|
||||
#endif
|
||||
// write DOS EPS header
|
||||
if (tempIo->seek(0, BasicIo::beg) != 0) {
|
||||
if (tempIo.seek(0, BasicIo::beg) != 0) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
EXV_WARNING << "Internal error while seeking in temporary file.\n";
|
||||
#endif
|
||||
@@ -1055,12 +1054,12 @@ namespace {
|
||||
ul2Data(dosEpsHeader + 20, sizeTiff == 0 ? 0 : posEndEpsNew + sizeWmf, littleEndian);
|
||||
ul2Data(dosEpsHeader + 24, sizeTiff, littleEndian);
|
||||
us2Data(dosEpsHeader + 28, 0xFFFF, littleEndian);
|
||||
writeTemp(*tempIo, dosEpsHeader, sizeof(dosEpsHeader));
|
||||
writeTemp(tempIo, dosEpsHeader, sizeof(dosEpsHeader));
|
||||
}
|
||||
|
||||
// copy temporary file to real output file
|
||||
io.close();
|
||||
io.transfer(*tempIo);
|
||||
io.transfer(tempIo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1149,7 +1148,7 @@ namespace Exiv2
|
||||
// free functions
|
||||
Image::UniquePtr newEpsInstance(BasicIo::UniquePtr io, bool create)
|
||||
{
|
||||
Image::UniquePtr image(new EpsImage(std::move(io), create));
|
||||
auto image = std::make_unique<EpsImage>(std::move(io), create);
|
||||
if (!image->good()) {
|
||||
image.reset();
|
||||
}
|
||||
|
||||
+24
-18
@@ -455,28 +455,32 @@ namespace Exiv2 {
|
||||
|
||||
DataBuf ExifThumbC::copy() const
|
||||
{
|
||||
Thumbnail::UniquePtr thumbnail = Thumbnail::create(exifData_);
|
||||
if (thumbnail.get() == nullptr)
|
||||
auto thumbnail = Thumbnail::create(exifData_);
|
||||
if (!thumbnail)
|
||||
return DataBuf();
|
||||
return thumbnail->copy(exifData_);
|
||||
}
|
||||
|
||||
long ExifThumbC::writeFile(const std::string& path) const
|
||||
{
|
||||
Thumbnail::UniquePtr thumbnail = Thumbnail::create(exifData_);
|
||||
if (thumbnail.get() == nullptr)
|
||||
auto thumbnail = Thumbnail::create(exifData_);
|
||||
if (!thumbnail.get())
|
||||
return 0;
|
||||
|
||||
std::string name = path + thumbnail->extension();
|
||||
DataBuf buf(thumbnail->copy(exifData_));
|
||||
if (buf.size() == 0) return 0;
|
||||
if (buf.size() == 0)
|
||||
return 0;
|
||||
|
||||
return Exiv2::writeFile(buf, name);
|
||||
}
|
||||
|
||||
#ifdef EXV_UNICODE_PATH
|
||||
long ExifThumbC::writeFile(const std::wstring& wpath) const
|
||||
{
|
||||
Thumbnail::UniquePtr thumbnail = Thumbnail::create(exifData_);
|
||||
if (thumbnail.get() == 0) return 0;
|
||||
auto thumbnail = Thumbnail::create(exifData_);
|
||||
if (!thumbnail)
|
||||
return 0;
|
||||
std::wstring name = wpath + thumbnail->wextension();
|
||||
DataBuf buf(thumbnail->copy(exifData_));
|
||||
if (buf.size() == 0) return 0;
|
||||
@@ -486,16 +490,16 @@ namespace Exiv2 {
|
||||
#endif
|
||||
const char* ExifThumbC::mimeType() const
|
||||
{
|
||||
Thumbnail::UniquePtr thumbnail = Thumbnail::create(exifData_);
|
||||
if (thumbnail.get() == nullptr)
|
||||
auto thumbnail = Thumbnail::create(exifData_);
|
||||
if (!thumbnail.get())
|
||||
return "";
|
||||
return thumbnail->mimeType();
|
||||
}
|
||||
|
||||
const char* ExifThumbC::extension() const
|
||||
{
|
||||
Thumbnail::UniquePtr thumbnail = Thumbnail::create(exifData_);
|
||||
if (thumbnail.get() == nullptr)
|
||||
auto thumbnail = Thumbnail::create(exifData_);
|
||||
if (!thumbnail)
|
||||
return "";
|
||||
return thumbnail->extension();
|
||||
}
|
||||
@@ -503,8 +507,9 @@ namespace Exiv2 {
|
||||
#ifdef EXV_UNICODE_PATH
|
||||
const wchar_t* ExifThumbC::wextension() const
|
||||
{
|
||||
Thumbnail::UniquePtr thumbnail = Thumbnail::create(exifData_);
|
||||
if (thumbnail.get() == 0) return EXV_WIDEN("");
|
||||
auto thumbnail = Thumbnail::create(exifData_);
|
||||
if (!thumbnail)
|
||||
return EXV_WIDEN("");
|
||||
return thumbnail->wextension();
|
||||
}
|
||||
|
||||
@@ -870,24 +875,25 @@ namespace {
|
||||
//! @cond IGNORE
|
||||
Thumbnail::UniquePtr Thumbnail::create(const Exiv2::ExifData& exifData)
|
||||
{
|
||||
Thumbnail::UniquePtr thumbnail;
|
||||
std::unique_ptr<Thumbnail> thumbnail;
|
||||
const Exiv2::ExifKey k1("Exif.Thumbnail.Compression");
|
||||
auto pos = exifData.findKey(k1);
|
||||
if (pos != exifData.end()) {
|
||||
if (pos->count() == 0) return thumbnail;
|
||||
if (pos->count() == 0)
|
||||
return thumbnail;
|
||||
long compression = pos->toLong();
|
||||
if (compression == 6) {
|
||||
thumbnail = Thumbnail::UniquePtr(new JpegThumbnail);
|
||||
thumbnail = std::make_unique<JpegThumbnail>();
|
||||
}
|
||||
else {
|
||||
thumbnail = Thumbnail::UniquePtr(new TiffThumbnail);
|
||||
thumbnail = std::make_unique<TiffThumbnail>();
|
||||
}
|
||||
}
|
||||
else {
|
||||
const Exiv2::ExifKey k2("Exif.Thumbnail.JPEGInterchangeFormat");
|
||||
pos = exifData.findKey(k2);
|
||||
if (pos != exifData.end()) {
|
||||
thumbnail = Thumbnail::UniquePtr(new JpegThumbnail);
|
||||
thumbnail = std::make_unique<JpegThumbnail>();
|
||||
}
|
||||
}
|
||||
return thumbnail;
|
||||
|
||||
+2
-2
@@ -153,8 +153,8 @@ int main(int argc, char* const argv[])
|
||||
try {
|
||||
// Create the required action class
|
||||
Action::TaskFactory& taskFactory = Action::TaskFactory::instance();
|
||||
Action::Task::UniquePtr task = taskFactory.create(Action::TaskType(params.action_));
|
||||
assert(task.get());
|
||||
auto task = taskFactory.create(Action::TaskType(params.action_));
|
||||
assert(task);
|
||||
|
||||
// Process all files
|
||||
int n = 1;
|
||||
|
||||
+1
-1
@@ -100,7 +100,7 @@ namespace Exiv2 {
|
||||
// free functions
|
||||
Image::UniquePtr newGifInstance(BasicIo::UniquePtr io, bool /*create*/)
|
||||
{
|
||||
Image::UniquePtr image(new GifImage(std::move(io)));
|
||||
auto image = std::make_unique<GifImage>(std::move(io));
|
||||
if (!image->good())
|
||||
{
|
||||
image.reset();
|
||||
|
||||
+41
-35
@@ -850,18 +850,18 @@ namespace Exiv2 {
|
||||
|
||||
#ifdef EXV_USE_CURL
|
||||
if (useCurl && (fProt == pHttp || fProt == pHttps || fProt == pFtp)) {
|
||||
return BasicIo::UniquePtr(new CurlIo(path)); // may throw
|
||||
return std::make_unique<CurlIo>(path); // may throw
|
||||
}
|
||||
#endif
|
||||
|
||||
if (fProt == pHttp)
|
||||
return BasicIo::UniquePtr(new HttpIo(path)); // may throw
|
||||
return std::make_unique<HttpIo>(path); // may throw
|
||||
if (fProt == pFileUri)
|
||||
return BasicIo::UniquePtr(new FileIo(pathOfFileUrl(path)));
|
||||
return std::make_unique<FileIo>(pathOfFileUrl(path));
|
||||
if (fProt == pStdin || fProt == pDataUri)
|
||||
return BasicIo::UniquePtr(new XPathIo(path)); // may throw
|
||||
return std::make_unique<XPathIo>(path); // may throw
|
||||
|
||||
return BasicIo::UniquePtr(new FileIo(path));
|
||||
return std::make_unique<FileIo>(path);
|
||||
|
||||
(void)(useCurl);
|
||||
} // ImageFactory::createIo
|
||||
@@ -872,39 +872,42 @@ namespace Exiv2 {
|
||||
Protocol fProt = fileProtocol(wpath);
|
||||
#ifdef EXV_USE_CURL
|
||||
if (useCurl && (fProt == pHttp || fProt == pHttps || fProt == pFtp)) {
|
||||
return BasicIo::UniquePtr(new CurlIo(wpath));
|
||||
return std::make_unique<CurlIo>(wpath);
|
||||
}
|
||||
#endif
|
||||
if (fProt == pHttp)
|
||||
return BasicIo::UniquePtr(new HttpIo(wpath));
|
||||
return std::make_unique<HttpIo>(wpath);
|
||||
if (fProt == pFileUri)
|
||||
return BasicIo::UniquePtr(new FileIo(pathOfFileUrl(wpath)));
|
||||
return std::make_unique<FileIo>(pathOfFileUrl(wpath));
|
||||
if (fProt == pStdin || fProt == pDataUri)
|
||||
return BasicIo::UniquePtr(new XPathIo(wpath)); // may throw
|
||||
return BasicIo::UniquePtr(new FileIo(wpath));
|
||||
} // ImageFactory::createIo
|
||||
return std::make_unique<XPathIo>(wpath); // may throw
|
||||
return std::make_unique<FileIo>(wpath);
|
||||
}
|
||||
#endif
|
||||
Image::UniquePtr ImageFactory::open(const std::string& path, bool useCurl)
|
||||
{
|
||||
Image::UniquePtr image = open(ImageFactory::createIo(path, useCurl)); // may throw
|
||||
if (image.get() == nullptr) throw Error(kerFileContainsUnknownImageType, path);
|
||||
auto image = open(ImageFactory::createIo(path, useCurl)); // may throw
|
||||
if (!image)
|
||||
throw Error(kerFileContainsUnknownImageType, path);
|
||||
return image;
|
||||
}
|
||||
|
||||
#ifdef EXV_UNICODE_PATH
|
||||
Image::UniquePtr ImageFactory::open(const std::wstring& wpath, bool useCurl)
|
||||
{
|
||||
Image::UniquePtr image = open(ImageFactory::createIo(wpath, useCurl)); // may throw
|
||||
if (image.get() == 0) throw WError(kerFileContainsUnknownImageType, wpath);
|
||||
auto image = open(ImageFactory::createIo(wpath, useCurl)); // may throw
|
||||
if (!image)
|
||||
throw WError(kerFileContainsUnknownImageType, wpath);
|
||||
return image;
|
||||
}
|
||||
|
||||
#endif
|
||||
Image::UniquePtr ImageFactory::open(const byte* data, long size)
|
||||
{
|
||||
BasicIo::UniquePtr io(new MemIo(data, size));
|
||||
Image::UniquePtr image = open(std::move(io)); // may throw
|
||||
if (image.get() == nullptr) throw Error(kerMemoryContainsUnknownImageType);
|
||||
auto io = std::make_unique<MemIo>(data, size);
|
||||
auto image = open(std::move(io)); // may throw
|
||||
if (!image)
|
||||
throw Error(kerMemoryContainsUnknownImageType);
|
||||
return image;
|
||||
}
|
||||
|
||||
@@ -918,21 +921,22 @@ namespace Exiv2 {
|
||||
return registry[i].newInstance_(std::move(io), false);
|
||||
}
|
||||
}
|
||||
return Image::UniquePtr();
|
||||
} // ImageFactory::open
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Image::UniquePtr ImageFactory::create(int type,
|
||||
const std::string& path)
|
||||
Image::UniquePtr ImageFactory::create(int type, const std::string& path)
|
||||
{
|
||||
std::unique_ptr<FileIo> fileIo(new FileIo(path));
|
||||
auto fileIo = std::make_unique<FileIo>(path);
|
||||
// Create or overwrite the file, then close it
|
||||
if (fileIo->open("w+b") != 0) {
|
||||
throw Error(kerFileOpenFailed, path, "w+b", strError());
|
||||
}
|
||||
fileIo->close();
|
||||
|
||||
BasicIo::UniquePtr io(std::move(fileIo));
|
||||
Image::UniquePtr image = create(type, std::move(io));
|
||||
if (image.get() == nullptr) throw Error(kerUnsupportedImageType, type);
|
||||
auto image = create(type, std::move(io));
|
||||
if (!image)
|
||||
throw Error(kerUnsupportedImageType, type);
|
||||
return image;
|
||||
}
|
||||
|
||||
@@ -940,37 +944,39 @@ namespace Exiv2 {
|
||||
Image::UniquePtr ImageFactory::create(int type,
|
||||
const std::wstring& wpath)
|
||||
{
|
||||
std::unique_ptr<FileIo> fileIo(new FileIo(wpath));
|
||||
auto fileIo = std::make_unique<FileIo>(wpath);
|
||||
// Create or overwrite the file, then close it
|
||||
if (fileIo->open("w+b") != 0) {
|
||||
throw WError(kerFileOpenFailed, wpath, "w+b", strError().c_str());
|
||||
}
|
||||
fileIo->close();
|
||||
|
||||
BasicIo::UniquePtr io(std::move(fileIo));
|
||||
Image::UniquePtr image = create(type, std::move(io));
|
||||
if (image.get() == 0) throw Error(kerUnsupportedImageType, type);
|
||||
auto image = create(type, std::move(io));
|
||||
if (!image)
|
||||
throw Error(kerUnsupportedImageType, type);
|
||||
return image;
|
||||
}
|
||||
|
||||
#endif
|
||||
Image::UniquePtr ImageFactory::create(int type)
|
||||
{
|
||||
BasicIo::UniquePtr io(new MemIo);
|
||||
Image::UniquePtr image = create(type, std::move(io));
|
||||
if (image.get() == nullptr) throw Error(kerUnsupportedImageType, type);
|
||||
auto io = std::make_unique<MemIo>();
|
||||
auto image = create(type, std::move(io));
|
||||
if (!image)
|
||||
throw Error(kerUnsupportedImageType, type);
|
||||
return image;
|
||||
}
|
||||
|
||||
Image::UniquePtr ImageFactory::create(int type,
|
||||
BasicIo::UniquePtr io)
|
||||
Image::UniquePtr ImageFactory::create(int type, BasicIo::UniquePtr io)
|
||||
{
|
||||
// BasicIo instance does not need to be open
|
||||
const Registry* r = find(registry, type);
|
||||
if (nullptr != r) {
|
||||
return r->newInstance_(std::move(io), true);
|
||||
}
|
||||
return Image::UniquePtr();
|
||||
} // ImageFactory::create
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// template, inline and free functions
|
||||
|
||||
+2
-3
@@ -226,7 +226,7 @@ namespace Exiv2 {
|
||||
|
||||
Iptcdatum& Iptcdatum::operator=(const uint16_t& value)
|
||||
{
|
||||
UShortValue::UniquePtr v(new UShortValue);
|
||||
auto v = std::make_unique<UShortValue>();
|
||||
v->value_.push_back(value);
|
||||
value_ = std::move(v);
|
||||
return *this;
|
||||
@@ -553,9 +553,8 @@ namespace {
|
||||
uint32_t sizeData
|
||||
)
|
||||
{
|
||||
Exiv2::Value::UniquePtr value;
|
||||
Exiv2::TypeId type = Exiv2::IptcDataSets::dataSetType(dataSet, record);
|
||||
value = Exiv2::Value::create(type);
|
||||
auto value = Exiv2::Value::create(type);
|
||||
int rc = value->read(data, sizeData, Exiv2::bigEndian);
|
||||
if (0 == rc) {
|
||||
Exiv2::IptcKey key(dataSet, record);
|
||||
|
||||
+4
-5
@@ -602,8 +602,8 @@ static void boxes_check(size_t b,size_t m)
|
||||
const char a = rawData.read_uint8(0);
|
||||
const char b = rawData.read_uint8(1);
|
||||
if (a == b && (a == 'I' || a == 'M')) {
|
||||
BasicIo::UniquePtr p = BasicIo::UniquePtr(new MemIo(rawData.c_data(), rawData.size()));
|
||||
printTiffStructure(*p, out, option, depth);
|
||||
MemIo p (rawData.c_data(), rawData.size());
|
||||
printTiffStructure(p, out, option, depth);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -638,8 +638,7 @@ static void boxes_check(size_t b,size_t m)
|
||||
throw Error(kerDataSourceOpenFailed, io_->path(), strError());
|
||||
}
|
||||
IoCloser closer(*io_);
|
||||
BasicIo::UniquePtr tempIo(new MemIo);
|
||||
assert (tempIo.get() != 0);
|
||||
auto tempIo = std::make_unique<MemIo>();
|
||||
|
||||
doWriteMetadata(*tempIo); // may throw
|
||||
io_->close();
|
||||
@@ -967,7 +966,7 @@ static void boxes_check(size_t b,size_t m)
|
||||
// free functions
|
||||
Image::UniquePtr newJp2Instance(BasicIo::UniquePtr io, bool create)
|
||||
{
|
||||
Image::UniquePtr image(new Jp2Image(std::move(io), create));
|
||||
auto image = std::make_unique<Jp2Image>(std::move(io), create);
|
||||
if (!image->good())
|
||||
{
|
||||
image.reset();
|
||||
|
||||
+10
-11
@@ -744,10 +744,11 @@ namespace Exiv2 {
|
||||
if (bPS) {
|
||||
IptcData::printStructure(out, makeSlice(buf, 0, size), depth);
|
||||
} else {
|
||||
// create a copy on write memio object with the data, then print the structure
|
||||
BasicIo::UniquePtr p = BasicIo::UniquePtr(new MemIo(buf.c_data(start), size - start));
|
||||
if (start < max)
|
||||
printTiffStructure(*p, out, option, depth);
|
||||
if (start < max) {
|
||||
// create a copy on write memio object with the data, then print the structure
|
||||
MemIo p (buf.c_data(start), size - start);
|
||||
printTiffStructure(p, out, option, depth);
|
||||
}
|
||||
}
|
||||
|
||||
// restore and clean up
|
||||
@@ -817,9 +818,7 @@ namespace Exiv2 {
|
||||
// exiv2 -pS E.jpg
|
||||
|
||||
// binary copy io_ to a temporary file
|
||||
BasicIo::UniquePtr tempIo(new MemIo);
|
||||
|
||||
assert(tempIo.get() != 0);
|
||||
auto tempIo = std::make_unique<MemIo>();
|
||||
for (size_t i = 0; i < (count / 2) + 1; i++) {
|
||||
long start = pos[2 * i] + 2; // step JPG 2 byte marker
|
||||
if (start == 2)
|
||||
@@ -1304,7 +1303,7 @@ namespace Exiv2 {
|
||||
|
||||
Image::UniquePtr newJpegInstance(BasicIo::UniquePtr io, bool create)
|
||||
{
|
||||
Image::UniquePtr image(new JpegImage(std::move(io), create));
|
||||
auto image = std::make_unique<JpegImage>(std::move(io), create);
|
||||
if (!image->good()) {
|
||||
image.reset();
|
||||
}
|
||||
@@ -1357,9 +1356,9 @@ namespace Exiv2 {
|
||||
|
||||
Image::UniquePtr newExvInstance(BasicIo::UniquePtr io, bool create)
|
||||
{
|
||||
Image::UniquePtr image;
|
||||
image = Image::UniquePtr(new ExvImage(std::move(io), create));
|
||||
if (!image->good()) image.reset();
|
||||
auto image = std::make_unique<ExvImage>(std::move(io), create);
|
||||
if (!image->good())
|
||||
image.reset();
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -155,7 +155,7 @@ namespace Exiv2 {
|
||||
// free functions
|
||||
Image::UniquePtr newMrwInstance(BasicIo::UniquePtr io, bool create)
|
||||
{
|
||||
Image::UniquePtr image(new MrwImage(std::move(io), create));
|
||||
auto image = std::make_unique<MrwImage>(std::move(io), create);
|
||||
if (!image->good()) {
|
||||
image.reset();
|
||||
}
|
||||
|
||||
+1
-1
@@ -192,7 +192,7 @@ namespace Exiv2 {
|
||||
// free functions
|
||||
Image::UniquePtr newOrfInstance(BasicIo::UniquePtr io, bool create)
|
||||
{
|
||||
Image::UniquePtr image(new OrfImage(std::move(io), create));
|
||||
auto image = std::make_unique<OrfImage>(std::move(io), create);
|
||||
if (!image->good()) {
|
||||
image.reset();
|
||||
}
|
||||
|
||||
+5
-7
@@ -143,13 +143,12 @@ namespace Exiv2 {
|
||||
if (io_->error()) throw Error(kerFailedToReadImageData);
|
||||
if (bufRead != imgData.size()) throw Error(kerInputDataReadFailed);
|
||||
|
||||
Image::UniquePtr image = Exiv2::ImageFactory::open(imgData.c_data(), imgData.size());
|
||||
auto image = Exiv2::ImageFactory::open(imgData.c_data(), imgData.size());
|
||||
image->readMetadata();
|
||||
exifData() = image->exifData();
|
||||
iptcData() = image->iptcData();
|
||||
xmpData() = image->xmpData();
|
||||
|
||||
} // PgfImage::readMetadata
|
||||
}
|
||||
|
||||
void PgfImage::writeMetadata()
|
||||
{
|
||||
@@ -158,8 +157,7 @@ namespace Exiv2 {
|
||||
throw Error(kerDataSourceOpenFailed, io_->path(), strError());
|
||||
}
|
||||
IoCloser closer(*io_);
|
||||
BasicIo::UniquePtr tempIo(new MemIo);
|
||||
assert (tempIo.get() != 0);
|
||||
auto tempIo = std::make_unique<MemIo>();
|
||||
|
||||
doWriteMetadata(*tempIo); // may throw
|
||||
io_->close();
|
||||
@@ -192,7 +190,7 @@ namespace Exiv2 {
|
||||
int w = 0, h = 0;
|
||||
DataBuf header = readPgfHeaderStructure(*io_, w, h);
|
||||
|
||||
Image::UniquePtr img = ImageFactory::create(ImageType::png);
|
||||
auto img = ImageFactory::create(ImageType::png);
|
||||
|
||||
img->setExifData(exifData_);
|
||||
img->setIptcData(iptcData_);
|
||||
@@ -316,7 +314,7 @@ namespace Exiv2 {
|
||||
// free functions
|
||||
Image::UniquePtr newPgfInstance(BasicIo::UniquePtr io, bool create)
|
||||
{
|
||||
Image::UniquePtr image(new PgfImage(std::move(io), create));
|
||||
auto image = std::make_unique<PgfImage>(std::move(io), create);
|
||||
if (!image->good())
|
||||
{
|
||||
image.reset();
|
||||
|
||||
+6
-7
@@ -362,8 +362,8 @@ namespace Exiv2 {
|
||||
if ( parsedBuf.size() ) {
|
||||
if ( bExif ) {
|
||||
// create memio object with the data, then print the structure
|
||||
BasicIo::UniquePtr p = BasicIo::UniquePtr(new MemIo(parsedBuf.c_data(6),parsedBuf.size()-6));
|
||||
printTiffStructure(*p,out,option,depth);
|
||||
MemIo p(parsedBuf.c_data(6),parsedBuf.size()-6);
|
||||
printTiffStructure(p,out,option,depth);
|
||||
}
|
||||
if ( bIptc ) {
|
||||
IptcData::printStructure(out, makeSlice(parsedBuf, 0, parsedBuf.size()), depth);
|
||||
@@ -392,8 +392,8 @@ namespace Exiv2 {
|
||||
}
|
||||
if ( eXIf && option == kpsRecursive ) {
|
||||
// create memio object with the data, then print the structure
|
||||
BasicIo::UniquePtr p = BasicIo::UniquePtr(new MemIo(data.c_data(), dataOffset));
|
||||
printTiffStructure(*p,out,option,depth);
|
||||
MemIo p(data.c_data(), dataOffset);
|
||||
printTiffStructure(p,out,option,depth);
|
||||
}
|
||||
|
||||
if ( bLF ) out << std::endl;
|
||||
@@ -529,8 +529,7 @@ namespace Exiv2 {
|
||||
throw Error(kerDataSourceOpenFailed, io_->path(), strError());
|
||||
}
|
||||
IoCloser closer(*io_);
|
||||
BasicIo::UniquePtr tempIo(new MemIo);
|
||||
assert (tempIo.get() != 0);
|
||||
auto tempIo = std::make_unique<MemIo>();
|
||||
|
||||
doWriteMetadata(*tempIo); // may throw
|
||||
io_->close();
|
||||
@@ -735,7 +734,7 @@ namespace Exiv2 {
|
||||
// free functions
|
||||
Image::UniquePtr newPngInstance(BasicIo::UniquePtr io, bool create)
|
||||
{
|
||||
Image::UniquePtr image(new PngImage(std::move(io), create));
|
||||
auto image = std::make_unique<PngImage>(std::move(io), create);
|
||||
if (!image->good())
|
||||
{
|
||||
image.reset();
|
||||
|
||||
+25
-21
@@ -376,15 +376,16 @@ namespace {
|
||||
Loader::UniquePtr Loader::create(PreviewId id, const Image &image)
|
||||
{
|
||||
if (id < 0 || id >= Loader::getNumLoaders())
|
||||
return UniquePtr();
|
||||
return nullptr;
|
||||
|
||||
if (loaderList_[id].imageMimeType_ &&
|
||||
std::string(loaderList_[id].imageMimeType_) != image.mimeType())
|
||||
return UniquePtr();
|
||||
if (loaderList_[id].imageMimeType_ && std::string(loaderList_[id].imageMimeType_) != image.mimeType())
|
||||
return nullptr;
|
||||
|
||||
UniquePtr loader = loaderList_[id].create_(id, image, loaderList_[id].parIdx_);
|
||||
auto loader = loaderList_[id].create_(id, image, loaderList_[id].parIdx_);
|
||||
|
||||
if (loader.get() && !loader->valid())
|
||||
loader.reset();
|
||||
|
||||
if (loader.get() && !loader->valid()) loader.reset();
|
||||
return loader;
|
||||
}
|
||||
|
||||
@@ -428,7 +429,7 @@ namespace {
|
||||
|
||||
Loader::UniquePtr createLoaderNative(PreviewId id, const Image &image, int parIdx)
|
||||
{
|
||||
return Loader::UniquePtr(new LoaderNative(id, image, parIdx));
|
||||
return std::make_unique<LoaderNative>(id, image, parIdx);
|
||||
}
|
||||
|
||||
PreviewProperties LoaderNative::getProperties() const
|
||||
@@ -503,8 +504,9 @@ namespace {
|
||||
const DataBuf data = getData();
|
||||
if (data.size() == 0) return false;
|
||||
try {
|
||||
Image::UniquePtr image = ImageFactory::open(data.c_data(), data.size());
|
||||
if (image.get() == nullptr) return false;
|
||||
auto image = ImageFactory::open(data.c_data(), data.size());
|
||||
if (!image)
|
||||
return false;
|
||||
image->readMetadata();
|
||||
|
||||
width_ = image->pixelWidth();
|
||||
@@ -549,7 +551,7 @@ namespace {
|
||||
|
||||
Loader::UniquePtr createLoaderExifJpeg(PreviewId id, const Image &image, int parIdx)
|
||||
{
|
||||
return Loader::UniquePtr(new LoaderExifJpeg(id, image, parIdx));
|
||||
return std::make_unique<LoaderExifJpeg>(id, image, parIdx);
|
||||
}
|
||||
|
||||
PreviewProperties LoaderExifJpeg::getProperties() const
|
||||
@@ -592,8 +594,9 @@ namespace {
|
||||
const Exiv2::byte* base = io.mmap();
|
||||
|
||||
try {
|
||||
Image::UniquePtr image = ImageFactory::open(base + offset_, size_);
|
||||
if (image.get() == nullptr) return false;
|
||||
auto image = ImageFactory::open(base + offset_, size_);
|
||||
if (!image)
|
||||
return false;
|
||||
image->readMetadata();
|
||||
|
||||
width_ = image->pixelWidth();
|
||||
@@ -627,7 +630,7 @@ namespace {
|
||||
|
||||
Loader::UniquePtr createLoaderExifDataJpeg(PreviewId id, const Image &image, int parIdx)
|
||||
{
|
||||
return Loader::UniquePtr(new LoaderExifDataJpeg(id, image, parIdx));
|
||||
return std::make_unique<LoaderExifDataJpeg>(id, image, parIdx);
|
||||
}
|
||||
|
||||
PreviewProperties LoaderExifDataJpeg::getProperties() const
|
||||
@@ -669,8 +672,9 @@ namespace {
|
||||
if (buf.size() == 0) return false;
|
||||
|
||||
try {
|
||||
Image::UniquePtr image = ImageFactory::open(buf.c_data(), buf.size());
|
||||
if (image.get() == nullptr) return false;
|
||||
auto image = ImageFactory::open(buf.c_data(), buf.size());
|
||||
if (!image)
|
||||
return false;
|
||||
image->readMetadata();
|
||||
|
||||
width_ = image->pixelWidth();
|
||||
@@ -739,7 +743,7 @@ namespace {
|
||||
|
||||
Loader::UniquePtr createLoaderTiff(PreviewId id, const Image &image, int parIdx)
|
||||
{
|
||||
return Loader::UniquePtr(new LoaderTiff(id, image, parIdx));
|
||||
return std::make_unique<LoaderTiff>(id, image, parIdx);
|
||||
}
|
||||
|
||||
PreviewProperties LoaderTiff::getProperties() const
|
||||
@@ -869,7 +873,7 @@ namespace {
|
||||
|
||||
Loader::UniquePtr createLoaderXmpJpeg(PreviewId id, const Image &image, int parIdx)
|
||||
{
|
||||
return Loader::UniquePtr(new LoaderXmpJpeg(id, image, parIdx));
|
||||
return std::make_unique<LoaderXmpJpeg>(id, image, parIdx);
|
||||
}
|
||||
|
||||
PreviewProperties LoaderXmpJpeg::getProperties() const
|
||||
@@ -1128,8 +1132,8 @@ namespace Exiv2 {
|
||||
PreviewPropertiesList list;
|
||||
// go through the loader table and store all successfully created loaders in the list
|
||||
for (PreviewId id = 0; id < Loader::getNumLoaders(); ++id) {
|
||||
Loader::UniquePtr loader = Loader::create(id, image_);
|
||||
if (loader.get() && loader->readDimensions()) {
|
||||
auto loader = Loader::create(id, image_);
|
||||
if (loader && loader->readDimensions()) {
|
||||
PreviewProperties props = loader->getProperties();
|
||||
DataBuf buf = loader->getData(); // #16 getPreviewImage()
|
||||
props.size_ = buf.size(); // update the size
|
||||
@@ -1142,9 +1146,9 @@ namespace Exiv2 {
|
||||
|
||||
PreviewImage PreviewManager::getPreviewImage(const PreviewProperties &properties) const
|
||||
{
|
||||
Loader::UniquePtr loader = Loader::create(properties.id_, image_);
|
||||
auto loader = Loader::create(properties.id_, image_);
|
||||
DataBuf buf;
|
||||
if (loader.get()) {
|
||||
if (loader) {
|
||||
buf = loader->getData();
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -350,8 +350,7 @@ namespace Exiv2 {
|
||||
throw Error(kerDataSourceOpenFailed, io_->path(), strError());
|
||||
}
|
||||
IoCloser closer(*io_);
|
||||
BasicIo::UniquePtr tempIo(new MemIo);
|
||||
assert (tempIo.get() != 0);
|
||||
auto tempIo = std::make_unique<MemIo>();
|
||||
|
||||
doWriteMetadata(*tempIo); // may throw
|
||||
io_->close();
|
||||
@@ -685,7 +684,7 @@ namespace Exiv2 {
|
||||
// free functions
|
||||
Image::UniquePtr newPsdInstance(BasicIo::UniquePtr io, bool /*create*/)
|
||||
{
|
||||
Image::UniquePtr image(new PsdImage(std::move(io)));
|
||||
auto image = std::make_unique<PsdImage>(std::move(io));
|
||||
if (!image->good())
|
||||
{
|
||||
image.reset();
|
||||
|
||||
+1
-1
@@ -383,7 +383,7 @@ namespace Exiv2 {
|
||||
// free functions
|
||||
Image::UniquePtr newRafInstance(BasicIo::UniquePtr io, bool create)
|
||||
{
|
||||
Image::UniquePtr image(new RafImage(std::move(io), create));
|
||||
auto image = std::make_unique<RafImage>(std::move(io), create);
|
||||
if (!image->good()) {
|
||||
image.reset();
|
||||
}
|
||||
|
||||
+3
-3
@@ -136,8 +136,8 @@ namespace Exiv2 {
|
||||
if (list.size() != 1) return;
|
||||
ExifData exifData;
|
||||
PreviewImage preview = loader.getPreviewImage(*list.begin());
|
||||
Image::UniquePtr image = ImageFactory::open(preview.pData(), preview.size());
|
||||
if (image.get() == nullptr) {
|
||||
auto image = ImageFactory::open(preview.pData(), preview.size());
|
||||
if (!image) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
EXV_WARNING << "Failed to open RW2 preview image.\n";
|
||||
#endif
|
||||
@@ -238,7 +238,7 @@ namespace Exiv2 {
|
||||
// free functions
|
||||
Image::UniquePtr newRw2Instance(BasicIo::UniquePtr io, bool /*create*/)
|
||||
{
|
||||
Image::UniquePtr image(new Rw2Image(std::move(io)));
|
||||
auto image = std::make_unique<Rw2Image>(std::move(io));
|
||||
if (!image->good()) {
|
||||
image.reset();
|
||||
}
|
||||
|
||||
+1
-1
@@ -122,7 +122,7 @@ namespace Exiv2 {
|
||||
// free functions
|
||||
Image::UniquePtr newTgaInstance(BasicIo::UniquePtr io, bool /*create*/)
|
||||
{
|
||||
Image::UniquePtr image(new TgaImage(std::move(io)));
|
||||
auto image = std::make_unique<TgaImage>(std::move(io));
|
||||
if (!image->good())
|
||||
{
|
||||
image.reset();
|
||||
|
||||
@@ -575,7 +575,7 @@ namespace Exiv2 {
|
||||
{
|
||||
auto tag = static_cast<uint16_t>(idx / cfg()->tagStep());
|
||||
int32_t sz = std::min(def.size(tag, cfg()->group_), TiffEntryBase::doSize() - idx);
|
||||
TiffComponent::UniquePtr tc = TiffCreator::create(tag, cfg()->group_);
|
||||
auto tc = TiffCreator::create(tag, cfg()->group_);
|
||||
auto tp = dynamic_cast<TiffBinaryElement*>(tc.get());
|
||||
// The assertion typically fails if a component is not configured in
|
||||
// the TIFF structure table (TiffCreator::tiffTreeStruct_)
|
||||
@@ -633,7 +633,7 @@ namespace Exiv2 {
|
||||
}
|
||||
}
|
||||
if (tc == nullptr) {
|
||||
TiffComponent::UniquePtr atc;
|
||||
std::unique_ptr<TiffComponent> atc;
|
||||
if (tiffPath.size() == 1 && object.get() != nullptr) {
|
||||
atc = std::move(object);
|
||||
} else {
|
||||
@@ -682,7 +682,7 @@ namespace Exiv2 {
|
||||
if (tiffPath.size() == 1 && object.get() != nullptr) {
|
||||
tc = addChild(std::move(object));
|
||||
} else {
|
||||
TiffComponent::UniquePtr atc(new TiffDirectory(tpi1.tag(), tpi2.group()));
|
||||
auto atc = std::make_unique<TiffDirectory>(tpi1.tag(), tpi2.group());
|
||||
tc = addChild(std::move(atc));
|
||||
}
|
||||
setCount(static_cast<uint32_t>(ifds_.size()));
|
||||
@@ -747,7 +747,7 @@ namespace Exiv2 {
|
||||
}
|
||||
}
|
||||
if (tc == nullptr) {
|
||||
TiffComponent::UniquePtr atc;
|
||||
std::unique_ptr<TiffComponent> atc;
|
||||
if (tiffPath.size() == 1 && object.get() != nullptr) {
|
||||
atc = std::move(object);
|
||||
} else {
|
||||
@@ -1879,17 +1879,17 @@ namespace Exiv2 {
|
||||
|
||||
TiffComponent::UniquePtr newTiffEntry(uint16_t tag, IfdId group)
|
||||
{
|
||||
return TiffComponent::UniquePtr(new TiffEntry(tag, group));
|
||||
return std::make_unique<TiffEntry>(tag, group);
|
||||
}
|
||||
|
||||
TiffComponent::UniquePtr newTiffMnEntry(uint16_t tag, IfdId group)
|
||||
{
|
||||
return TiffComponent::UniquePtr(new TiffMnEntry(tag, group, mnId));
|
||||
return std::make_unique<TiffMnEntry>(tag, group, mnId);
|
||||
}
|
||||
|
||||
TiffComponent::UniquePtr newTiffBinaryElement(uint16_t tag, IfdId group)
|
||||
{
|
||||
return TiffComponent::UniquePtr(new TiffBinaryElement(tag, group));
|
||||
return std::make_unique<TiffBinaryElement>(tag, group);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -201,7 +201,7 @@ namespace Exiv2 {
|
||||
TiffComponent* addPath(uint16_t tag,
|
||||
TiffPath& tiffPath,
|
||||
TiffComponent* const pRoot,
|
||||
UniquePtr object =UniquePtr(nullptr));
|
||||
UniquePtr object =nullptr);
|
||||
/*!
|
||||
@brief Add a child to the component. Default is to do nothing.
|
||||
@param tiffComponent Auto pointer to the component to add.
|
||||
|
||||
+1
-1
@@ -307,7 +307,7 @@ namespace Exiv2 {
|
||||
// free functions
|
||||
Image::UniquePtr newTiffInstance(BasicIo::UniquePtr io, bool create)
|
||||
{
|
||||
Image::UniquePtr image(new TiffImage(std::move(io), create));
|
||||
auto image = std::make_unique<TiffImage>(std::move(io), create);
|
||||
if (!image->good()) {
|
||||
image.reset();
|
||||
}
|
||||
|
||||
+10
-11
@@ -1836,13 +1836,11 @@ namespace Exiv2 {
|
||||
return key.r_ == root_ && key.g_ == group_;
|
||||
}
|
||||
|
||||
TiffComponent::UniquePtr TiffCreator::create(uint32_t extendedTag,
|
||||
IfdId group)
|
||||
TiffComponent::UniquePtr TiffCreator::create(uint32_t extendedTag, IfdId group)
|
||||
{
|
||||
TiffComponent::UniquePtr tc;
|
||||
std::unique_ptr<TiffComponent> tc;
|
||||
auto tag = static_cast<uint16_t>(extendedTag & 0xffff);
|
||||
const TiffGroupStruct* ts = find(tiffGroupStruct_,
|
||||
TiffGroupStruct::Key(extendedTag, group));
|
||||
const TiffGroupStruct* ts = find(tiffGroupStruct_, TiffGroupStruct::Key(extendedTag, group));
|
||||
if (ts && ts->newTiffCompFct_) {
|
||||
tc = ts->newTiffCompFct_(tag, group);
|
||||
}
|
||||
@@ -1895,7 +1893,8 @@ namespace Exiv2 {
|
||||
ph = std::unique_ptr<TiffHeaderBase>(new TiffHeader);
|
||||
pHeader = ph.get();
|
||||
}
|
||||
TiffComponent::UniquePtr rootDir = parse(pData, size, root, pHeader);
|
||||
|
||||
auto rootDir = parse(pData, size, root, pHeader);
|
||||
if (nullptr != rootDir.get()) {
|
||||
TiffDecoder decoder(exifData,
|
||||
iptcData,
|
||||
@@ -1931,7 +1930,7 @@ namespace Exiv2 {
|
||||
assert(pHeader);
|
||||
assert(pHeader->byteOrder() != invalidByteOrder);
|
||||
WriteMethod writeMethod = wmIntrusive;
|
||||
TiffComponent::UniquePtr parsedTree = parse(pData, size, root, pHeader);
|
||||
auto parsedTree = parse(pData, size, root, pHeader);
|
||||
PrimaryGroups primaryGroups;
|
||||
findPrimaryGroups(primaryGroups, parsedTree.get());
|
||||
if (nullptr != parsedTree.get()) {
|
||||
@@ -1948,7 +1947,7 @@ namespace Exiv2 {
|
||||
if (!encoder.dirty()) writeMethod = wmNonIntrusive;
|
||||
}
|
||||
if (writeMethod == wmIntrusive) {
|
||||
TiffComponent::UniquePtr createdTree = TiffCreator::create(root, ifdIdNotSet);
|
||||
auto createdTree = TiffCreator::create(root, ifdIdNotSet);
|
||||
if (nullptr != parsedTree.get()) {
|
||||
// Copy image tags from the original image to the composite
|
||||
TiffCopier copier(createdTree.get(), root, pHeader, &primaryGroups);
|
||||
@@ -1960,7 +1959,7 @@ namespace Exiv2 {
|
||||
encoder.add(createdTree.get(), parsedTree.get(), root);
|
||||
// Write binary representation from the composite tree
|
||||
DataBuf header = pHeader->write();
|
||||
BasicIo::UniquePtr tempIo(new MemIo);
|
||||
auto tempIo = std::make_unique<MemIo>();
|
||||
assert(tempIo.get() != 0);
|
||||
IoWrapper ioWrapper(*tempIo, header.c_data(), header.size(), pOffsetWriter);
|
||||
auto imageIdx(uint32_t(-1));
|
||||
@@ -1996,8 +1995,8 @@ namespace Exiv2 {
|
||||
if (!pHeader->read(pData, size) || pHeader->offset() >= size) {
|
||||
throw Error(kerNotAnImage, "TIFF");
|
||||
}
|
||||
TiffComponent::UniquePtr rootDir = TiffCreator::create(root, ifdIdNotSet);
|
||||
if (nullptr != rootDir.get()) {
|
||||
auto rootDir = TiffCreator::create(root, ifdIdNotSet);
|
||||
if (rootDir) {
|
||||
rootDir->setStart(pData + pHeader->offset());
|
||||
TiffRwState state(pHeader->byteOrder(), 0);
|
||||
TiffReader reader(pData, size, rootDir.get(), state);
|
||||
|
||||
+10
-10
@@ -196,7 +196,7 @@ namespace Exiv2 {
|
||||
assert(object != 0);
|
||||
|
||||
if (pHeader_->isImageTag(object->tag(), object->group(), pPrimaryGroups_)) {
|
||||
TiffComponent::UniquePtr clone = object->clone();
|
||||
auto clone = object->clone();
|
||||
// Assumption is that the corresponding TIFF entry doesn't exist
|
||||
TiffPath tiffPath;
|
||||
TiffCreator::getPath(tiffPath, object->tag(), object->group(), root_);
|
||||
@@ -618,7 +618,7 @@ namespace Exiv2 {
|
||||
irbKey.setIdx(pos->idx());
|
||||
}
|
||||
if (rawIptc.size() != 0 && (del || pos == exifData_.end())) {
|
||||
Value::UniquePtr value = Value::create(unsignedLong);
|
||||
auto value = Value::create(unsignedLong);
|
||||
DataBuf buf;
|
||||
if (rawIptc.size() % 4 != 0) {
|
||||
// Pad the last unsignedLong value with 0s
|
||||
@@ -642,7 +642,7 @@ namespace Exiv2 {
|
||||
irbBuf = Photoshop::setIptcIrb(irbBuf.c_data(), irbBuf.size(), iptcData_);
|
||||
exifData_.erase(pos);
|
||||
if (irbBuf.size() != 0) {
|
||||
Value::UniquePtr value = Value::create(unsignedByte);
|
||||
auto value = Value::create(unsignedByte);
|
||||
value->read(irbBuf.data(), irbBuf.size(), invalidByteOrder);
|
||||
Exifdatum iptcDatum(irbKey, value.get());
|
||||
exifData_.add(iptcDatum);
|
||||
@@ -672,7 +672,7 @@ namespace Exiv2 {
|
||||
}
|
||||
if (!xmpPacket.empty()) {
|
||||
// Set the XMP Exif tag to the new value
|
||||
Value::UniquePtr value = Value::create(unsignedByte);
|
||||
auto value = Value::create(unsignedByte);
|
||||
value->read(reinterpret_cast<const byte*>(&xmpPacket[0]),
|
||||
static_cast<long>(xmpPacket.size()),
|
||||
invalidByteOrder);
|
||||
@@ -1332,8 +1332,8 @@ namespace Exiv2 {
|
||||
return;
|
||||
}
|
||||
uint16_t tag = getUShort(p, byteOrder());
|
||||
TiffComponent::UniquePtr tc = TiffCreator::create(tag, object->group());
|
||||
if (tc.get()) {
|
||||
auto tc = TiffCreator::create(tag, object->group());
|
||||
if (tc) {
|
||||
tc->setStart(p);
|
||||
object->addChild(std::move(tc));
|
||||
} else {
|
||||
@@ -1411,8 +1411,8 @@ namespace Exiv2 {
|
||||
break;
|
||||
}
|
||||
// If there are multiple dirs, group is incremented for each
|
||||
TiffComponent::UniquePtr td(new TiffDirectory(object->tag(),
|
||||
static_cast<IfdId>(object->newGroup_ + i)));
|
||||
auto td = std::make_unique<TiffDirectory>(object->tag(),
|
||||
static_cast<IfdId>(object->newGroup_ + i));
|
||||
td->setStart(pData_ + baseOffset() + offset);
|
||||
object->addChild(std::move(td));
|
||||
}
|
||||
@@ -1604,7 +1604,7 @@ namespace Exiv2 {
|
||||
size = 0;
|
||||
}
|
||||
}
|
||||
Value::UniquePtr v = Value::create(typeId);
|
||||
auto v = Value::create(typeId);
|
||||
enforce(v.get() != nullptr, kerCorruptedMetadata);
|
||||
v->read(pData, size, byteOrder());
|
||||
|
||||
@@ -1705,7 +1705,7 @@ namespace Exiv2 {
|
||||
ByteOrder bo = object->elByteOrder();
|
||||
if (bo == invalidByteOrder) bo = byteOrder();
|
||||
TypeId typeId = toTypeId(object->elDef()->tiffType_, object->tag(), object->group());
|
||||
Value::UniquePtr v = Value::create(typeId);
|
||||
auto v = Value::create(typeId);
|
||||
enforce(v.get() != nullptr, kerCorruptedMetadata);
|
||||
v->read(pData, size, bo);
|
||||
|
||||
|
||||
+20
-20
@@ -50,69 +50,69 @@ namespace Exiv2 {
|
||||
|
||||
Value::UniquePtr Value::create(TypeId typeId)
|
||||
{
|
||||
UniquePtr value;
|
||||
std::unique_ptr<Value> value;
|
||||
switch (typeId) {
|
||||
case invalidTypeId:
|
||||
case signedByte:
|
||||
case unsignedByte:
|
||||
value = UniquePtr(new DataValue(typeId));
|
||||
value = std::make_unique<DataValue>(typeId);
|
||||
break;
|
||||
case asciiString:
|
||||
value = UniquePtr(new AsciiValue);
|
||||
value = std::make_unique<AsciiValue>();
|
||||
break;
|
||||
case unsignedShort:
|
||||
value = UniquePtr(new ValueType<uint16_t>);
|
||||
value = std::make_unique<ValueType<uint16_t>>();
|
||||
break;
|
||||
case unsignedLong:
|
||||
case tiffIfd:
|
||||
value = UniquePtr(new ValueType<uint32_t>(typeId));
|
||||
value = std::make_unique<ValueType<uint32_t>>(typeId);
|
||||
break;
|
||||
case unsignedRational:
|
||||
value = UniquePtr(new ValueType<URational>);
|
||||
value = std::make_unique<ValueType<URational>>();
|
||||
break;
|
||||
case undefined:
|
||||
value = UniquePtr(new DataValue);
|
||||
value = std::make_unique<DataValue>();
|
||||
break;
|
||||
case signedShort:
|
||||
value = UniquePtr(new ValueType<int16_t>);
|
||||
value = std::make_unique<ValueType<int16_t>>();
|
||||
break;
|
||||
case signedLong:
|
||||
value = UniquePtr(new ValueType<int32_t>);
|
||||
value = std::make_unique<ValueType<int32_t>>();
|
||||
break;
|
||||
case signedRational:
|
||||
value = UniquePtr(new ValueType<Rational>);
|
||||
value = std::make_unique<ValueType<Rational>>();
|
||||
break;
|
||||
case tiffFloat:
|
||||
value = UniquePtr(new ValueType<float>);
|
||||
value = std::make_unique<ValueType<float>>();
|
||||
break;
|
||||
case tiffDouble:
|
||||
value = UniquePtr(new ValueType<double>);
|
||||
value = std::make_unique<ValueType<double>>();
|
||||
break;
|
||||
case string:
|
||||
value = UniquePtr(new StringValue);
|
||||
value = std::make_unique<StringValue>();
|
||||
break;
|
||||
case date:
|
||||
value = UniquePtr(new DateValue);
|
||||
value = std::make_unique<DateValue>();
|
||||
break;
|
||||
case time:
|
||||
value = UniquePtr(new TimeValue);
|
||||
value = std::make_unique<TimeValue>();
|
||||
break;
|
||||
case comment:
|
||||
value = UniquePtr(new CommentValue);
|
||||
value = std::make_unique<CommentValue>();
|
||||
break;
|
||||
case xmpText:
|
||||
value = UniquePtr(new XmpTextValue);
|
||||
value = std::make_unique<XmpTextValue>();
|
||||
break;
|
||||
case xmpBag:
|
||||
case xmpSeq:
|
||||
case xmpAlt:
|
||||
value = UniquePtr(new XmpArrayValue(typeId));
|
||||
value = std::make_unique<XmpArrayValue>(typeId);
|
||||
break;
|
||||
case langAlt:
|
||||
value = UniquePtr(new LangAltValue);
|
||||
value = std::make_unique<LangAltValue>();
|
||||
break;
|
||||
default:
|
||||
value = UniquePtr(new DataValue(typeId));
|
||||
value = std::make_unique<DataValue>(typeId);
|
||||
break;
|
||||
}
|
||||
return value;
|
||||
|
||||
+4
-5
@@ -110,8 +110,7 @@ namespace Exiv2 {
|
||||
throw Error(kerDataSourceOpenFailed, io_->path(), strError());
|
||||
}
|
||||
IoCloser closer(*io_);
|
||||
BasicIo::UniquePtr tempIo(new MemIo);
|
||||
assert (tempIo.get() != 0);
|
||||
auto tempIo = std::make_unique<MemIo>();
|
||||
|
||||
doWriteMetadata(*tempIo); // may throw
|
||||
io_->close();
|
||||
@@ -479,8 +478,8 @@ namespace Exiv2 {
|
||||
|
||||
if ( equalsWebPTag(chunkId, WEBP_CHUNK_HEADER_EXIF) && option==kpsRecursive ) {
|
||||
// create memio object with the payload, then print the structure
|
||||
BasicIo::UniquePtr p = BasicIo::UniquePtr(new MemIo(payload.c_data(),payload.size()));
|
||||
printTiffStructure(*p,out,option,depth);
|
||||
MemIo p (payload.c_data(),payload.size());
|
||||
printTiffStructure(p,out,option,depth);
|
||||
}
|
||||
|
||||
bool bPrintPayload = (equalsWebPTag(chunkId, WEBP_CHUNK_HEADER_XMP) && option==kpsXMP)
|
||||
@@ -732,7 +731,7 @@ namespace Exiv2 {
|
||||
|
||||
Image::UniquePtr newWebPInstance(BasicIo::UniquePtr io, bool /*create*/)
|
||||
{
|
||||
Image::UniquePtr image(new WebPImage(std::move(io)));
|
||||
auto image = std::make_unique<WebPImage>(std::move(io));
|
||||
if (!image->good()) {
|
||||
image.reset();
|
||||
}
|
||||
|
||||
+8
-9
@@ -786,10 +786,10 @@ namespace Exiv2 {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
XmpKey::UniquePtr key = makeXmpKey(schemaNs, propPath);
|
||||
auto key = makeXmpKey(schemaNs, propPath);
|
||||
if (XMP_ArrayIsAltText(opt)) {
|
||||
// Read Lang Alt property
|
||||
LangAltValue::UniquePtr val(new LangAltValue);
|
||||
auto val = std::make_unique<LangAltValue>();
|
||||
XMP_Index count = meta.CountArrayItems(schemaNs.c_str(), propPath.c_str());
|
||||
while (count-- > 0) {
|
||||
// Get the text
|
||||
@@ -836,7 +836,7 @@ namespace Exiv2 {
|
||||
}
|
||||
if (simpleArray) {
|
||||
// Read the array into an XmpArrayValue
|
||||
XmpArrayValue::UniquePtr val(new XmpArrayValue(arrayValueTypeId(opt)));
|
||||
auto val = std::make_unique<XmpArrayValue>(arrayValueTypeId(opt));
|
||||
XMP_Index count = meta.CountArrayItems(schemaNs.c_str(), propPath.c_str());
|
||||
while (count-- > 0) {
|
||||
iter.Next(&schemaNs, &propPath, &propValue, &opt);
|
||||
@@ -847,17 +847,16 @@ namespace Exiv2 {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
XmpTextValue::UniquePtr val(new XmpTextValue);
|
||||
if ( XMP_PropIsStruct(opt)
|
||||
|| XMP_PropIsArray(opt)) {
|
||||
|
||||
auto val = std::make_unique<XmpTextValue>();
|
||||
if (XMP_PropIsStruct(opt) || XMP_PropIsArray(opt)) {
|
||||
// Create a metadatum with only XMP options
|
||||
val->setXmpArrayType(xmpArrayType(opt));
|
||||
val->setXmpStruct(xmpStruct(opt));
|
||||
xmpData.add(*key.get(), val.get());
|
||||
continue;
|
||||
}
|
||||
if ( XMP_PropIsSimple(opt)
|
||||
|| XMP_PropIsQualifier(opt)) {
|
||||
if (XMP_PropIsSimple(opt) || XMP_PropIsQualifier(opt)) {
|
||||
val->read(propValue);
|
||||
xmpData.add(*key.get(), val.get());
|
||||
continue;
|
||||
@@ -1146,7 +1145,7 @@ namespace {
|
||||
if (prefix.empty()) {
|
||||
throw Exiv2::Error(Exiv2::kerNoPrefixForNamespace, propPath, schemaNs);
|
||||
}
|
||||
return Exiv2::XmpKey::UniquePtr(new Exiv2::XmpKey(prefix, property));
|
||||
return std::make_unique<Exiv2::XmpKey>(prefix, property);
|
||||
} // makeXmpKey
|
||||
#endif // EXV_HAVE_XMP_TOOLKIT
|
||||
|
||||
|
||||
+3
-3
@@ -175,8 +175,8 @@ namespace Exiv2 {
|
||||
if (xmpPacket_.substr(0, 5) != "<?xml") {
|
||||
xmpPacket_ = xmlHeader + xmpPacket_ + xmlFooter;
|
||||
}
|
||||
BasicIo::UniquePtr tempIo(new MemIo);
|
||||
assert(tempIo.get() != 0);
|
||||
auto tempIo = std::make_unique<MemIo>();
|
||||
|
||||
// Write XMP packet
|
||||
if ( tempIo->write(reinterpret_cast<const byte*>(xmpPacket_.data()),
|
||||
static_cast<long>(xmpPacket_.size()))
|
||||
@@ -191,7 +191,7 @@ namespace Exiv2 {
|
||||
// free functions
|
||||
Image::UniquePtr newXmpInstance(BasicIo::UniquePtr io, bool create)
|
||||
{
|
||||
Image::UniquePtr image(new XmpSidecar(std::move(io), create));
|
||||
auto image = std::make_unique<XmpSidecar>(std::move(io), create);
|
||||
if (!image->good()) {
|
||||
image.reset();
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ TEST_F(AXmpKey, canBeCopied)
|
||||
TEST_F(AXmpKey, canBeCloned)
|
||||
{
|
||||
XmpKey key(expectedPrefix, expectedProperty);
|
||||
XmpKey::UniquePtr clonedKey = key.clone();
|
||||
auto clonedKey = key.clone();
|
||||
checkValidity(*clonedKey);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user