[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a
Maximiliano Curia
maxy at moszumanska.debian.org
Thu Jul 13 17:36:40 UTC 2017
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=44d0dea
The following commit has been merged in the master branch:
commit 44d0deac927be05f1b210f3741c0d0d51e0614b7
Author: Andreas Huggel <ahuggel at gmx.net>
Date: Sat Oct 16 06:43:40 2004 +0000
Converted Value hierarchy to use std::auto_ptr where appropriate
---
src/addmoddel.cpp | 29 +++++--------
src/exif.cpp | 49 ++++++++++-----------
src/exif.hpp | 30 ++++++-------
src/iptc.cpp | 44 +++++++++----------
src/iptc.hpp | 31 +++++++-------
src/iptctest.cpp | 16 +++----
src/metadatum.hpp | 13 +++---
src/value.cpp | 48 ++++++++++-----------
src/value.hpp | 124 +++++++++++++++++++++++++++++++++++++++---------------
9 files changed, 212 insertions(+), 172 deletions(-)
diff --git a/src/addmoddel.cpp b/src/addmoddel.cpp
index 8117e8e..5da934d 100644
--- a/src/addmoddel.cpp
+++ b/src/addmoddel.cpp
@@ -3,7 +3,7 @@
Abstract: Sample program showing how to add, modify and delete Exif metadata.
File: addmoddel.cpp
- Version: $Name: $ $Revision: 1.4 $
+ Version: $Name: $ $Revision: 1.5 $
Author(s): Andreas Huggel (ahu) <ahuggel at gmx.net>
History: 26-Jan-04, ahu: created
*/
@@ -24,19 +24,16 @@ try {
// Add to the Exif data
// Create a ASCII string value (note the use of create)
- Exiv2::Value* v = Exiv2::Value::create(Exiv2::asciiString);
+ Exiv2::Value::AutoPtr v = Exiv2::Value::create(Exiv2::asciiString);
// Set the value to a string
v->read("1999:12:31 23:59:59");
// Add the value together with its key to the Exif data container
Exiv2::ExifKey key("Exif.Photo.DateTimeOriginal");
- exifData.add(key, v);
-
+ exifData.add(key, v.get());
std::cout << "Added key \"" << key << "\", value \"" << *v << "\"
";
- // Delete the memory allocated by Value::create
- delete v;
// Now create a more interesting value (without using the create method)
- Exiv2::URationalValue* rv = new Exiv2::URationalValue;
+ Exiv2::URationalValue::AutoPtr rv(new Exiv2::URationalValue);
// Set two rational components from a string
rv->read("1/2 1/3");
// Add more elements through the extended interface of rational value
@@ -44,11 +41,8 @@ try {
rv->value_.push_back(std::make_pair(3,4));
// Add the key and value pair to the Exif data
key = Exiv2::ExifKey("Exif.Image.PrimaryChromaticities");
- exifData.add(key, rv);
-
+ exifData.add(key, rv.get());
std::cout << "Added key \"" << key << "\", value \"" << *rv << "\"
";
- // Delete memory allocated on the heap
- delete rv;
// *************************************************************************
// Modify Exif data
@@ -59,8 +53,8 @@ try {
if (pos == exifData.end()) throw Exiv2::Error("Key not found");
// Modify the value
std::string date = pos->toString();
- date.replace(0,4,"2000");
- pos->setValue(date);
+ date.replace(0, 4, "2000");
+ pos->setValue(date);
std::cout << "Modified key \"" << key
<< "\", new value \"" << pos->value() << "\"
";
@@ -71,14 +65,13 @@ try {
// Get a pointer to a copy of the value
v = pos->getValue();
// Downcast the Value pointer to its actual type
- rv = dynamic_cast<Exiv2::URationalValue*>(v);
- if (rv == 0) throw Exiv2::Error("Downcast failed");
+ Exiv2::URationalValue* prv = dynamic_cast<Exiv2::URationalValue*>(v.release());
+ if (prv == 0) throw Exiv2::Error("Downcast failed");
+ rv = Exiv2::URationalValue::AutoPtr(prv);
// Modify the value directly through the interface of URationalValue
rv->value_[2] = std::make_pair(88,77);
// Copy the modified value back to the metadatum
- pos->setValue(rv);
- // Delete the memory allocated by getValue
- delete v;
+ pos->setValue(rv.get());
std::cout << "Modified key \"" << key
<< "\", new value \"" << pos->value() << "\"
";
diff --git a/src/exif.cpp b/src/exif.cpp
index 22dedd0..dbc007c 100644
--- a/src/exif.cpp
+++ b/src/exif.cpp
@@ -20,14 +20,14 @@
*/
/*
File: exif.cpp
- Version: $Name: $ $Revision: 1.66 $
+ Version: $Name: $ $Revision: 1.67 $
Author(s): Andreas Huggel (ahu) <ahuggel at gmx.net>
History: 26-Jan-04, ahu: created
11-Feb-04, ahu: isolated as a component
*/
// *****************************************************************************
#include "rcsid.hpp"
-EXIV2_RCSID("@(#) $Name: $ $Revision: 1.66 $ $RCSfile: exif.cpp,v $");
+EXIV2_RCSID("@(#) $Name: $ $Revision: 1.67 $ $RCSfile: exif.cpp,v $");
// Define DEBUG_MAKERNOTE to output debug information to std::cerr
#undef DEBUG_MAKERNOTE
@@ -74,28 +74,27 @@ namespace {
namespace Exiv2 {
Exifdatum::Exifdatum(const Entry& e, ByteOrder byteOrder)
- : key_(ExifKey::AutoPtr(new ExifKey(e))), pValue_(0)
+ : key_(ExifKey::AutoPtr(new ExifKey(e)))
{
- pValue_ = Value::create(TypeId(e.type()));
- pValue_->read(e.data(), e.count() * e.typeSize(), byteOrder);
+ value_ = Value::create(TypeId(e.type()));
+ value_->read(e.data(), e.count() * e.typeSize(), byteOrder);
}
Exifdatum::Exifdatum(const ExifKey& key, const Value* pValue)
- : key_(key.clone()), pValue_(0)
+ : key_(key.clone())
{
- if (pValue) pValue_ = pValue->clone();
+ if (pValue) value_ = pValue->clone();
}
Exifdatum::~Exifdatum()
{
- delete pValue_;
}
Exifdatum::Exifdatum(const Exifdatum& rhs)
- : Metadatum(rhs), pValue_(0)
+ : Metadatum(rhs)
{
if (rhs.key_.get() != 0) key_ = rhs.key_->clone(); // deep copy
- if (rhs.pValue_ != 0) pValue_ = rhs.pValue_->clone(); // deep copy
+ if (rhs.value_.get() != 0) value_ = rhs.value_->clone(); // deep copy
}
Exifdatum& Exifdatum::operator=(const Exifdatum& rhs)
@@ -106,30 +105,28 @@ namespace Exiv2 {
key_.reset();
if (rhs.key_.get() != 0) key_ = rhs.key_->clone(); // deep copy
- delete pValue_;
- pValue_ = 0;
- if (rhs.pValue_ != 0) pValue_ = rhs.pValue_->clone(); // deep copy
+ value_.reset();
+ if (rhs.value_.get() != 0) value_ = rhs.value_->clone(); // deep copy
return *this;
} // Exifdatum::operator=
void Exifdatum::setValue(const Value* pValue)
{
- delete pValue_;
- pValue_ = pValue->clone();
+ value_.reset();
+ if (pValue) value_ = pValue->clone();
}
void Exifdatum::setValue(const Entry& e, ByteOrder byteOrder)
{
- delete pValue_;
- pValue_ = Value::create(TypeId(e.type()));
- pValue_->read(e.data(), e.count() * e.typeSize(), byteOrder);
+ value_ = Value::create(TypeId(e.type()));
+ value_->read(e.data(), e.count() * e.typeSize(), byteOrder);
}
void Exifdatum::setValue(const std::string& buf)
{
- if (pValue_ == 0) pValue_ = Value::create(asciiString);
- pValue_->read(buf);
+ if (value_.get() == 0) value_ = Value::create(asciiString);
+ value_->read(buf);
}
TiffThumbnail::TiffThumbnail()
@@ -443,9 +440,8 @@ namespace Exiv2 {
ExifKey key("Exif.Thumbnail.JPEGInterchangeFormat");
ExifData::iterator pos = exifData.findKey(key);
if (pos == exifData.end()) {
- Value* value = Value::create(unsignedLong);
- exifData.add(key, value);
- delete value;
+ Value::AutoPtr value = Value::create(unsignedLong);
+ exifData.add(key, value.get());
pos = exifData.findKey(key);
}
pos->setValue(toString(offset_));
@@ -453,9 +449,8 @@ namespace Exiv2 {
ExifKey key2("Exif.Thumbnail.JPEGInterchangeFormatLength");
pos = exifData.findKey(key2);
if (pos == exifData.end()) {
- Value *value = Value::create(unsignedLong);
- exifData.add(key2, value);
- delete value;
+ Value::AutoPtr value = Value::create(unsignedLong);
+ exifData.add(key2, value.get());
pos = exifData.findKey(key2);
}
pos->setValue(toString(size_));
@@ -866,7 +861,7 @@ namespace Exiv2 {
}
}
- void ExifData::add(const ExifKey& key, Value* pValue)
+ void ExifData::add(const ExifKey& key, const Value* pValue)
{
add(Exifdatum(key, pValue));
}
diff --git a/src/exif.hpp b/src/exif.hpp
index 3e768c6..7afe43d 100644
--- a/src/exif.hpp
+++ b/src/exif.hpp
@@ -21,7 +21,7 @@
/*!
@file exif.hpp
@brief Encoding and decoding of Exif data
- @version $Name: $ $Revision: 1.57 $
+ @version $Name: $ $Revision: 1.58 $
@author Andreas Huggel (ahu)
<a href="mailto:ahuggel at gmx.net">ahuggel at gmx.net</a>
@date 09-Jan-04, ahu: created
@@ -148,10 +148,10 @@ namespace Exiv2 {
@return Number of characters written.
*/
long copy(byte* buf, ByteOrder byteOrder) const
- { return pValue_ == 0 ? 0 : pValue_->copy(buf, byteOrder); }
+ { return value_.get() == 0 ? 0 : value_->copy(buf, byteOrder); }
//! Return the type id of the value
TypeId typeId() const
- { return pValue_ == 0 ? invalidTypeId : pValue_->typeId(); }
+ { return value_.get() == 0 ? invalidTypeId : value_->typeId(); }
//! Return the name of the type
const char* typeName() const
{ return TypeInfo::typeName(typeId()); }
@@ -160,13 +160,13 @@ namespace Exiv2 {
{ return TypeInfo::typeSize(typeId()); }
//! Return the number of components in the value
long count() const
- { return pValue_ == 0 ? 0 : pValue_->count(); }
+ { return value_.get() == 0 ? 0 : value_->count(); }
//! Return the size of the value in bytes
long size() const
- { return pValue_ == 0 ? 0 : pValue_->size(); }
+ { return value_.get() == 0 ? 0 : value_->size(); }
//! Return the value as a string.
std::string toString() const
- { return pValue_ == 0 ? "" : pValue_->toString(); }
+ { return value_.get() == 0 ? "" : value_->toString(); }
/*!
@brief Return the n-th component of the value converted to long. The
return value is -1 if the value of the Exifdatum is not set and
@@ -174,7 +174,7 @@ namespace Exiv2 {
component.
*/
long toLong(long n =0) const
- { return pValue_ == 0 ? -1 : pValue_->toLong(n); }
+ { return value_.get() == 0 ? -1 : value_->toLong(n); }
/*!
@brief Return the n-th component of the value converted to float. The
return value is -1 if the value of the Exifdatum is not set and
@@ -182,7 +182,7 @@ namespace Exiv2 {
component.
*/
float toFloat(long n =0) const
- { return pValue_ == 0 ? -1 : pValue_->toFloat(n); }
+ { return value_.get() == 0 ? -1 : value_->toFloat(n); }
/*!
@brief Return the n-th component of the value converted to
Rational. The return value is -1/1 if the value of the
@@ -190,7 +190,7 @@ namespace Exiv2 {
undefined if there is no n-th component.
*/
Rational toRational(long n =0) const
- { return pValue_ == 0 ? Rational(-1, 1) : pValue_->toRational(n); }
+ { return value_.get() == 0 ? Rational(-1, 1) : value_->toRational(n); }
/*!
@brief Return a pointer to a copy (clone) of the value. The caller
is responsible to delete this copy when it's no longer needed.
@@ -203,8 +203,8 @@ namespace Exiv2 {
@return A pointer to a copy (clone) of the value, 0 if the value is
not set.
*/
- Value* getValue() const
- { return pValue_ == 0 ? 0 : pValue_->clone(); }
+ Value::AutoPtr getValue() const
+ { return value_.get() == 0 ? Value::AutoPtr(0) : value_->clone(); }
/*!
@brief Return a constant reference to the value.
@@ -225,13 +225,13 @@ namespace Exiv2 {
@throw Error ("Value not set") if the value is not set.
*/
const Value& value() const
- { if (pValue_) return *pValue_; throw Error("Value not set"); }
+ { if (value_.get() != 0) return *value_; throw Error("Value not set"); }
//@}
private:
// DATA
- ExifKey::AutoPtr key_; //!< Key
- Value* pValue_; //!< Pointer to the value
+ ExifKey::AutoPtr key_; //!< Key
+ Value::AutoPtr value_; //!< Value
}; // class Exifdatum
@@ -582,7 +582,7 @@ namespace Exiv2 {
performed, i.e., it is possible to add multiple metadata with
the same key.
*/
- void add(const ExifKey& key, Value* pValue);
+ void add(const ExifKey& key, const Value* pValue);
/*!
@brief Add a copy of the Exifdatum to the Exif metadata. No
duplicate checks are performed, i.e., it is possible to add
diff --git a/src/iptc.cpp b/src/iptc.cpp
index c291353..2b5af62 100644
--- a/src/iptc.cpp
+++ b/src/iptc.cpp
@@ -20,13 +20,13 @@
*/
/*
File: iptc.cpp
- Version: $Name: $ $Revision: 1.8 $
+ Version: $Name: $ $Revision: 1.9 $
Author(s): Brad Schick (brad) <schick at robotbattle.com>
History: 31-July-04, brad: created
*/
// *****************************************************************************
#include "rcsid.hpp"
-EXIV2_RCSID("@(#) $Name: $ $Revision: 1.8 $ $RCSfile: iptc.cpp,v $");
+EXIV2_RCSID("@(#) $Name: $ $Revision: 1.9 $ $RCSfile: iptc.cpp,v $");
// Define DEBUG_MAKERNOTE to output debug information to std::cerr
#undef DEBUG_MAKERNOTE
@@ -49,22 +49,21 @@ EXIV2_RCSID("@(#) $Name: $ $Revision: 1.8 $ $RCSfile: iptc.cpp,v $");
namespace Exiv2 {
Iptcdatum::Iptcdatum(const IptcKey& key,
- const Value* value)
- : key_(key.clone()), pValue_(0), modified_(false)
+ const Value* pValue)
+ : key_(key.clone()), modified_(false)
{
- if (value) pValue_ = value->clone();
+ if (pValue) value_ = pValue->clone();
}
Iptcdatum::Iptcdatum(const Iptcdatum& rhs)
- : Metadatum(rhs), pValue_(0), modified_(false)
+ : Metadatum(rhs), modified_(false)
{
if (rhs.key_.get() != 0) key_ = rhs.key_->clone(); // deep copy
- if (rhs.pValue_ != 0) pValue_ = rhs.pValue_->clone(); // deep copy
+ if (rhs.value_.get() != 0) value_ = rhs.value_->clone(); // deep copy
}
Iptcdatum::~Iptcdatum()
{
- delete pValue_;
}
Iptcdatum& Iptcdatum::operator=(const Iptcdatum& rhs)
@@ -76,9 +75,8 @@ namespace Exiv2 {
key_.reset();
if (rhs.key_.get() != 0) key_ = rhs.key_->clone(); // deep copy
- delete pValue_;
- pValue_ = 0;
- if (rhs.pValue_ != 0) pValue_ = rhs.pValue_->clone(); // deep copy
+ value_.reset();
+ if (rhs.value_.get() != 0) value_ = rhs.value_->clone(); // deep copy
return *this;
} // Iptcdatum::operator=
@@ -86,15 +84,15 @@ namespace Exiv2 {
void Iptcdatum::setValue(const Value* pValue)
{
modified_ = true;
- delete pValue_;
- pValue_ = pValue->clone();
+ value_.reset();
+ if (pValue) value_ = pValue->clone();
}
void Iptcdatum::setValue(const std::string& buf)
{
modified_ = true;
- if (pValue_ == 0) pValue_ = Value::create(string);
- pValue_->read(buf);
+ if (value_.get() == 0) value_ = Value::create(string);
+ value_->read(buf);
}
const byte IptcData::marker_ = 0x1C; // Dataset marker
@@ -179,23 +177,21 @@ namespace Exiv2 {
int IptcData::readData(uint16_t dataSet, uint16_t record,
const byte* data, uint32_t sizeData)
{
- Value* val = 0;
+ Value::AutoPtr value;
try {
- // If the type is unknown or the parse failes then
+ // If the type is unknown or the parse fails then
// default to undefined type below.
TypeId type = IptcDataSets::dataSetType(dataSet, record);
- val = Value::create(type);
- val->read(data, sizeData, bigEndian);
+ value = Value::create(type);
+ value->read(data, sizeData, bigEndian);
}
catch (const Error&) {
// Default to loading as raw bytes
- delete val;
- val = Value::create(undefined);
- val->read(data, sizeData, bigEndian);
+ value = Value::create(undefined);
+ value->read(data, sizeData, bigEndian);
}
IptcKey key(dataSet, record);
- add(key, val);
- delete val;
+ add(key, value.get());
return 0;
}
diff --git a/src/iptc.hpp b/src/iptc.hpp
index d5480bf..07159cd 100644
--- a/src/iptc.hpp
+++ b/src/iptc.hpp
@@ -21,7 +21,7 @@
/*!
@file iptc.hpp
@brief Encoding and decoding of Iptc data
- @version $Name: $ $Revision: 1.8 $
+ @version $Name: $ $Revision: 1.9 $
@author Brad Schick (brad)
<a href="mailto:schick at robotbattle.com">schick at robotbattle.com</a>
@date 31-Jul-04, brad: created
@@ -68,7 +68,7 @@ namespace Exiv2 {
to a tag number and record id.
*/
explicit Iptcdatum(const IptcKey& key,
- const Value* value =0);
+ const Value* pValue =0);
//! Copy constructor
Iptcdatum(const Iptcdatum& rhs);
//! Destructor
@@ -106,7 +106,7 @@ namespace Exiv2 {
@return Number of characters written.
*/
long copy(byte* buf, ByteOrder byteOrder) const
- { return pValue_ == 0 ? 0 : pValue_->copy(buf, byteOrder); }
+ { return value_.get() == 0 ? 0 : value_->copy(buf, byteOrder); }
/*!
@brief Return the key of the Iptcdatum. The key is of the form
'<b>Iptc</b>.recordName.datasetName'. Note however that the key
@@ -139,20 +139,20 @@ namespace Exiv2 {
{ return key_.get() == 0 ? 0 : key_->tag(); }
//! Return the type id of the value
TypeId typeId() const
- { return pValue_ == 0 ? invalidTypeId : pValue_->typeId(); }
+ { return value_.get() == 0 ? invalidTypeId : value_->typeId(); }
//! Return the name of the type
const char* typeName() const { return TypeInfo::typeName(typeId()); }
//! Return the size in bytes of one component of this type
long typeSize() const { return TypeInfo::typeSize(typeId()); }
//! Return the number of components in the value
- long count() const { return pValue_ == 0 ? 0 : pValue_->count(); }
+ long count() const { return value_.get() == 0 ? 0 : value_->count(); }
//! Return the size of the value in bytes
- long size() const { return pValue_ == 0 ? 0 : pValue_->size(); }
+ long size() const { return value_.get() == 0 ? 0 : value_->size(); }
//! Return true if value was modified, otherwise false
bool modified() const { return modified_; }
//! Return the value as a string.
std::string toString() const
- { return pValue_ == 0 ? "" : pValue_->toString(); }
+ { return value_.get() == 0 ? "" : value_->toString(); }
/*!
@brief Return the n-th component of the value converted to long. The
return value is -1 if the value of the Iptcdatum is not set and
@@ -160,7 +160,7 @@ namespace Exiv2 {
component.
*/
long toLong(long n =0) const
- { return pValue_ == 0 ? -1 : pValue_->toLong(n); }
+ { return value_.get() == 0 ? -1 : value_->toLong(n); }
/*!
@brief Return the n-th component of the value converted to float. The
return value is -1 if the value of the Iptcdatum is not set and
@@ -168,7 +168,7 @@ namespace Exiv2 {
component.
*/
float toFloat(long n =0) const
- { return pValue_ == 0 ? -1 : pValue_->toFloat(n); }
+ { return value_.get() == 0 ? -1 : value_->toFloat(n); }
/*!
@brief Return the n-th component of the value converted to
Rational. The return value is -1/1 if the value of the
@@ -176,7 +176,7 @@ namespace Exiv2 {
undefined if there is no n-th component.
*/
Rational toRational(long n =0) const
- { return pValue_ == 0 ? Rational(-1, 1) : pValue_->toRational(n); }
+ { return value_.get() == 0 ? Rational(-1, 1) : value_->toRational(n); }
/*!
@brief Return a pointer to a copy (clone) of the value. The caller
is responsible to delete this copy when it's no longer needed.
@@ -189,7 +189,8 @@ namespace Exiv2 {
@return A pointer to a copy (clone) of the value, 0 if the value is
not set.
*/
- Value* getValue() const { return pValue_ == 0 ? 0 : pValue_->clone(); }
+ Value::AutoPtr getValue() const
+ { return value_.get() == 0 ? Value::AutoPtr(0) : value_->clone(); }
/*!
@brief Return a constant reference to the value.
@@ -210,7 +211,7 @@ namespace Exiv2 {
@throw Error ("Value not set") if the value is not set.
*/
const Value& value() const
- { if (pValue_) return *pValue_; throw Error("Value not set"); }
+ { if (value_.get() != 0) return *value_; throw Error("Value not set"); }
//@}
/*!
@@ -221,9 +222,9 @@ namespace Exiv2 {
private:
// DATA
- IptcKey::AutoPtr key_; //!< Key
- Value* pValue_; //!< Pointer to the value
- bool modified_; //!< Change indicator
+ IptcKey::AutoPtr key_; //!< Key
+ Value::AutoPtr value_; //!< Value
+ bool modified_; //!< Change indicator
}; // class Iptcdatum
diff --git a/src/iptctest.cpp b/src/iptctest.cpp
index 5f849d0..3e3702e 100644
--- a/src/iptctest.cpp
+++ b/src/iptctest.cpp
@@ -4,7 +4,7 @@
This is not designed to be a robust application.
File : iptctest.cpp
- Version : $Name: $ $Revision: 1.4 $
+ Version : $Name: $ $Revision: 1.5 $
Author(s): Brad Schick (brad) <schick at robotbattle.com>
History : 01-Aug-04, brad: created
*/
@@ -113,10 +113,10 @@ void processAdd(const std::string& line, int num)
data = data.substr(1, data.size()-2);
}
TypeId type = IptcDataSets::dataSetType(iptcKey.tag(), iptcKey.record());
- Value *val = Value::create(type);
- val->read(data);
+ Value::AutoPtr value = Value::create(type);
+ value->read(data);
- int rc = g_iptcData.add(iptcKey, val);
+ int rc = g_iptcData.add(iptcKey, value.get());
if (rc) {
std::string error = IptcData::strError(rc, "Input file");
throw Error(error);
@@ -166,15 +166,15 @@ void processModify(const std::string& line, int num)
data = data.substr(1, data.size()-2);
}
TypeId type = IptcDataSets::dataSetType(iptcKey.tag(), iptcKey.record());
- Value *val = Value::create(type);
- val->read(data);
+ Value::AutoPtr value = Value::create(type);
+ value->read(data);
IptcData::iterator iter = g_iptcData.findId(iptcKey.tag(), iptcKey.record());
if (iter != g_iptcData.end()) {
- iter->setValue(val);
+ iter->setValue(value.get());
}
else {
- int rc = g_iptcData.add(iptcKey, val);
+ int rc = g_iptcData.add(iptcKey, value.get());
if (rc) {
std::string error = IptcData::strError(rc, "Input file");
throw Error(error);
diff --git a/src/metadatum.hpp b/src/metadatum.hpp
index c70194d..c7efd15 100644
--- a/src/metadatum.hpp
+++ b/src/metadatum.hpp
@@ -21,7 +21,7 @@
/*!
@file metadatum.hpp
@brief Provides abstract base classes Metadatum and Key
- @version $Name: $ $Revision: 1.4 $
+ @version $Name: $ $Revision: 1.5 $
@author Andreas Huggel (ahu)
<a href="mailto:ahuggel at gmx.net">ahuggel at gmx.net</a>
@author Brad Schick (brad)
@@ -208,18 +208,19 @@ namespace Exiv2 {
*/
virtual Rational toRational(long n =0) const =0;
/*!
- @brief Return a pointer to a copy (clone) of the value. The caller
- is responsible to delete this copy when it's no longer needed.
+ @brief Return an auto-pointer to a copy (clone) of the value. The
+ caller owns this copy and the auto-poiner ensures that it will
+ be deleted.
This method is provided for users who need full control over the
value. A caller may, e.g., downcast the pointer to the appropriate
subclass of Value to make use of the interface of the subclass to set
or modify its contents.
- @return A pointer to a copy (clone) of the value, 0 if the value is
- not set.
+ @return An auto-pointer containing a pointer to a copy (clone) of the
+ value, 0 if the value is not set.
*/
- virtual Value* getValue() const =0;
+ virtual Value::AutoPtr getValue() const =0;
/*!
@brief Return a constant reference to the value.
diff --git a/src/value.cpp b/src/value.cpp
index 5a73b61..7623f14 100644
--- a/src/value.cpp
+++ b/src/value.cpp
@@ -20,7 +20,7 @@
*/
/*
File: value.cpp
- Version: $Name: $ $Revision: 1.14 $
+ Version: $Name: $ $Revision: 1.15 $
Author(s): Andreas Huggel (ahu) <ahuggel at gmx.net>
History: 26-Jan-04, ahu: created
11-Feb-04, ahu: isolated as a component
@@ -28,7 +28,7 @@
*/
// *****************************************************************************
#include "rcsid.hpp"
-EXIV2_RCSID("@(#) $Name: $ $Revision: 1.14 $ $RCSfile: value.cpp,v $");
+EXIV2_RCSID("@(#) $Name: $ $Revision: 1.15 $ $RCSfile: value.cpp,v $");
// *****************************************************************************
// included header files
@@ -54,54 +54,54 @@ namespace Exiv2 {
return *this;
}
- Value* Value::create(TypeId typeId)
+ Value::AutoPtr Value::create(TypeId typeId)
{
- Value* value = 0;
+ AutoPtr value;
switch (typeId) {
case invalidTypeId:
- value = new DataValue(invalidTypeId);
+ value = AutoPtr(new DataValue(invalidTypeId));
break;
case unsignedByte:
- value = new DataValue(unsignedByte);
+ value = AutoPtr(new DataValue(unsignedByte));
break;
case asciiString:
- value = new AsciiValue;
+ value = AutoPtr(new AsciiValue);
break;
case unsignedShort:
- value = new ValueType<uint16_t>;
+ value = AutoPtr(new ValueType<uint16_t>);
break;
case unsignedLong:
- value = new ValueType<uint32_t>;
+ value = AutoPtr(new ValueType<uint32_t>);
break;
case unsignedRational:
- value = new ValueType<URational>;
+ value = AutoPtr(new ValueType<URational>);
break;
case invalid6:
- value = new DataValue(invalid6);
+ value = AutoPtr(new DataValue(invalid6));
break;
case undefined:
- value = new DataValue;
+ value = AutoPtr(new DataValue);
break;
case signedShort:
- value = new ValueType<int16_t>;
+ value = AutoPtr(new ValueType<int16_t>);
break;
case signedLong:
- value = new ValueType<int32_t>;
+ value = AutoPtr(new ValueType<int32_t>);
break;
case signedRational:
- value = new ValueType<Rational>;
+ value = AutoPtr(new ValueType<Rational>);
break;
case string:
- value = new StringValue;
+ value = AutoPtr(new StringValue);
break;
case date:
- value = new DateValue;
+ value = AutoPtr(new DateValue);
break;
case time:
- value = new TimeValue;
+ value = AutoPtr(new TimeValue);
break;
default:
- value = new DataValue(typeId);
+ value = AutoPtr(new DataValue(typeId));
break;
}
return value;
@@ -151,7 +151,7 @@ namespace Exiv2 {
return static_cast<long>(value_.size());
}
- DataValue* DataValue::clone() const
+ DataValue* DataValue::clone_() const
{
return new DataValue(*this);
}
@@ -209,7 +209,7 @@ namespace Exiv2 {
return *this;
}
- StringValue* StringValue::clone() const
+ StringValue* StringValue::clone_() const
{
return new StringValue(*this);
}
@@ -234,7 +234,7 @@ namespace Exiv2 {
if (value_[value_.size()-1] != '
--
exiv2 packaging
More information about the pkg-kde-commits
mailing list