| 1 |
#ifndef __ExpatAdapter_hpp__ |
| 2 |
#define __ExpatAdapter_hpp__ |
| 3 |
|
| 4 |
// ================================================================================================= |
| 5 |
// Copyright 2005 Adobe |
| 6 |
// All Rights Reserved. |
| 7 |
// |
| 8 |
// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms |
| 9 |
// of the Adobe license agreement accompanying it. If you have received this file from a source other |
| 10 |
// than Adobe, then your use, modification, or distribution of it requires the prior written permission |
| 11 |
// of Adobe. |
| 12 |
// ================================================================================================= |
| 13 |
|
| 14 |
#if AdobePrivate |
| 15 |
// ================================================================================================= |
| 16 |
// Change history |
| 17 |
// ============== |
| 18 |
// |
| 19 |
// Writers: |
| 20 |
// AWL Alan Lillich |
| 21 |
// ADC Amandeep Chawla |
| 22 |
// |
| 23 |
// mm-dd-yy who Description of changes, most recent on top. |
| 24 |
// |
| 25 |
// 02-24-14 ADC 5.6-c001 XMPCommon Framework and XMPCore new APIs ported to Mac Environment. |
| 26 |
// |
| 27 |
// 06-11-09 AWL 5.0-c034 Finish threading revamp, implement friendly reader/writer locking. |
| 28 |
// |
| 29 |
// 08-06-08 AWL Add disabled conditional code for limiting XML entity usage. |
| 30 |
// |
| 31 |
// 11-30-07 AWL 4.2-c027 Expose XML_Node and ExpatAdapter so that XMPFiles can use them. |
| 32 |
// 08-24-07 AWL 4.2-c019 Remove support for ancient CXMP_* init/term routines and non-public (AXE) expat. |
| 33 |
// |
| 34 |
// 08-16-06 AWL 4.1-c015 [1312441,1340116] Change the parsing code to tolerate ISO Latin-1 input. At |
| 35 |
// the same time, get rid of the ugly hackery that tries to deal with unescaped ASCII |
| 36 |
// control characters. Also get rid of the check and complaint about parsing into an |
| 37 |
// empty object. This is predominantly what people want, so clear the XMPMeta object. |
| 38 |
// |
| 39 |
// 03-24-06 AWL 4.0-c001 Adapt for move to ham-perforce, integrate XMPFiles, bump version to 4. |
| 40 |
// |
| 41 |
// 02-03-05 AWL Initial creation. |
| 42 |
// |
| 43 |
// ================================================================================================= |
| 44 |
#endif // AdobePrivate |
| 45 |
|
| 46 |
#include "public/include/XMP_Environment.h" // ! Must be the first #include! |
| 47 |
#include "source/XMLParserAdapter.hpp" |
| 48 |
|
| 49 |
// ================================================================================================= |
| 50 |
// Derived XML parser adapter for Expat. |
| 51 |
// ================================================================================================= |
| 52 |
|
| 53 |
#ifndef BanAllEntityUsage |
| 54 |
#define BanAllEntityUsage 0 |
| 55 |
#endif |
| 56 |
|
| 57 |
struct XML_ParserStruct; // ! Hack to avoid exposing expat.h to all clients. |
| 58 |
typedef struct XML_ParserStruct *XML_Parser; |
| 59 |
|
| 60 |
class ExpatAdapter : public XMLParserAdapter { |
| 61 |
public: |
| 62 |
|
| 63 |
XML_Parser parser; |
| 64 |
XMP_NamespaceTable * registeredNamespaces; |
| 65 |
|
| 66 |
#if BanAllEntityUsage |
| 67 |
bool isAborted; |
| 68 |
#endif |
| 69 |
|
| 70 |
#if XMP_DebugBuild |
| 71 |
size_t elemNesting; |
| 72 |
#endif |
| 73 |
|
| 74 |
static const bool kUseGlobalNamespaces = true; |
| 75 |
static const bool kUseLocalNamespaces = false; |
| 76 |
|
| 77 |
ExpatAdapter ( bool useGlobalNamespaces ); |
| 78 |
virtual ~ExpatAdapter(); |
| 79 |
|
| 80 |
void ParseBuffer ( const void * buffer, size_t length, bool last = true ); |
| 81 |
|
| 82 |
private: |
| 83 |
|
| 84 |
ExpatAdapter() : registeredNamespaces(0) {}; // ! Force use of constructor with namespace parameter. |
| 85 |
|
| 86 |
}; |
| 87 |
|
| 88 |
extern "C" ExpatAdapter * |
| 89 |
XMP_PUBLIC XMP_NewExpatAdapter ( bool useGlobalNamespaces ); |
| 90 |
|
| 91 |
// ================================================================================================= |
| 92 |
|
| 93 |
#endif // __ExpatAdapter_hpp__ |