Project

General

Profile

XmpParser::registerNs calls unimplemented method SXMPMeta::DeleteNamespace

Added by Anonymous Poster almost 4 years ago

There is an SXMPMeta::DeleteNamespace call in XmpParser::registerNs (xmp.cpp). That method just throws an exception. I believe it's an error in exiv2 and the fix seems to be simply commenting out that line. In fact, there's a second mention of DeleteNamespace in xmp.cpp where this call is commented out with a proper comment.


Replies (1)

RE: XmpParser::registerNs calls unimplemented method SXMPMeta::DeleteNamespace - Added by Robin Mills almost 4 years ago

I'm not convinced there is a problem here. May I ask you to provide a test case when you raise an issue in the code. It makes it so much easier to be "on the same page" as you. You could very well be raising a real issue here, however I'm spending (unproductive) time scratching my head wondering "What is he banging on about?". Help us to help you.

I've modified xmp.cpp as follows:

    void XmpParser::registerNs(const std::string& ns,
                               const std::string& prefix)
    {
        try {
            initialize();
            AutoLock autoLock(xmpLockFct_, pLockData_);
            std::cout << "about to call SXMPMeta::DeleteNamespace"  << std::endl;
            SXMPMeta::DeleteNamespace(ns.c_str());
            SXMPMeta::RegisterNamespace(ns.c_str(), prefix.c_str());
        }
        catch (const XMP_Error& e) {
            throw Error(40, e.GetID(), e.GetErrMsg());
        }
    } // XmpParser::registerNs
And XMPMeta.cpp as follows:
#include <iostream>
#include <algorithm>
#include <cassert>
#include <string>
/* class-static */ void
XMPMeta::DeleteNamespace ( XMP_StringPtr namespaceURI )
{
    std::cout << "In XMPMeta::DeleteNamespace"  << std::endl;
    XMP_StringMapPos uriPos = sNamespaceURIToPrefixMap->find ( namespaceURI );
    if ( uriPos == sNamespaceURIToPrefixMap->end() ) return;

    XMP_StringMapPos prefixPos = sNamespacePrefixToURIMap->find ( uriPos->second );
    XMP_Assert ( prefixPos != sNamespacePrefixToURIMap->end() );

    sNamespaceURIToPrefixMap->erase ( uriPos );
    sNamespacePrefixToURIMap->erase ( prefixPos );

}    // DeleteNamespace
And ran this test:
733 rmills@rmillsmbp:~/gnu/exiv2/trunk $ exiv2 -M"reg cm http://clanmills.com" ~/Downloads/Stonehenge.jpg
about to call SXMPMeta::DeleteNamespace
In XMPMeta::DeleteNamespace
734 rmills@rmillsmbp:~/gnu/exiv2/trunk $ 
I don't know anything about the following commented off code in xmp.cpp. It seems to me that the comment (and the commenting off) is incorrect. However I never modify code without a solid test case, so I'm going to leave it.
    void XmpParser::unregisterNs(const std::string& /*ns*/)
    {
#ifdef EXV_HAVE_XMP_TOOLKIT
        try {
// Throws XMP Toolkit error 8: Unimplemented method XMPMeta::DeleteNamespace
//          SXMPMeta::DeleteNamespace(ns.c_str());
        }
        catch (const XMP_Error& e) {
            throw Error(40, e.GetID(), e.GetErrMsg());
        }
#endif
    } // XmpParser::unregisterNs

    (1-1/1)