|
decompiler 1.0.0
|
An XML based decoder. More...
#include <marshal.hh>
Public Member Functions | |
| XmlDecode (const AddrSpaceManager *spc, const Element *root) | |
| Constructor with preparsed root. | |
| XmlDecode (const AddrSpaceManager *spc) | |
| Constructor for use with ingestStream. | |
| virtual void | ingestStream (istream &s) |
| Prepare to decode a given stream. More... | |
| virtual uint4 | peekElement (void) |
| Peek at the next child element of the current parent, without traversing in (opening) it. More... | |
| virtual uint4 | openElement (void) |
| Open (traverse into) the next child element of the current parent. More... | |
| virtual uint4 | openElement (const ElementId &elemId) |
| Open (traverse into) the next child element, which must be of a specific type. More... | |
| virtual void | closeElement (uint4 id) |
| Close the current element. More... | |
| virtual void | closeElementSkipping (uint4 id) |
| Close the current element, skipping any child elements that have not yet been parsed. More... | |
| virtual void | rewindAttributes (void) |
| Reset attribute traversal for the current element. More... | |
| virtual uint4 | getNextAttributeId (void) |
| Get the next attribute id for the current element. More... | |
| virtual bool | readBool (void) |
| Parse the current attribute as a boolean value. More... | |
| virtual bool | readBool (const AttributeId &attribId) |
| Find and parse a specific attribute in the current element as a boolean value. More... | |
| virtual intb | readSignedInteger (void) |
| Parse the current attribute as a signed integer value. More... | |
| virtual intb | readSignedInteger (const AttributeId &attribId) |
| Find and parse a specific attribute in the current element as a signed integer. More... | |
| virtual uintb | readUnsignedInteger (void) |
| Parse the current attribute as an unsigned integer value. More... | |
| virtual uintb | readUnsignedInteger (const AttributeId &attribId) |
| Find and parse a specific attribute in the current element as an unsigned integer. More... | |
| virtual string | readString (void) |
| Parse the current attribute as a string. More... | |
| virtual string | readString (const AttributeId &attribId) |
| Find the specific attribute in the current element and return it as a string. More... | |
| virtual AddrSpace * | readSpace (void) |
| Parse the current attribute as an address space. More... | |
| virtual AddrSpace * | readSpace (const AttributeId &attribId) |
| Find the specific attribute in the current element and return it as an address space. More... | |
Public Member Functions inherited from Decoder | |
| Decoder (const AddrSpaceManager *spc) | |
| Base constructor. | |
| const AddrSpaceManager * | getAddrSpaceManager (void) const |
| Get the manager used for address space decoding. | |
| virtual | ~Decoder (void) |
| Destructor. | |
| virtual void | ingestStream (istream &s)=0 |
| Prepare to decode a given stream. More... | |
| virtual uint4 | peekElement (void)=0 |
| Peek at the next child element of the current parent, without traversing in (opening) it. More... | |
| virtual uint4 | openElement (void)=0 |
| Open (traverse into) the next child element of the current parent. More... | |
| virtual uint4 | openElement (const ElementId &elemId)=0 |
| Open (traverse into) the next child element, which must be of a specific type. More... | |
| virtual void | closeElement (uint4 id)=0 |
| Close the current element. More... | |
| virtual void | closeElementSkipping (uint4 id)=0 |
| Close the current element, skipping any child elements that have not yet been parsed. More... | |
| virtual uint4 | getNextAttributeId (void)=0 |
| Get the next attribute id for the current element. More... | |
| virtual void | rewindAttributes (void)=0 |
| Reset attribute traversal for the current element. More... | |
| virtual bool | readBool (void)=0 |
| Parse the current attribute as a boolean value. More... | |
| virtual bool | readBool (const AttributeId &attribId)=0 |
| Find and parse a specific attribute in the current element as a boolean value. More... | |
| virtual intb | readSignedInteger (void)=0 |
| Parse the current attribute as a signed integer value. More... | |
| virtual intb | readSignedInteger (const AttributeId &attribId)=0 |
| Find and parse a specific attribute in the current element as a signed integer. More... | |
| virtual uintb | readUnsignedInteger (void)=0 |
| Parse the current attribute as an unsigned integer value. More... | |
| virtual uintb | readUnsignedInteger (const AttributeId &attribId)=0 |
| Find and parse a specific attribute in the current element as an unsigned integer. More... | |
| virtual string | readString (void)=0 |
| Parse the current attribute as a string. More... | |
| virtual string | readString (const AttributeId &attribId)=0 |
| Find the specific attribute in the current element and return it as a string. More... | |
| virtual AddrSpace * | readSpace (void)=0 |
| Parse the current attribute as an address space. More... | |
| virtual AddrSpace * | readSpace (const AttributeId &attribId)=0 |
| Find the specific attribute in the current element and return it as an address space. More... | |
| void | skipElement (void) |
| Skip parsing of the next element. More... | |
Private Member Functions | |
| int4 | findMatchingAttribute (const Element *el, const string &attribName) |
| Find the attribute index, within the given element, for the given name. More... | |
Private Attributes | |
| Document * | document |
| An ingested XML document, owned by this decoder. | |
| const Element * | rootElement |
| The root XML element to be decoded. | |
| vector< const Element * > | elStack |
| Stack of currently open elements. | |
| vector< List::const_iterator > | iterStack |
| Index of next child for each open element. | |
| int4 | attributeIndex |
| Position of current attribute to parse (in current element) | |
Additional Inherited Members | |
Protected Attributes inherited from Decoder | |
| const AddrSpaceManager * | spcManager |
| Manager for decoding address space attributes. | |
An XML based decoder.
The underlying transfer encoding is an XML document. The decoder can either be initialized with an existing Element as the root of the data to transfer, or the ingestStream() method can be invoked to read the XML document from an input stream, in which case the decoder manages the Document object.
|
virtual |
Close the current element.
The data for the current element is considered fully processed. If the element has additional children, an exception is thrown. The stream must indicate the end of the element in some way.
| id | is the id of the element to close (which must be the current element) |
Implements Decoder.
References attributeIndex, elStack, ElementId::find(), Element::getChildren(), Element::getName(), and iterStack.
Referenced by SleighArchitecture::loadLanguageDescription(), LoadImageXml::open(), Architecture::parseCompilerConfig(), Architecture::parseExtraRules(), Architecture::parseProcessorConfig(), and Architecture::restoreXml().
|
virtual |
Close the current element, skipping any child elements that have not yet been parsed.
This closes the given element, which must be current. If there are child elements that have not been parsed, this is not considered an error, and they are skipped over in the parse.
| id | is the id of the element to close (which must be the current element) |
Implements Decoder.
References attributeIndex, elStack, ElementId::find(), Element::getName(), and iterStack.
Referenced by SleighArchitecture::loadLanguageDescription(), and Architecture::parseProcessorConfig().
|
private |
Find the attribute index, within the given element, for the given name.
Run through the attributes of the element until we find the one matching the name, or throw an exception otherwise.
| el | is the given element to search |
| attribName | is the attribute name to search for |
References Element::getAttributeName(), and Element::getNumAttributes().
Referenced by readBool(), readSignedInteger(), readSpace(), readString(), and readUnsignedInteger().
|
virtual |
Get the next attribute id for the current element.
Attributes are automatically set up for traversal using this method, when the element is opened. If all attributes have been traversed (or there are no attributes), 0 is returned.
Implements Decoder.
References attributeIndex, elStack, AttributeId::find(), and Element::getAttributeName().
Referenced by LoadImageXml::open(), and Architecture::restoreXml().
|
virtual |
Prepare to decode a given stream.
Called once before any decoding. Currently this is assumed to make an internal copy of the stream data, i.e. the input stream is cleared before any decoding takes place.
| s | is the given input stream to be decode |
Implements Decoder.
References document, Document::getRoot(), rootElement, and xml_tree().
Referenced by SleighArchitecture::loadLanguageDescription().
|
virtual |
Open (traverse into) the next child element, which must be of a specific type.
The child becomes the current parent, and its attributes are initialized for use with getNextAttributeId. The child must match the given element id or an exception is thrown.
| elemId | is the given element id to match |
Implements Decoder.
References attributeIndex, elStack, Element::getChildren(), ElementId::getId(), ElementId::getName(), Element::getName(), iterStack, and rootElement.
|
virtual |
Open (traverse into) the next child element of the current parent.
The child becomes the current parent. The list of attributes is initialized for use with getNextAttributeId.
Implements Decoder.
References attributeIndex, elStack, ElementId::find(), Element::getChildren(), Element::getName(), iterStack, and rootElement.
Referenced by SleighArchitecture::loadLanguageDescription(), LoadImageXml::open(), Architecture::parseCompilerConfig(), Architecture::parseExtraRules(), Architecture::parseProcessorConfig(), and Architecture::restoreXml().
|
virtual |
Peek at the next child element of the current parent, without traversing in (opening) it.
The element id is returned, which can be compared to ElementId labels. If there are no remaining child elements to traverse, 0 is returned.
Implements Decoder.
References elStack, ElementId::find(), Element::getChildren(), Element::getName(), iterStack, and rootElement.
Referenced by SleighArchitecture::loadLanguageDescription(), Architecture::parseCompilerConfig(), Architecture::parseExtraRules(), Architecture::parseProcessorConfig(), and Architecture::restoreXml().
|
virtual |
Find and parse a specific attribute in the current element as a boolean value.
The set of attributes for the current element is searched for a match to the given attribute id. This attribute is then parsed as a boolean and its value returned. If there is no attribute matching the id, an exception is thrown. Parsing via getNextAttributeId is reset.
| attribId | is the specific attribute id to match |
Implements Decoder.
References elStack, findMatchingAttribute(), Element::getAttributeValue(), Element::getContent(), AttributeId::getName(), and xml_readbool().
|
virtual |
Parse the current attribute as a boolean value.
The last attribute, as returned by getNextAttributeId, is treated as a boolean, and its value is returned.
Implements Decoder.
References attributeIndex, elStack, Element::getAttributeValue(), and xml_readbool().
Referenced by LoadImageXml::open(), and Architecture::restoreXml().
|
virtual |
Find and parse a specific attribute in the current element as a signed integer.
The set of attributes for the current element is searched for a match to the given attribute id. This attribute is then parsed as a signed integer and its value returned. If there is no attribute matching the id, an exception is thrown. Parsing via getNextAttributeId is reset.
| attribId | is the specific attribute id to match |
Implements Decoder.
References elStack, findMatchingAttribute(), Element::getAttributeValue(), Element::getContent(), and AttributeId::getName().
|
virtual |
Parse the current attribute as a signed integer value.
The last attribute, as returned by getNextAttributeId, is treated as a signed integer, and its value is returned.
Implements Decoder.
References attributeIndex, elStack, and Element::getAttributeValue().
|
virtual |
Find the specific attribute in the current element and return it as an address space.
Search attributes from the current element for a match to the given attribute id. Return this attribute as an address space. If there is no attribute matching the id, an exception is thrown. Parse via getNextAttributeId is reset.
| attribId | is the specific attribute id to match |
Implements Decoder.
References elStack, findMatchingAttribute(), Element::getAttributeValue(), Element::getContent(), AttributeId::getName(), AddrSpaceManager::getSpaceByName(), and Decoder::spcManager.
|
virtual |
Parse the current attribute as an address space.
The last attribute, as returned by getNextAttributeId, is returned as an address space.
Implements Decoder.
References attributeIndex, elStack, Element::getAttributeValue(), AddrSpaceManager::getSpaceByName(), and Decoder::spcManager.
Referenced by LoadImageXml::open(), and Architecture::parseProcessorConfig().
|
virtual |
Find the specific attribute in the current element and return it as a string.
The set of attributes for the current element is searched for a match to the given attribute id. This attribute is then returned as a string. If there is no attribute matching the id, and exception is thrown. Parse via getNextAttributeId is reset.
| attribId | is the specific attribute id to match |
Implements Decoder.
References elStack, findMatchingAttribute(), Element::getAttributeValue(), Element::getContent(), and AttributeId::getName().
|
virtual |
Parse the current attribute as a string.
The last attribute, as returned by getNextAttributeId, is returned as a string.
Implements Decoder.
References attributeIndex, elStack, and Element::getAttributeValue().
Referenced by LoadImageXml::open(), and Architecture::parseCompilerConfig().
|
virtual |
Find and parse a specific attribute in the current element as an unsigned integer.
The set of attributes for the current element is searched for a match to the given attribute id. This attribute is then parsed as an unsigned integer and its value returned. If there is no attribute matching the id, an exception is thrown. Parsing via getNextAttributeId is reset.
| attribId | is the specific attribute id to match |
Implements Decoder.
References elStack, findMatchingAttribute(), Element::getAttributeValue(), Element::getContent(), and AttributeId::getName().
|
virtual |
Parse the current attribute as an unsigned integer value.
The last attribute, as returned by getNextAttributeId, is treated as an unsigned integer, and its value is returned.
Implements Decoder.
References attributeIndex, elStack, and Element::getAttributeValue().
|
virtual |
Reset attribute traversal for the current element.
Attributes for a single element can be traversed more than once using the getNextAttributeId method.
Implements Decoder.
References attributeIndex.
Referenced by LoadImageXml::open().