[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a

Maximiliano Curia maxy at moszumanska.debian.org
Thu Jul 13 17:45:40 UTC 2017


Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=c396a92

The following commit has been merged in the master branch:
commit c396a92e018109d7c3cec00bace97a3b670e09bb
Author: Robin Mills <robin at clanmills.com>
Date:   Fri Aug 28 19:57:46 2015 +0000

    #960 added API: static void Exiv2::XMPParser::getRegisteredNamespaces(std::map<std::string,std::string>&);
---
 include/exiv2/xmp.hpp       |  10 +-
 samples/exiv2json.cpp       | 304 ++++++++++++++++++++++++--------------------
 src/version.cpp             |  46 ++-----
 src/xmp.cpp                 |  60 ++++++++-
 test/bugfixes-test.sh       |   4 +-
 test/data/bugfixes-test.out | Bin 1839741 -> 1835223 bytes
 6 files changed, 244 insertions(+), 180 deletions(-)

diff --git a/include/exiv2/xmp.hpp b/include/exiv2/xmp.hpp
index 00c07e2..32ee3eb 100644
--- a/include/exiv2/xmp.hpp
+++ b/include/exiv2/xmp.hpp
@@ -357,7 +357,7 @@ namespace Exiv2 {
               // Note however that this call itself is still not thread-safe.
               Exiv2::XmpParser::initialize(XmpLock::LockUnlock, &xmpLock);
 
-              // Program continues here, subsequent registrations of XMP 
+              // Program continues here, subsequent registrations of XMP
               // namespaces are serialized using xmpLock.
 
           }
@@ -374,6 +374,14 @@ namespace Exiv2 {
          */
         static void terminate();
 
+        /*!
+         @brief object a map of registered namespaces
+
+         This will initialize the Parser if necessary
+         */
+        static void getRegisteredNamespaces(std::map<std::string,std::string>& dict);
+
+
     private:
         /*!
           @brief Register a namespace with the XMP Toolkit.
diff --git a/samples/exiv2json.cpp b/samples/exiv2json.cpp
index 63b7524..dcc7a94 100644
--- a/samples/exiv2json.cpp
+++ b/samples/exiv2json.cpp
@@ -3,13 +3,20 @@
 // Sample program to print metadata in JSON format
 
 #include <exiv2/exiv2.hpp>
-#include <exiv2/value.hpp>
 #include "Jzon.h"
 
 #include <iostream>
 #include <iomanip>
 #include <cassert>
 #include <string>
+#include <map>
+#include <vector>
+#include <set>
+
+#include <stdlib.h>
+#include <limits.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 
 #if defined(__MINGW32__) || defined(__MINGW64__)
 # ifndef  __MINGW__
@@ -17,11 +24,6 @@
 # endif
 #endif
 
-#include <stdlib.h>
-#include <limits.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
 #if defined(_MSC_VER) || defined(__MINGW__)
 #include <windows.h>
 #ifndef  PATH_MAX
@@ -29,112 +31,120 @@
 #endif
 const char* realpath(const char* file,char* path)
 {
-	GetFullPathName(file,PATH_MAX,path,NULL);
-	return path;
+    GetFullPathName(file,PATH_MAX,path,NULL);
+    return path;
 }
 #else
 #include <unistd.h>
 #endif
 
 struct Token {
-	std::string n; // the name eg "History"
-	bool        a; // name is an array eg History[]
-	int         i; // index (indexed from 1) eg History[1]/stEvt:action
+    std::string n; // the name eg "History"
+    bool        a; // name is an array eg History[]
+    int         i; // index (indexed from 1) eg History[1]/stEvt:action
 };
-typedef std::vector<Token> Tokens ;
+typedef std::vector<Token>    Tokens;
+typedef std::set<std::string> Namespaces;
 
 // "XMP.xmp.MP.RegionInfo/MPRI:Regions[1]/MPReg:Rectangle"
-bool getToken(std::string& in,Token& token)
+bool getToken(std::string& in,Token& token,Namespaces* pNS=NULL)
 {
-	bool result = false;
-
-	token.n = ""    ;
-	token.a = false ;
-	token.i = 0     ;
-
-	while ( !result && in.length() ) {
-		std::string c = in.substr(0,1);
-		char        C = c[0];
-		in            = in.substr(1,std::string::npos);
-		if ( in.length() == 0 && C != ']' )	token.n += c;
-		if ( C == '/' || C == '[' || C == ':' || C == '.' || C == ']' || in.length() == 0 ) {
-			token.a   = C == '[';
-			if ( C == ']' ) token.i = std::atoi(token.n.c_str()); // encoded string first index == 1
-			result    = token.n.length() > 0 ;
-		}  else {
-			token.n   += c;
-		}
-	}
-	return result;
+    bool result = false;
+    bool ns     = false;
+
+    token.n = ""    ;
+    token.a = false ;
+    token.i = 0     ;
+
+    while ( !result && in.length() ) {
+        std::string c = in.substr(0,1);
+        char        C = c[0];
+        in            = in.substr(1,std::string::npos);
+        if ( in.length() == 0 && C != ']' ) token.n += c;
+        if ( C == '/' || C == '[' || C == ':' || C == '.' || C == ']' || in.length() == 0 ) {
+            ns        |= C == '/' ;
+            token.a    = C == '[' ;
+            if (         C == ']' ) token.i = std::atoi(token.n.c_str()); // encoded string first index == 1
+            result     = token.n.length() > 0 ;
+        }  else {
+            token.n   += c;
+        }
+    }
+    if (ns && pNS) pNS->insert(token.n);
+
+    return result;
 }
 
 Jzon::Node& addToTree(Jzon::Node& r1,Token token)
 {
-	Jzon::Object object ;
-	Jzon::Array  array  ;
-
-	std::string  key    = token.n  ;
-	size_t       index  = token.i-1; // array Eg: "History[1]" indexed from 1.  Jzon expects 0 based index.
-	Jzon::Node&  empty  = token.a ? (Jzon::Node&) array : (Jzon::Node&) object ;
-
-	if (  r1.IsObject() ) {
-		Jzon::Object& o1 = r1.AsObject();
-		if (   !o1.Has(key) ) o1.Add(key,empty);
-		return  o1.Get(key);
-	} else if ( r1.IsArray() ) {
-		Jzon::Array& a1 = r1.AsArray();
-		while ( a1.GetCount() <= index ) a1.Add(empty);
-		return  a1.Get(index);
-	}
-	return r1;
+    Jzon::Object object ;
+    Jzon::Array  array  ;
+
+    std::string  key    = token.n  ;
+    size_t       index  = token.i-1; // array Eg: "History[1]" indexed from 1.  Jzon expects 0 based index.
+    Jzon::Node&  empty  = token.a ? (Jzon::Node&) array : (Jzon::Node&) object ;
+
+    if (  r1.IsObject() ) {
+        Jzon::Object& o1 = r1.AsObject();
+        if (   !o1.Has(key) ) o1.Add(key,empty);
+        return  o1.Get(key);
+    } else if ( r1.IsArray() ) {
+        Jzon::Array& a1 = r1.AsArray();
+        while ( a1.GetCount() <= index ) a1.Add(empty);
+        return  a1.Get(index);
+    }
+    return r1;
 }
 
 Jzon::Node& recursivelyBuildTree(Jzon::Node& root,Tokens& tokens,size_t k)
 {
-	return addToTree( k==0 ? root : recursivelyBuildTree(root,tokens,k-1), tokens[k] );
+    return addToTree( k==0 ? root : recursivelyBuildTree(root,tokens,k-1), tokens[k] );
 }
 
 // build the json tree for this key.  return location and discover the name
-Jzon::Node& objectForKey(const std::string Key,Jzon::Object& root,std::string& name)
+Jzon::Node& objectForKey(const std::string Key,Jzon::Object& root,std::string& name,Namespaces* pNS=NULL)
 {
     // Parse the key
     Tokens      tokens ;
     Token       token  ;
     std::string input  = Key ; // Example: "XMP.xmp.MP.RegionInfo/MPRI:Regions[1]/MPReg:Rectangle"
-    while ( getToken(input,token) ) tokens.push_back(token);
-	size_t      l      = tokens.size()-1; // leave leaf name to push()
-	name               = tokens[l].n ;
-	return recursivelyBuildTree(root,tokens,l-1);
+    while ( getToken(input,token,pNS) ) tokens.push_back(token);
+    size_t      l      = tokens.size()-1; // leave leaf name to push()
+    name               = tokens[l].n ;
+
+    // The second token.  For example: XMP.dc is a namespace
+    if ( pNS && tokens.size() > 1 ) pNS->insert(tokens[1].n);
+    return recursivelyBuildTree(root,tokens,l-1);
 
 #if 0
-	// recursivelyBuildTree:
-	// Go to the root.  Climb out adding objects or arrays to create the tree
-	// The leaf is pushed on the top by the caller of objectForKey()
-	// The recursion could be expressed by these if statements:
-	if ( l == 1 ) return                               addToTree(root,tokens[0]);
-	if ( l == 2 ) return                     addToTree(addToTree(root,tokens[0]),tokens[1]);
-	if ( l == 3 ) return           addToTree(addToTree(addToTree(root,tokens[0]),tokens[1]),tokens[2]);
-	if ( l == 4 ) return addToTree(addToTree(addToTree(addToTree(root,tokens[0]),tokens[1]),tokens[2]),tokens[3]);
-	...
+    // recursivelyBuildTree:
+    // Go to the root.  Climb out adding objects or arrays to create the tree
+    // The leaf is pushed on the top by the caller of objectForKey()
+    // The recursion could be expressed by these if statements:
+    if ( l == 1 ) return                               addToTree(root,tokens[0]);
+    if ( l == 2 ) return                     addToTree(addToTree(root,tokens[0]),tokens[1]);
+    if ( l == 3 ) return           addToTree(addToTree(addToTree(root,tokens[0]),tokens[1]),tokens[2]);
+    if ( l == 4 ) return addToTree(addToTree(addToTree(addToTree(root,tokens[0]),tokens[1]),tokens[2]),tokens[3]);
+    ...
 #endif
 }
 
 bool isObject(std::string& value)
 {
-	return !value.compare(std::string("type=\"Struct\""));
+    return !value.compare(std::string("type=\"Struct\""));
 }
 
 bool isArray(std::string& value)
 {
-	return !value.compare(std::string("type=\"Seq\""))
-	||     !value.compare(std::string("type=\"Bag\""))
-	||     !value.compare(std::string("type=\"Alt\""))
-	;
+    return !value.compare(std::string("type=\"Seq\""))
+    ||     !value.compare(std::string("type=\"Bag\""))
+    ||     !value.compare(std::string("type=\"Alt\""))
+    ;
 }
 
 #define STORE(node,key,value) \
- 	if  (node.IsObject()) node.AsObject().Add(key,value);\
- 	else                  node.AsArray() .Add(    value)
+    if  (node.IsObject()) node.AsObject().Add(key,value);\
+    else                  node.AsArray() .Add(    value)
 
 template <class T>
 void push(Jzon::Node& node,const std::string& key,T i)
@@ -143,16 +153,16 @@ void push(Jzon::Node& node,const std::string& key,T i)
 
     switch ( i->typeId() ) {
         case Exiv2::xmpText:
-			 if (        ::isObject(value) ) {
-				 Jzon::Object   v;
-				 STORE(node,key,v);
-			 } else if ( ::isArray(value) ) {
-				 Jzon::Array    v;
-				 STORE(node,key,v);
-			 } else {
-				 STORE(node,key,value);
-			 }
-    	break;
+             if (        ::isObject(value) ) {
+                 Jzon::Object   v;
+                 STORE(node,key,v);
+             } else if ( ::isArray(value) ) {
+                 Jzon::Array    v;
+                 STORE(node,key,v);
+             } else {
+                 STORE(node,key,value);
+             }
+        break;
 
         case Exiv2::unsignedByte:
         case Exiv2::unsignedShort:
@@ -160,12 +170,12 @@ void push(Jzon::Node& node,const std::string& key,T i)
         case Exiv2::signedByte:
         case Exiv2::signedShort:
         case Exiv2::signedLong:
-			 STORE(node,key,std::atoi(value.c_str()) );
-	    break;
+             STORE(node,key,std::atoi(value.c_str()) );
+        break;
 
         case Exiv2::tiffFloat:
         case Exiv2::tiffDouble:
-			 STORE(node,key,std::atof(value.c_str()) );
+             STORE(node,key,std::atof(value.c_str()) );
         break;
 
         case Exiv2::unsignedRational:
@@ -174,21 +184,21 @@ void push(Jzon::Node& node,const std::string& key,T i)
              Exiv2::Rational rat = i->value().toRational();
              arr.Add(rat.first );
              arr.Add(rat.second);
-			 STORE(node,key,arr);
+             STORE(node,key,arr);
         } break;
 
         case Exiv2::langAlt: {
-        	 Jzon::Object l ;
+             Jzon::Object l ;
              const Exiv2::LangAltValue& langs = dynamic_cast<const Exiv2::LangAltValue&>(i->value());
-        	 for ( Exiv2::LangAltValue::ValueType::const_iterator lang = langs.value_.begin()
-        	     ; lang != langs.value_.end()
-        	     ; lang++
-        	 ) {
-        	 	l.Add(lang->first,lang->second);
-        	 }
-        	 Jzon::Object o ;
-        	 o.Add("lang",l);
-        	 STORE(node,key,o);
+             for ( Exiv2::LangAltValue::ValueType::const_iterator lang = langs.value_.begin()
+                 ; lang != langs.value_.end()
+                 ; lang++
+             ) {
+                l.Add(lang->first,lang->second);
+             }
+             Jzon::Object o ;
+             o.Add("lang",l);
+             STORE(node,key,o);
         }
         break;
 
@@ -207,11 +217,11 @@ void push(Jzon::Node& node,const std::string& key,T i)
              // http://dev.exiv2.org/boards/3/topics/1367#message-1373
              if ( key == "UserComment" ) {
                 size_t pos  = value.find('

-- 
exiv2 packaging



More information about the pkg-kde-commits mailing list