blob: f0f99e3fa1ef362844dd5b1c8c670b24183fe727 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#ifndef DYNAMIC_DEPTH_INTERNAL_XMPMETA_XML_UTILS_H_ // NOLINT
#define DYNAMIC_DEPTH_INTERNAL_XMPMETA_XML_UTILS_H_ // NOLINT
#include <libxml/tree.h>
#include <string>
#include "base/port.h"
namespace photos_editing_formats {
namespace xml {
// Convenience function to convert an xmlChar* to a char*
inline const char* FromXmlChar(const xmlChar* in) {
return reinterpret_cast<const char*>(in);
}
// Convenience function to convert a char* to an xmlChar*.
inline const xmlChar* ToXmlChar(const char* in) {
return reinterpret_cast<const xmlChar*>(in);
}
// Returns the first rdf:Description node; null if not found.
xmlNodePtr GetFirstDescriptionElement(xmlDocPtr parent);
// Returns the first rdf:Seq element found in the XML document.
xmlNodePtr GetFirstSeqElement(xmlDocPtr parent);
// Returns the first rdf:Seq element found in the given node.
// Returns {@code parent} if that is itself an rdf:Seq node.
xmlNodePtr GetFirstSeqElement(xmlNodePtr parent);
// Returns the ith (zero-indexed) rdf:li node in the given rdf:Seq node.
// Returns null if either of {@code index} < 0, {@code node} is null, or is
// not an rdf:Seq node.
xmlNodePtr GetElementAt(xmlNodePtr node, int index);
// Returns the value in an rdf:li node. This is for a node whose value
// does not have a name, e.g. <rdf:li>value</rdf:li>.
// If the given rdf:li node has a nested node, it returns the string
// representation of the contents of those nodes, which replaces the XML
// tags with one whitespace character for each tag character.
// This is treated as undefined behavior; it is the caller's responsibility
// to remove any whitespace and newlines.
const string GetLiNodeContent(xmlNodePtr node);
// Returns the given XML doc serialized to a string.
// For debugging purposes.
const string XmlDocToString(const xmlDocPtr doc);
} // namespace xml
} // namespace photos_editing_formats
#endif // DYNAMIC_DEPTH_INTERNAL_XMPMETA_XML_UTILS_H_ // NOLINT
|