#640 Public API to reveal all namespaces known to Exiv2 and XMPsdk is XmpProperties::registeredNamespaces(Exiv2::Dictionary&)

v0.27.3
Robin Mills 10 years ago
parent 3a7b0e0122
commit ed2751612d

@ -38,6 +38,7 @@
#include "types.hpp" #include "types.hpp"
#include "metadatum.hpp" #include "metadatum.hpp"
#include "tags.hpp" #include "tags.hpp"
#include "datasets.hpp"
// + standard includes // + standard includes
#include <string> #include <string>
@ -224,6 +225,11 @@ namespace Exiv2 {
// DATA // DATA
static NsRegistry nsRegistry_; //!< Namespace registry static NsRegistry nsRegistry_; //!< Namespace registry
/*!
@brief Get all registered namespaces (for both Exiv2 and XMPsdk)
*/
static void registeredNamespaces(Exiv2::Dictionary& nsDict);
}; // class XmpProperties }; // class XmpProperties
/*! /*!

@ -36,6 +36,7 @@
#include "value.hpp" #include "value.hpp"
#include "types.hpp" #include "types.hpp"
#include "datasets.hpp" #include "datasets.hpp"
#include "properties.hpp"
// + standard includes // + standard includes
#include <string> #include <string>
@ -375,14 +376,6 @@ namespace Exiv2 {
*/ */
static void terminate(); static void terminate();
/*!
@brief object a map of registered namespaces (prefix:URI)
This will initialize the Parser if necessary
*/
static void getRegisteredNamespaces(Exiv2::Dictionary& dict);
private: private:
/*! /*!
@brief Register a namespace with the XMP Toolkit. @brief Register a namespace with the XMP Toolkit.
@ -396,11 +389,18 @@ namespace Exiv2 {
*/ */
static void unregisterNs(const std::string& ns); static void unregisterNs(const std::string& ns);
/*!
@brief Get namespaces registered with XMPsdk
*/
static void registeredNamespaces(Exiv2::Dictionary&);
// DATA // DATA
static bool initialized_; //! Indicates if the XMP Toolkit has been initialized static bool initialized_; //! Indicates if the XMP Toolkit has been initialized
static XmpLockFct xmpLockFct_; static XmpLockFct xmpLockFct_;
static void* pLockData_; static void* pLockData_;
friend class XmpProperties; // permit XmpProperties -> registerNs() and registeredNamespaces()
}; // class XmpParser }; // class XmpParser
// ***************************************************************************** // *****************************************************************************

@ -2391,6 +2391,14 @@ namespace Exiv2 {
return xn; return xn;
} }
void XmpProperties::registeredNamespaces(Exiv2::Dictionary& nsDict)
{
for (unsigned int i = 0; i < EXV_COUNTOF(xmpNsInfo); ++i) {
Exiv2::XmpParser::registerNs(xmpNsInfo[i].ns_,xmpNsInfo[i].prefix_);
}
Exiv2::XmpParser::registeredNamespaces(nsDict);
}
void XmpProperties::printProperties(std::ostream& os, const std::string& prefix) void XmpProperties::printProperties(std::ostream& os, const std::string& prefix)
{ {
const XmpPropertyInfo* pl = propertyList(prefix); const XmpPropertyInfo* pl = propertyList(prefix);

@ -532,12 +532,10 @@ void Exiv2::dumpLibraryInfo(std::ostream& os,const exv_grep_keys_t& keys)
#ifdef EXV_HAVE_XMP_TOOLKIT #ifdef EXV_HAVE_XMP_TOOLKIT
const char* name = "xmlns"; const char* name = "xmlns";
typedef std::map<std::string,std::string> dict_t;
typedef dict_t::const_iterator dict_i;
dict_t ns; Exiv2::Dictionary ns;
Exiv2::XmpParser::getRegisteredNamespaces(ns); Exiv2::XmpProperties::registeredNamespaces(ns);
for ( dict_i it = ns.begin(); it != ns.end() ; it++ ) { for ( Exiv2::Dictionary_i it = ns.begin(); it != ns.end() ; it++ ) {
std::string xmlns = (*it).first; std::string xmlns = (*it).first;
std::string uri = (*it).second; std::string uri = (*it).second;
output(os,keys,name,xmlns+":"+uri); output(os,keys,name,xmlns+":"+uri);

@ -465,12 +465,14 @@ namespace Exiv2 {
return result; return result;
} }
void XmpParser::getRegisteredNamespaces(Exiv2::Dictionary& dict) void XmpParser::registeredNamespaces(Exiv2::Dictionary& dict)
{ {
bool bInit = !initialized_; bool bInit = !initialized_;
try { try {
if (bInit) initialize(); if (bInit) initialize();
#ifdef EXV_HAVE_XMP_TOOLKIT
SXMPMeta::DumpNamespaces(nsDumper,&dict); SXMPMeta::DumpNamespaces(nsDumper,&dict);
#endif
if (bInit) terminate(); if (bInit) terminate();
} catch (const XMP_Error& e) { } catch (const XMP_Error& e) {
throw Error(40, e.GetID(), e.GetErrMsg()); throw Error(40, e.GetID(), e.GetErrMsg());
@ -484,8 +486,6 @@ namespace Exiv2 {
#ifdef EXV_HAVE_XMP_TOOLKIT #ifdef EXV_HAVE_XMP_TOOLKIT
SXMPMeta::Terminate(); SXMPMeta::Terminate();
#endif #endif
xmpLockFct_ = 0;
pLockData_ = 0;
initialized_ = false; initialized_ = false;
} }
} }

Loading…
Cancel
Save