Ghidra Decompiler Analysis Engine
|
Go to the documentation of this file.
37 static string bogus_uri;
40 vector<string *> name;
41 vector<string *> value;
45 for(uint4 i=0;i<name.size();++i) {
delete name[i];
delete value[i]; }
48 const string &getelemURI(
void)
const {
return bogus_uri; }
49 const string &getelemName(
void)
const {
return *elementname; }
50 void add_attribute(
string *nm,
string *vl) { name.push_back(nm); value.push_back(vl); }
52 int4 getLength(
void)
const {
return name.size(); }
53 const string &getURI(int4 i)
const {
return bogus_uri; }
54 const string &getLocalName(int4 i)
const {
return *name[i]; }
55 const string &getQName(int4 i)
const {
return *name[i]; }
61 const string &getValue(int4 i)
const {
return *value[i]; }
64 const string &
getValue(
const string &qualifiedName)
const {
65 for(uint4 i=0;i<name.size();++i)
66 if (*name[i] == qualifiedName)
return *value[i];
80 virtual void setDocumentLocator(
Locator locator)=0;
81 virtual void startDocument(
void)=0;
82 virtual void endDocument(
void)=0;
83 virtual void startPrefixMapping(
const string &prefix,
const string &uri)=0;
84 virtual void endPrefixMapping(
const string &prefix)=0;
92 virtual void startElement(
const string &namespaceURI,
const string &localName,
93 const string &qualifiedName,
const Attributes &atts)=0;
100 virtual void endElement(
const string &namespaceURI,
const string &localName,
101 const string &qualifiedName)=0;
108 virtual void characters(
const char *text,int4 start,int4 length)=0;
115 virtual void ignorableWhitespace(
const char *text,int4 start,int4 length)=0;
120 virtual void setVersion(
const string &version)=0;
125 virtual void setEncoding(
const string &encoding)=0;
131 virtual void processingInstruction(
const string &target,
const string &data)=0;
136 virtual void skippedEntity(
const string &name)=0;
141 virtual void setError(
const string &errmsg)=0;
145 typedef vector<Element *>
List;
154 vector<string> value;
161 void setName(
const string &nm) { name = nm; }
170 content.append(str+start,length); }
182 attr.push_back(nm); value.push_back(vl); }
184 Element *getParent(
void)
const {
return parent; }
185 const string &getName(
void)
const {
return name; }
186 const List &getChildren(
void)
const {
return children; }
187 const string &getContent(
void)
const {
return content; }
195 const string &getAttributeValue(
const string &nm)
const;
197 int4 getNumAttributes(
void)
const {
return attr.size(); }
198 const string &getAttributeName(int4 i)
const {
return attr[i]; }
199 const string &getAttributeValue(int4 i)
const {
return value[i]; }
209 Element *getRoot(
void)
const {
return *children.begin(); }
229 virtual void startElement(
const string &namespaceURI,
const string &localName,
230 const string &qualifiedName,
const Attributes &atts);
231 virtual void endElement(
const string &namespaceURI,
const string &localName,
232 const string &qualifiedName);
233 virtual void characters(
const char *text,int4 start,int4 length);
239 virtual void setError(
const string &errmsg) { error = errmsg; }
240 const string &getError(
void)
const {
return error; }
250 vector<Document *> doclist;
251 map<string,const Element *> tagmap;
261 Document *parseDocument(istream &s);
269 Document *openDocument(
const string &filename);
275 void registerTag(
const Element *el);
281 const Element *getTag(
const string &nm)
const;
290 XmlError(
const string &s) { explain = s; }
321 extern void xml_escape(ostream &s,
const char *str);
330 inline void a_v(ostream &s,
const string &attr,
const string &val)
333 s <<
' ' << attr <<
"=\"";
343 inline void a_v_i(ostream &s,
const string &attr,intb val)
346 s <<
' ' << attr <<
"=\"" << dec << val <<
"\"";
354 inline void a_v_u(ostream &s,
const string &attr,uintb val)
357 s <<
' ' << attr <<
"=\"0x" << hex << val <<
"\"";
365 inline void a_v_b(ostream &s,
const string &attr,
bool val)
368 s <<
' ' << attr <<
"=\"";
385 if (attr.size()==0)
return false;
386 char firstc = attr[0];
387 if (firstc==
't')
return true;
388 if (firstc==
'1')
return true;
389 if (firstc==
'y')
return true;
void xml_escape(ostream &s, const char *str)
Send the given character array to a stream, escaping characters with special XML meaning.
Definition: xml.cc:2350
virtual void endPrefixMapping(const string &prefix)
Finish the current prefix.
Definition: xml.hh:228
The SAX interface for parsing XML documents.
Definition: xml.hh:77
void addChild(Element *child)
Add a new child Element to the model, with this as the parent.
Definition: xml.hh:175
void addContent(const char *str, int4 start, int4 length)
Append new character content to this element.
Definition: xml.hh:168
virtual void ignorableWhitespace(const char *text, int4 start, int4 length)
Callback with whitespace character data for the current XML element.
Definition: xml.hh:234
string explain
Explanatory string.
Definition: xml.hh:289
void a_v_b(ostream &s, const string &attr, bool val)
Output the given boolean value as an XML attribute.
Definition: xml.hh:365
vector< Element * > List
A list of XML elements.
Definition: xml.hh:144
Element * parent
The parent Element (or null)
Definition: xml.hh:156
A complete in-memory XML document.
Definition: xml.hh:206
void * Locator
Placeholder for a document locator object.
Definition: xml.hh:71
An XML element. A node in the DOM tree.
Definition: xml.hh:150
void a_v_u(ostream &s, const string &attr, uintb val)
Output the given unsigned integer as an XML attribute value.
Definition: xml.hh:354
virtual void startPrefixMapping(const string &prefix, const string &uri)
Start a new prefix to namespace URI mapping.
Definition: xml.hh:227
const string & getValue(const string &qualifiedName) const
Get the value of the attribute with the given qualified name.
Definition: xml.hh:64
void a_v(ostream &s, const string &attr, const string &val)
Output an XML attribute name/value pair to stream.
Definition: xml.hh:330
A SAX interface implementation for constructing an in-memory DOM model.
Definition: xml.hh:217
virtual void setEncoding(const string &val)
Set the character encoding as specified by the current document.
Definition: xml.hh:237
virtual void setDocumentLocator(Locator locator)
Set the Locator object for documents.
Definition: xml.hh:224
Document * xml_tree(istream &i)
Parse the given XML stream into an in-memory document.
Definition: xml.cc:2338
virtual void setError(const string &errmsg)
Callback for handling an error condition during XML parsing.
Definition: xml.hh:239
bool xml_readbool(const string &attr)
Read an XML attribute value as a boolean.
Definition: xml.hh:382
An exception thrown by the XML parser.
Definition: xml.hh:288
virtual void skippedEntity(const string &name)
Callback for an XML entity skipped by the parser.
Definition: xml.hh:238
void addAttribute(const string &nm, const string &vl)
Add a new name/value attribute pair to this element.
Definition: xml.hh:181
virtual void startDocument(void)
Start processing a new XML document.
Definition: xml.hh:225
A container for parsed XML documents.
Definition: xml.hh:249
void a_v_i(ostream &s, const string &attr, intb val)
Output the given signed integer as an XML attribute value.
Definition: xml.hh:343
virtual void endDocument(void)
End processing for the current XML document.
Definition: xml.hh:226
int4 xml_parse(istream &i, ContentHandler *hand, int4 dbg=0)
Start-up the XML parser given a stream and a handler.
Definition: xml.cc:2236
virtual void processingInstruction(const string &target, const string &data)
Callback for a formal processing instruction seen in the current document.
Definition: xml.hh:235
The attributes for a single XML element.
Definition: xml.hh:36
virtual void setVersion(const string &val)
Set the XML version as specified by the current document.
Definition: xml.hh:236
List children
A list of child Element objects.
Definition: xml.hh:157