Skip to content

Commit

Permalink
Make XmpData::eraseFamily usable
Browse files Browse the repository at this point in the history
  • Loading branch information
jim-easterbrook committed Jan 12, 2024
1 parent 6a9e563 commit 5f87dc4
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 31 deletions.
15 changes: 15 additions & 0 deletions src/interface/xmp.i
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@ static Exiv2::TypeId get_type_id(Exiv2::Xmpdatum* datum) {
};
}

// XmpData::eraseFamily takes an iterator reference (and invalidates it)
%typemap(in) Exiv2::XmpData::iterator& (Exiv2::XmpData::iterator it) {
XmpData_iterator_base* argp = NULL;
int res = SWIG_ConvertPtr(
$input, (void**)&argp, $descriptor(XmpData_iterator_base*), 0);
if (!SWIG_IsOK(res)) {
%argument_fail(res, XmpData_iterator_base, $symname, $argnum);
}
if (!argp) {
%argument_nullref(XmpData_iterator_base, $symname, $argnum);
}
it = **argp;
$1 = ⁢
}

DATA_CONTAINER(Exiv2::XmpData, Exiv2::Xmpdatum, Exiv2::XmpKey)

// Ignore const overloads of some methods
Expand Down
22 changes: 13 additions & 9 deletions src/swig-0_27_0/xmp_wrap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8288,8 +8288,7 @@ SWIGINTERN PyObject *_wrap_XmpData_eraseFamily(PyObject *self, PyObject *args) {
Exiv2::XmpData::iterator *arg2 = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
void *argp2 = 0 ;
int res2 = 0 ;
Exiv2::XmpData::iterator it2 ;
PyObject *swig_obj[2] ;

if (!args) SWIG_fail;
Expand All @@ -8299,14 +8298,19 @@ SWIGINTERN PyObject *_wrap_XmpData_eraseFamily(PyObject *self, PyObject *args) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XmpData_eraseFamily" "', argument " "1"" of type '" "Exiv2::XmpData *""'");
}
arg1 = reinterpret_cast< Exiv2::XmpData * >(argp1);
res2 = SWIG_ConvertPtr(swig_obj[0], &argp2, SWIGTYPE_p_std__vectorT_Exiv2__Xmpdatum_std__allocatorT_Exiv2__Xmpdatum_t_t__iterator, 0 );
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XmpData_eraseFamily" "', argument " "2"" of type '" "Exiv2::XmpData::iterator &""'");
}
if (!argp2) {
SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "XmpData_eraseFamily" "', argument " "2"" of type '" "Exiv2::XmpData::iterator &""'");
{
XmpData_iterator_base* argp = NULL;
int res = SWIG_ConvertPtr(
swig_obj[0], (void**)&argp, SWIGTYPE_p_XmpData_iterator_base, 0);
if (!SWIG_IsOK(res)) {
SWIG_exception_fail(SWIG_ArgError(res), "in method '" "XmpData_eraseFamily" "', argument " "2"" of type '" "XmpData_iterator_base""'");
}
if (!argp) {
SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "XmpData_eraseFamily" "', argument " "2"" of type '" "XmpData_iterator_base""'");
}
it2 = **argp;
arg2 = &it2;
}
arg2 = reinterpret_cast< Exiv2::XmpData::iterator * >(argp2);
{
try {
(arg1)->eraseFamily(*arg2);
Expand Down
22 changes: 13 additions & 9 deletions src/swig-0_27_4/xmp_wrap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8288,8 +8288,7 @@ SWIGINTERN PyObject *_wrap_XmpData_eraseFamily(PyObject *self, PyObject *args) {
Exiv2::XmpData::iterator *arg2 = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
void *argp2 = 0 ;
int res2 = 0 ;
Exiv2::XmpData::iterator it2 ;
PyObject *swig_obj[2] ;

if (!args) SWIG_fail;
Expand All @@ -8299,14 +8298,19 @@ SWIGINTERN PyObject *_wrap_XmpData_eraseFamily(PyObject *self, PyObject *args) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XmpData_eraseFamily" "', argument " "1"" of type '" "Exiv2::XmpData *""'");
}
arg1 = reinterpret_cast< Exiv2::XmpData * >(argp1);
res2 = SWIG_ConvertPtr(swig_obj[0], &argp2, SWIGTYPE_p_std__vectorT_Exiv2__Xmpdatum_std__allocatorT_Exiv2__Xmpdatum_t_t__iterator, 0 );
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XmpData_eraseFamily" "', argument " "2"" of type '" "Exiv2::XmpData::iterator &""'");
}
if (!argp2) {
SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "XmpData_eraseFamily" "', argument " "2"" of type '" "Exiv2::XmpData::iterator &""'");
{
XmpData_iterator_base* argp = NULL;
int res = SWIG_ConvertPtr(
swig_obj[0], (void**)&argp, SWIGTYPE_p_XmpData_iterator_base, 0);
if (!SWIG_IsOK(res)) {
SWIG_exception_fail(SWIG_ArgError(res), "in method '" "XmpData_eraseFamily" "', argument " "2"" of type '" "XmpData_iterator_base""'");
}
if (!argp) {
SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "XmpData_eraseFamily" "', argument " "2"" of type '" "XmpData_iterator_base""'");
}
it2 = **argp;
arg2 = &it2;
}
arg2 = reinterpret_cast< Exiv2::XmpData::iterator * >(argp2);
{
try {
(arg1)->eraseFamily(*arg2);
Expand Down
22 changes: 13 additions & 9 deletions src/swig-0_28_0/xmp_wrap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8603,8 +8603,7 @@ SWIGINTERN PyObject *_wrap_XmpData_eraseFamily(PyObject *self, PyObject *args) {
Exiv2::XmpData::iterator *arg2 = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
void *argp2 = 0 ;
int res2 = 0 ;
Exiv2::XmpData::iterator it2 ;
PyObject *swig_obj[2] ;

if (!args) SWIG_fail;
Expand All @@ -8614,14 +8613,19 @@ SWIGINTERN PyObject *_wrap_XmpData_eraseFamily(PyObject *self, PyObject *args) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XmpData_eraseFamily" "', argument " "1"" of type '" "Exiv2::XmpData *""'");
}
arg1 = reinterpret_cast< Exiv2::XmpData * >(argp1);
res2 = SWIG_ConvertPtr(swig_obj[0], &argp2, SWIGTYPE_p_std__vectorT_Exiv2__Xmpdatum_std__allocatorT_Exiv2__Xmpdatum_t_t__iterator, 0 );
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XmpData_eraseFamily" "', argument " "2"" of type '" "Exiv2::XmpData::iterator &""'");
}
if (!argp2) {
SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "XmpData_eraseFamily" "', argument " "2"" of type '" "Exiv2::XmpData::iterator &""'");
{
XmpData_iterator_base* argp = NULL;
int res = SWIG_ConvertPtr(
swig_obj[0], (void**)&argp, SWIGTYPE_p_XmpData_iterator_base, 0);
if (!SWIG_IsOK(res)) {
SWIG_exception_fail(SWIG_ArgError(res), "in method '" "XmpData_eraseFamily" "', argument " "2"" of type '" "XmpData_iterator_base""'");
}
if (!argp) {
SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "XmpData_eraseFamily" "', argument " "2"" of type '" "XmpData_iterator_base""'");
}
it2 = **argp;
arg2 = &it2;
}
arg2 = reinterpret_cast< Exiv2::XmpData::iterator * >(argp2);
{
try {
(arg1)->eraseFamily(*arg2);
Expand Down
13 changes: 9 additions & 4 deletions tests/test_xmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ def test_XmpData(self):
k = data.erase(k)
self.assertIsInstance(k, exiv2.XmpData_iterator)
self.assertEqual(k.key(), 'Xmp.xmp.ModifyDate')
self.assertEqual(len(data), 27)
k = data.findKey(exiv2.XmpKey('Xmp.iptcExt.LocationCreated'))
data.eraseFamily(k)
self.assertEqual(len(data), 21)
# access by key
self.image.readMetadata()
self.assertEqual('Xmp.dc.creator' in data, True)
self.assertIsInstance(data['Xmp.dc.creator'], exiv2.Xmpdatum)
del data['Xmp.dc.creator']
Expand All @@ -89,18 +94,18 @@ def test_XmpData(self):
while b != e:
next(b)
count += 1
self.assertEqual(count, 27)
self.assertEqual(count, 26)
count = 0
for d in data:
count += 1
self.assertEqual(count, 27)
self.assertEqual(count, 26)
count = len(list(data))
self.assertEqual(count, 27)
self.assertEqual(count, 26)
# sorting
data.sortByKey()
self.assertEqual(data.begin().key(), 'Xmp.dc.creator')
# other methods
self.assertEqual(data.count(), 27)
self.assertEqual(data.count(), 26)
self.assertEqual(data.empty(), False)
data.clear()
self.assertEqual(len(data), 0)
Expand Down

0 comments on commit 5f87dc4

Please sign in to comment.