#600: Upgrading XMP-Toolkit to version 4.4; re-applied the changes done previously. (STILL DOESN'T COMPILE)

This commit is contained in:
Andreas Huggel
2009-07-07 14:13:03 +00:00
parent 73aa0f4fda
commit 4359702117
19 changed files with 61 additions and 106 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
#define __TXMPIterator_hpp__ 1
#if ( ! __XMP_hpp__ )
#error "Do not directly include, use XMP.hpp"
#error "Do not directly include, use XMPSDK.hpp"
#endif
// =================================================================================================
+1 -1
View File
@@ -2,7 +2,7 @@
#define __TXMPMeta_hpp__ 1
#if ( ! __XMP_hpp__ )
#error "Do not directly include, use XMP.hpp"
#error "Do not directly include, use XMPSDK.hpp"
#endif
// =================================================================================================
+1 -1
View File
@@ -2,7 +2,7 @@
#define __TXMPUtils_hpp__ 1
#if ( ! __XMP_hpp__ )
#error "Do not directly include, use XMP.hpp"
#error "Do not directly include, use XMPSDK.hpp"
#endif
// =================================================================================================
+1 -5
View File
@@ -28,7 +28,7 @@
/// \endcode
#include "XMP.hpp" // ! This must be the first include!
#include "XMPSDK.hpp" // ! This must be the first include!
#define XMP_ClientBuild 1
@@ -53,10 +53,6 @@
template class TXMPMeta <TXMP_STRING_TYPE>;
template class TXMPIterator <TXMP_STRING_TYPE>;
template class TXMPUtils <TXMP_STRING_TYPE>;
#if XMP_INCLUDE_XMPFILES
#include "client-glue/TXMPFiles.incl_cpp"
template class TXMPFiles <TXMP_STRING_TYPE>;
#endif
#endif
+1 -10
View File
@@ -10,7 +10,7 @@
// =================================================================================================
// ================================================================================================
/// \file XMP.hpp
/// \file XMPSDK.hpp
/// \brief Overall header file for the XMP Toolkit
///
/// This is an overall header file, the only one that C++ clients should include.
@@ -76,17 +76,8 @@
#include "client-glue/TXMPMeta.incl_cpp"
#include "client-glue/TXMPIterator.incl_cpp"
#include "client-glue/TXMPUtils.incl_cpp"
#include "client-glue/TXMPFiles.incl_cpp"
#endif
#if XMP_INCLUDE_XMPFILES
#include "TXMPFiles.hpp" // ! Needs typedef for SXMPMeta.
typedef class TXMPFiles <TXMP_STRING_TYPE> SXMPFiles;
#if TXMP_EXPAND_INLINE
#include "client-glue/TXMPFiles.incl_cpp"
#endif
#endif
#endif // TXMP_STRING_TYPE
#if XMP_WinBuild
+17
View File
@@ -26,6 +26,23 @@
// requires these to be defined without values, they are only used here to define XMP-specific
// macros with 0 or 1 values.
/* 20-Oct-07, ahu: Determine the platform, set the above defines accordingly. */
#define _FILE_OFFSET_BITS 64
#if defined __CYGWIN32__ && !defined __CYGWIN__
/* For backwards compatibility with Cygwin b19 and
earlier, we define __CYGWIN__ here, so that
we can rely on checking just for that macro. */
# define __CYGWIN__ __CYGWIN32__
#endif
#if defined WIN32 && !defined __CYGWIN__
# define WIN_ENV 1
/* Todo: How to correctly recognize a Mac platform? */
#elif defined macintosh || defined MACOS_CLASSIC || defined MACOS_X_UNIX || defined MACOS_X || defined MACOS
# define MAC_ENV 1
#else
# define UNIX_ENV 1
#endif
// ! Tempting though it might be to have a standard macro for big or little endian, there seems to
// ! be no decent way to do that on our own in UNIX. Forcing it on the client isn't acceptable.
+1 -1
View File
@@ -38,7 +38,7 @@ versions.
#define XMP_API_VERSION_MICRO 0
#define XMP_API_VERSION 4.4
#define XMP_API_VERSION_STRING "4.4.0"
#define XMP_API_VERSION_STRING "4.4.0-Exiv2"
/* ============================================================================================= */
@@ -11,7 +11,7 @@
/// \file TXMPIterator.incl_cpp
/// \brief The implementation of the TXMPIterator template class.
#include "XMP.hpp"
#include "XMPSDK.hpp"
#include "client-glue/WXMP_Common.hpp"
#include "client-glue/WXMPIterator.hpp"
+1 -1
View File
@@ -11,7 +11,7 @@
/// \file TXMPMeta.incl_cpp
/// \brief The implementation of the TXMPMeta template class.
#include "XMP.hpp"
#include "XMPSDK.hpp"
#include "client-glue/WXMP_Common.hpp"
#include "client-glue/WXMPMeta.hpp"
@@ -11,7 +11,7 @@
/// \file TXMPUtils.incl_cpp
/// \brief The implementation of the TXMPUtils template class.
#include "XMP.hpp"
#include "XMPSDK.hpp"
#include "client-glue/WXMP_Common.hpp"
#include "client-glue/WXMPUtils.hpp"
-48
View File
@@ -318,21 +318,6 @@ IsCoreSyntaxTerm ( RDFTermKind term )
} // IsCoreSyntaxTerm
// -------------------------------------------------------------------------------------------------
// IsSyntaxTerm
// ------------
//
// 7.2.3 syntaxTerms
// coreSyntaxTerms | rdf:Description | rdf:li
static bool
IsSyntaxTerm ( RDFTermKind term )
{
if ( (kRDFTerm_FirstSyntax <= term) && (term <= kRDFTerm_LastSyntax) ) return true;
return false;
} // IsSyntaxTerm
// -------------------------------------------------------------------------------------------------
// IsOldTerm
@@ -350,22 +335,6 @@ IsOldTerm ( RDFTermKind term )
} // IsOldTerm
// -------------------------------------------------------------------------------------------------
// IsNodeElementName
// -----------------
//
// 7.2.5 nodeElementURIs
// anyURI - ( coreSyntaxTerms | rdf:li | oldTerms )
static bool
IsNodeElementName ( RDFTermKind term )
{
if ( (term == kRDFTerm_li) || IsOldTerm ( term ) ) return false;
return (! IsCoreSyntaxTerm ( term ));
} // IsNodeElementName
// -------------------------------------------------------------------------------------------------
// IsPropertyElementName
// ---------------------
@@ -382,23 +351,6 @@ IsPropertyElementName ( RDFTermKind term )
} // IsPropertyElementName
// -------------------------------------------------------------------------------------------------
// IsPropertyAttributeName
// -----------------------
//
// 7.2.7 propertyAttributeURIs
// anyURI - ( coreSyntaxTerms | rdf:Description | rdf:li | oldTerms )
static bool
IsPropertyAttributeName ( RDFTermKind term )
{
if ( (term == kRDFTerm_Description) || (term == kRDFTerm_li) || IsOldTerm ( term ) ) return false;
return (! IsCoreSyntaxTerm ( term ));
} // IsPropertyAttributeName
// =================================================================================================
// AddChildNode
// ============
+3 -1
View File
@@ -664,6 +664,7 @@ ExpandXPath ( XMP_StringPtr schemaNS,
XMP_StringPtr qualName, nameEnd;
XMP_VarString currStep;
qualName = nameEnd = NULL;
size_t resCount = 2; // Guess at the number of steps. At least 2, plus 1 for each '/' or '['.
for ( stepEnd = propPath; *stepEnd != 0; ++stepEnd ) {
if ( (*stepEnd == '/') || (*stepEnd == '[') ) ++resCount;
@@ -1412,7 +1413,8 @@ NormalizeLangArray ( XMP_Node * array )
array->children[itemNum] = temp;
}
if ( itemLim == 2 ) array->children[1]->value = array->children[0]->value;
// 09-Oct-07, ahu: disabled to avoid unexpected behaviour
// if ( itemLim == 2 ) array->children[1]->value = array->children[0]->value;
}
+2 -1
View File
@@ -20,9 +20,10 @@
#include <map>
#include <cassert>
#include <cstring>
#if XMP_WinBuild
#include <Windows.h>
#include <windows.h>
#else
// Use pthread for both Mac and generic UNIX.
#include <pthread.h>
+3 -3
View File
@@ -156,7 +156,7 @@ AddNodeOffspring ( IterInfo & info, IterNode & iterParent, const XMP_Node * xmpP
currPath += xmpChild->name;
} else {
char buffer [32]; // AUDIT: Using sizeof(buffer) below for snprintf length is safe.
snprintf ( buffer, sizeof(buffer), "[%d]", childNum+1 ); // ! XPath indices are one-based.
snprintf ( buffer, sizeof(buffer), "[%lu]", static_cast<unsigned long>(childNum+1) ); // ! XPath indices are one-based.
currPath += buffer;
}
iterParent.children.push_back ( IterNode ( xmpChild->options, currPath, leafOffset ) );
@@ -422,7 +422,7 @@ XMPIterator::Unlock ( XMP_OptionBits options )
XMPIterator::XMPIterator ( const XMPMeta & xmpObj,
XMP_StringPtr schemaNS,
XMP_StringPtr propName,
XMP_OptionBits options ) : info(IterInfo(options,&xmpObj)), clientRefs(0)
XMP_OptionBits options ) : clientRefs(0), info(IterInfo(options,&xmpObj))
{
if ( (options & kXMP_IterClassMask) != kXMP_IterProperties ) {
XMP_Throw ( "Unsupported iteration kind", kXMPErr_BadOptions );
@@ -574,7 +574,7 @@ XMPIterator::XMPIterator ( const XMPMeta & xmpObj,
XMPIterator::XMPIterator ( XMP_StringPtr schemaNS,
XMP_StringPtr propName,
XMP_OptionBits options ) : info(IterInfo(options,0)), clientRefs(0)
XMP_OptionBits options ) : clientRefs(0), info(IterInfo(options,0))
{
XMP_Throw ( "Unimplemented XMPIterator constructor for global tables", kXMPErr_Unimplemented );
+1 -1
View File
@@ -706,7 +706,7 @@ TouchUpDataModel ( XMPMeta * xmp )
// Do a special case fix for dc:subject, make sure it is an unordered array.
XMP_Node * dcSubject = FindChildNode ( currSchema, "dc:subject", kXMP_ExistingOnly );
if ( dcSubject != 0 ) {
XMP_OptionBits keepMask = ~(kXMP_PropArrayIsOrdered | kXMP_PropArrayIsAlternate | kXMP_PropArrayIsAltText);
XMP_OptionBits keepMask = static_cast<XMP_OptionBits>(~(kXMP_PropArrayIsOrdered | kXMP_PropArrayIsAlternate | kXMP_PropArrayIsAltText));
dcSubject->options &= keepMask; // Make sure any ordered array bits are clear.
}
}
-11
View File
@@ -43,8 +43,6 @@ using namespace std;
static const char * kPacketHeader = "<?xpacket begin=\"\xEF\xBB\xBF\" id=\"W5M0MpCehiHzreSzNTczkc9d\"?>";
static const char * kPacketTrailer = "<?xpacket end=\"w\"?>"; // ! The w/r is at [size-4].
static const char * kPXMP_SchemaGroup = "XMP_SchemaGroup";
static const char * kRDF_XMPMetaStart = "<x:xmpmeta xmlns:x=\"adobe:ns:meta/\" x:xmptk=\"";
static const char * kRDF_XMPMetaEnd = "</x:xmpmeta>";
@@ -58,19 +56,10 @@ static const char * kRDF_StructStart = "<rdf:Description>";
static const char * kRDF_StructEnd = "</rdf:Description>";
static const char * kRDF_BagStart = "<rdf:Bag>";
static const char * kRDF_BagEnd = "</rdf:Bag>";
static const char * kRDF_SeqStart = "<rdf:Seq>";
static const char * kRDF_SeqEnd = "</rdf:Seq>";
static const char * kRDF_AltStart = "<rdf:Alt>";
static const char * kRDF_AltEnd = "</rdf:Alt>";
static const char * kRDF_ItemStart = "<rdf:li>";
static const char * kRDF_ItemEnd = "</rdf:li>";
static const char * kRDF_ValueStart = "<rdf:value>";
static const char * kRDF_ValueEnd = "</rdf:value>";
// =================================================================================================
+9 -6
View File
@@ -24,6 +24,8 @@
#include <algorithm> // For sort and stable_sort.
#include <stdio.h> // For snprintf.
#include <cstdio>
#if XMP_DebugBuild
#include <iostream>
#endif
@@ -80,10 +82,10 @@ static const char * kTenSpaces = " ";
#define OutProcString(str) { status = (*outProc) ( refCon, (str).c_str(), (str).size() ); if ( status != 0 ) goto EXIT; }
#define OutProcDecInt(num) { snprintf ( buffer, sizeof(buffer), "%d", (num) ); /* AUDIT: Using sizeof for snprintf length is safe */ \
#define OutProcULong(num) { snprintf ( buffer, sizeof(buffer), "%lu", (num) ); /* AUDIT: Using sizeof for snprintf length is safe */ \
status = (*outProc) ( refCon, buffer, strlen(buffer) ); if ( status != 0 ) goto EXIT; }
#define OutProcHexInt(num) { snprintf ( buffer, sizeof(buffer), "%X", (num) ); /* AUDIT: Using sizeof for snprintf length is safe */ \
#define OutProcHexInt(num) { snprintf ( buffer, sizeof(buffer), "%lX", (num) ); /* AUDIT: Using sizeof for snprintf length is safe */ \
status = (*outProc) ( refCon, buffer, strlen(buffer) ); if ( status != 0 ) goto EXIT; }
#define OutProcHexByte(num) { snprintf ( buffer, sizeof(buffer), "%.2X", (num) ); /* AUDIT: Using sizeof for snprintf length is safe */ \
@@ -273,7 +275,7 @@ DumpPropertyTree ( const XMP_Node * currNode,
DumpClearString ( currNode->name, outProc, refCon );
} else {
OutProcNChars ( "[", 1 );
OutProcDecInt ( itemIndex );
OutProcULong ( static_cast<unsigned long>(itemIndex) );
OutProcNChars ( "]", 1 );
}
@@ -580,7 +582,7 @@ SortWithinOffspring ( XMP_NodeOffspring & nodeVec )
// ============
XMPMeta::XMPMeta() : tree(XMP_Node(0,"",0)), clientRefs(0), prevTkVer(0), xmlParser(0)
XMPMeta::XMPMeta() : clientRefs(0), prevTkVer(0), tree(XMP_Node(0,"",0)), xmlParser(0)
{
// Nothing more to do, clientRefs is incremented in wrapper.
#if XMP_TraceCTorDTor
@@ -722,8 +724,9 @@ XMPMeta::Initialize()
(void) RegisterNamespace ( "adobe:ns:meta/", "x", &voidPtr, &voidLen );
(void) RegisterNamespace ( "http://ns.adobe.com/iX/1.0/", "iX", &voidPtr, &voidLen );
XMPMeta::RegisterStandardAliases ( "" );
// 06-Oct-07, ahu: Do not use aliases. They result in unexpected behaviour.
// XMPMeta::RegisterStandardAliases ( "" );
// Initialize the other core classes.
+1 -1
View File
@@ -407,7 +407,7 @@ public:
private:
// ! These are hidden on purpose:
XMPMeta ( const XMPMeta & /* original */ ) : tree(XMP_Node(0,"",0)), clientRefs(0), prevTkVer(0), xmlParser(0)
XMPMeta ( const XMPMeta & /* original */ ) : clientRefs(0), prevTkVer(0), tree(XMP_Node(0,"",0)), xmlParser(0)
{ XMP_Throw ( "Call to hidden constructor", kXMPErr_InternalFailure ); };
void operator= ( const XMPMeta & /* rhs */ )
{ XMP_Throw ( "Call to hidden operator=", kXMPErr_InternalFailure ); };
+16 -12
View File
@@ -389,21 +389,21 @@ static void FormatFullDateTime ( XMP_DateTime & tempDate, char * buffer, size_t
// Output YYYY-MM-DDThh:mmTZD.
snprintf ( buffer, bufferLen, "%.4d-%02d-%02dT%02d:%02d", // AUDIT: Callers pass sizeof(buffer).
tempDate.year, tempDate.month, tempDate.day, tempDate.hour, tempDate.minute );
static_cast<int>(tempDate.year), static_cast<int>(tempDate.month), static_cast<int>(tempDate.day), static_cast<int>(tempDate.hour), static_cast<int>(tempDate.minute) );
} else if ( tempDate.nanoSecond == 0 ) {
// Output YYYY-MM-DDThh:mm:ssTZD.
snprintf ( buffer, bufferLen, "%.4d-%02d-%02dT%02d:%02d:%02d", // AUDIT: Callers pass sizeof(buffer).
tempDate.year, tempDate.month, tempDate.day,
tempDate.hour, tempDate.minute, tempDate.second );
static_cast<int>(tempDate.year), static_cast<int>(tempDate.month), static_cast<int>(tempDate.day),
static_cast<int>(tempDate.hour), static_cast<int>(tempDate.minute), static_cast<int>(tempDate.second) );
} else {
// Output YYYY-MM-DDThh:mm:ss.sTZD.
snprintf ( buffer, bufferLen, "%.4d-%02d-%02dT%02d:%02d:%02d.%09d", // AUDIT: Callers pass sizeof(buffer).
tempDate.year, tempDate.month, tempDate.day,
tempDate.hour, tempDate.minute, tempDate.second, tempDate.nanoSecond );
static_cast<int>(tempDate.year), static_cast<int>(tempDate.month), static_cast<int>(tempDate.day),
static_cast<int>(tempDate.hour), static_cast<int>(tempDate.minute), static_cast<int>(tempDate.second), static_cast<int>(tempDate.nanoSecond) );
for ( size_t i = strlen(buffer)-1; buffer[i] == '0'; --i ) buffer[i] = 0; // Trim excess digits.
}
@@ -600,7 +600,7 @@ static size_t MoveLargestProperty ( XMPMeta & stdXMP, XMPMeta * extXMP, PropSize
printf ( " Move %s, %d bytes\n", propName, propSize );
#endif
bool moved = MoveOneProperty ( stdXMP, extXMP, schemaURI, propName );
bool moved = MoveOneProperty ( stdXMP, extXMP, schemaURI, propName );
XMP_Assert ( moved );
propSizes.erase ( lastPos );
@@ -703,7 +703,7 @@ XMPUtils::ComposeArrayItemPath ( XMP_StringPtr schemaNS,
if ( itemIndex != kXMP_ArrayLastItem ) {
// AUDIT: Using string->size() for the snprintf length is safe.
snprintf ( const_cast<char*>(sComposedPath->c_str()), sComposedPath->size(), "%s[%d]", arrayName, itemIndex );
snprintf ( const_cast<char*>(sComposedPath->c_str()), sComposedPath->size(), "%s[%d]", arrayName, static_cast<int>(itemIndex) );
} else {
*sComposedPath = arrayName;
*sComposedPath += "[last()] ";
@@ -1063,7 +1063,7 @@ XMPUtils::ConvertFromDate ( const XMP_DateTime & binValue,
if ( (tempDate.day == 0) && (tempDate.hour == 0) && (tempDate.minute == 0) &&
(tempDate.second == 0) && (tempDate.nanoSecond == 0) &&
(tempDate.tzSign == 0) && (tempDate.tzHour == 0) && (tempDate.tzMinute == 0) ) {
snprintf ( buffer, sizeof(buffer), "%.4d", tempDate.year ); // AUDIT: Using sizeof for snprintf length is safe.
snprintf ( buffer, sizeof(buffer), "%.4d", static_cast<int>(tempDate.year) ); // AUDIT: Using sizeof for snprintf length is safe.
} else if ( (tempDate.year == 0) && (tempDate.day == 0) ) {
FormatFullDateTime ( tempDate, buffer, sizeof(buffer) );
addTimeZone = true;
@@ -1080,7 +1080,7 @@ XMPUtils::ConvertFromDate ( const XMP_DateTime & binValue,
(tempDate.tzSign != 0) || (tempDate.tzHour != 0) || (tempDate.tzMinute != 0) ) {
XMP_Throw ( "Invalid partial date, non-zeros after zero month and day", kXMPErr_BadParam);
}
snprintf ( buffer, sizeof(buffer), "%.4d-%02d", tempDate.year, tempDate.month ); // AUDIT: Using sizeof for snprintf length is safe.
snprintf ( buffer, sizeof(buffer), "%.4d-%02d", static_cast<int>(tempDate.year), static_cast<int>(tempDate.month) ); // AUDIT: Using sizeof for snprintf length is safe.
} else if ( (tempDate.hour == 0) && (tempDate.minute == 0) &&
(tempDate.second == 0) && (tempDate.nanoSecond == 0) &&
@@ -1089,7 +1089,7 @@ XMPUtils::ConvertFromDate ( const XMP_DateTime & binValue,
// Output YYYY-MM-DD.
if ( (tempDate.month < 1) || (tempDate.month > 12) ) XMP_Throw ( "Month is out of range", kXMPErr_BadParam);
if ( (tempDate.day < 1) || (tempDate.day > 31) ) XMP_Throw ( "Day is out of range", kXMPErr_BadParam);
snprintf ( buffer, sizeof(buffer), "%.4d-%02d-%02d", tempDate.year, tempDate.month, tempDate.day ); // AUDIT: Using sizeof for snprintf length is safe.
snprintf ( buffer, sizeof(buffer), "%.4d-%02d-%02d", static_cast<int>(tempDate.year), static_cast<int>(tempDate.month), static_cast<int>(tempDate.day) ); // AUDIT: Using sizeof for snprintf length is safe.
} else {
@@ -1113,7 +1113,7 @@ XMPUtils::ConvertFromDate ( const XMP_DateTime & binValue,
if ( tempDate.tzSign == 0 ) {
*sConvertedValue += 'Z';
} else {
snprintf ( buffer, sizeof(buffer), "+%02d:%02d", tempDate.tzHour, tempDate.tzMinute ); // AUDIT: Using sizeof for snprintf length is safe.
snprintf ( buffer, sizeof(buffer), "+%02d:%02d", static_cast<int>(tempDate.tzHour), static_cast<int>(tempDate.tzMinute) ); // AUDIT: Using sizeof for snprintf length is safe.
if ( tempDate.tzSign < 0 ) buffer[0] = '-';
*sConvertedValue += buffer;
}
@@ -1262,7 +1262,7 @@ XMPUtils::ConvertToFloat ( XMP_StringPtr strValue )
// Note that ISO 8601 does not seem to allow years less than 1000 or greater than 9999. We allow
// any year, even negative ones. The year is formatted as "%.4d".
// ! Tolerate missing TZD, assume is UTC. Photoshop 8 writes dates like this for exif:GPSTimeStamp.
// ! Tolerate missing TZD, assume the time is in local time
// ! Tolerate missing date portion, in case someone foolishly writes a time-only value that way.
// *** Put the ISO format comments in the header documentation.
@@ -1397,6 +1397,10 @@ XMPUtils::ConvertToDate ( XMP_StringPtr strValue,
if ( temp > 59 ) XMP_Throw ( "Time zone minute is out of range", kXMPErr_BadParam );
binValue->tzMinute = temp;
} else {
XMPUtils::SetTimeZone( binValue );
}
if ( strValue[pos] != 0 ) XMP_Throw ( "Invalid date string, extra chars at end", kXMPErr_BadParam );