1
/* xmp-parse.h - simple parser for XMP metadata
3
* Copyright (C) 2004, Raphaël Quinet <raphael@gimp.org>
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Lesser General Public
7
* License as published by the Free Software Foundation; either
8
* version 2 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Lesser General Public License for more details.
15
* You should have received a copy of the GNU Lesser General Public
16
* License along with this library; if not, write to the
17
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
* Boston, MA 02111-1307, USA.
31
XMP_ERROR_BAD_ENCODING,
33
XMP_ERROR_MISSING_ABOUT,
34
XMP_ERROR_UNKNOWN_ELEMENT,
35
XMP_ERROR_UNKNOWN_ATTRIBUTE,
36
XMP_ERROR_UNEXPECTED_ELEMENT,
37
XMP_ERROR_INVALID_CONTENT,
38
XMP_ERROR_INVALID_COMMENT
41
#define XMP_PARSE_ERROR xmp_parse_error_quark ()
43
GQuark xmp_parse_error_quark (void);
47
XMP_FLAG_FIND_XPACKET = 1 << 0, /* allow text before <?xpacket */
48
XMP_FLAG_NO_COMMENTS = 1 << 1, /* no XML comments allowed */
49
XMP_FLAG_NO_UNKNOWN_ELEMENTS = 1 << 2, /* no unknown XML elements */
50
XMP_FLAG_NO_UNKNOWN_ATTRIBUTES = 1 << 3, /* no unknown XML attributes */
51
XMP_FLAG_NO_MISSING_ABOUT = 1 << 4, /* schemas must have rdf:about */
52
XMP_FLAG_DEFER_VALUE_FREE = 1 << 5 /* prop. value[] freed by caller */
57
XMP_PTYPE_TEXT, /* value in value[0] */
58
XMP_PTYPE_RESOURCE, /* value in value[0] */
59
XMP_PTYPE_ORDERED_LIST, /* values in value[0..n] */
60
XMP_PTYPE_UNORDERED_LIST, /* values in value[0..n] */
61
XMP_PTYPE_ALT_THUMBS, /* values in value[0..n] */
62
XMP_PTYPE_ALT_LANG, /* lang in value[0,2..n*2], text in value[1,3..n*2+1] */
63
XMP_PTYPE_STRUCTURE, /* ns prefix in name[0], ns uri in name[1], */
64
/* name in value[2,4..n*2+2], value in value[3,5..n*2+3] */
68
typedef struct _XMPParseContext XMPParseContext;
69
typedef struct _XMPParser XMPParser;
73
/* Called whenever the parser sees a new namespace (usually an XMP
74
* schema) except for the basic RDF and XMP namespaces. The value
75
* returned by this callback will be passed as "ns_user_data" to the
76
* callbacks end_schema and set_property. It is allowed to return
77
* the pointers ns_uri or ns_prefix because they will remain valid
78
* at least until end_schema is called.
80
gpointer (*start_schema) (XMPParseContext *context,
82
const gchar *ns_prefix,
86
/* Called when a namespace goes out of scope. The ns_user_data will
87
* be the one that was returned by start_schema for the
88
* corresponding schema.
90
void (*end_schema) (XMPParseContext *context,
91
gpointer ns_user_data,
95
/* Called for each property that is defined in the XMP packet. The
96
* way the value of the property is returned depends on its type.
97
* See the definition of XMPParseType for details.
99
void (*set_property) (XMPParseContext *context,
103
gpointer ns_user_data,
107
/* Called on error, including one set by other methods in the
108
* vtable. The GError should not be freed.
110
void (*error) (XMPParseContext *context,
115
XMPParseContext * xmp_parse_context_new (const XMPParser *parser,
118
GDestroyNotify user_data_dnotify);
120
void xmp_parse_context_free (XMPParseContext *context);
122
gboolean xmp_parse_context_parse (XMPParseContext *context,
127
gboolean xmp_parse_context_end_parse (XMPParseContext *context,
131
#endif /* XMP_PARSE_H */