Ghidra 11.3.2
Ghidra internal decompiler documentation.
Loading...
Searching...
No Matches
ghidra::XmlEncode Class Reference

An XML based encoder. More...

#include <marshal.hh>

Inheritance diagram for ghidra::XmlEncode:
[legend]
Collaboration diagram for ghidra::XmlEncode:
[legend]

Public Member Functions

 XmlEncode (ostream &s, bool doFormat=true)
 Construct from a stream.
 
virtual void openElement (const ElementId &elemId)
 Begin a new element in the encoding.
 
virtual void closeElement (const ElementId &elemId)
 End the current element in the encoding.
 
virtual void writeBool (const AttributeId &attribId, bool val)
 Write an annotated boolean value into the encoding.
 
virtual void writeSignedInteger (const AttributeId &attribId, intb val)
 Write an annotated signed integer value into the encoding.
 
virtual void writeUnsignedInteger (const AttributeId &attribId, uintb val)
 Write an annotated unsigned integer value into the encoding.
 
virtual void writeString (const AttributeId &attribId, const string &val)
 Write an annotated string into the encoding.
 
virtual void writeStringIndexed (const AttributeId &attribId, uint4 index, const string &val)
 Write an annotated string, using an indexed attribute, into the encoding.
 
virtual void writeSpace (const AttributeId &attribId, const AddrSpace *spc)
 Write an address space reference into the encoding.
 
virtual void writeOpcode (const AttributeId &attribId, OpCode opc)
 Write a p-code operation opcode into the encoding, associating it with the given annotation.
 
- Public Member Functions inherited from ghidra::Encoder
virtual ~Encoder (void)
 Destructor.
 

Private Types

enum  { tag_start = 0 , tag_content = 1 , tag_stop = 2 }
 

Private Member Functions

void newLine (void)
 Emit a newline and proper indenting for the next tag.
 

Private Attributes

ostream & outStream
 The stream receiving the encoded data.
 
int4 tagStatus
 Stage of writing an element tag.
 
int4 depth
 Depth of open elements.
 
bool doFormatting
 true if encoder should indent and emit newlines
 

Static Private Attributes

static const char spaces [] = "\n "
 Array of ' ' characters for emitting indents.
 
static const int4 MAX_SPACES = 24+1
 Maximum number of leading spaces when indenting XML.
 

Friends

class XmlDecode
 

Detailed Description

An XML based encoder.

The underlying transfer encoding is an XML document. The encoder is initialized with a stream which will receive the XML document as calls are made on the encoder.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
tag_start 

Tag has been opened, attributes can be written.

tag_content 

Opening tag and content have been written.

tag_stop 

No tag is currently being written.

Member Function Documentation

◆ closeElement()

void ghidra::XmlEncode::closeElement ( const ElementId elemId)
virtual

End the current element in the encoding.

The current element must match the given annotation or an exception is thrown.

Parameters
elemIdis the given (expected) annotation for the current element

Implements ghidra::Encoder.

References depth, ghidra::ElementId::getName(), newLine(), outStream, tag_content, tag_start, tag_stop, and tagStatus.

◆ openElement()

void ghidra::XmlEncode::openElement ( const ElementId elemId)
virtual

Begin a new element in the encoding.

The element will have the given ElementId annotation and becomes the current element.

Parameters
elemIdis the given ElementId annotation

Implements ghidra::Encoder.

References depth, ghidra::ElementId::getName(), newLine(), outStream, tag_start, and tagStatus.

◆ writeBool()

void ghidra::XmlEncode::writeBool ( const AttributeId attribId,
bool  val 
)
virtual

Write an annotated boolean value into the encoding.

The boolean data is associated with the given AttributeId annotation and the current open element.

Parameters
attribIdis the given AttributeId annotation
valis boolean value to encode

Implements ghidra::Encoder.

References ghidra::a_v_b(), ghidra::AttributeId::getName(), outStream, tag_content, tag_start, and tagStatus.

◆ writeOpcode()

void ghidra::XmlEncode::writeOpcode ( const AttributeId attribId,
OpCode  opc 
)
virtual

Write a p-code operation opcode into the encoding, associating it with the given annotation.

Parameters
attribIdis the given annotation
opcis the opcode

Implements ghidra::Encoder.

References ghidra::AttributeId::getName(), outStream, tag_content, tag_start, and tagStatus.

◆ writeSignedInteger()

void ghidra::XmlEncode::writeSignedInteger ( const AttributeId attribId,
intb  val 
)
virtual

Write an annotated signed integer value into the encoding.

The integer is associated with the given AttributeId annotation and the current open element.

Parameters
attribIdis the given AttributeId annotation
valis the signed integer value to encode

Implements ghidra::Encoder.

References ghidra::a_v_i(), ghidra::AttributeId::getName(), outStream, tag_content, tag_start, and tagStatus.

◆ writeSpace()

void ghidra::XmlEncode::writeSpace ( const AttributeId attribId,
const AddrSpace spc 
)
virtual

Write an address space reference into the encoding.

The address space is associated with the given AttributeId annotation and the current open element.

Parameters
attribIdis the given AttributeId annotation
spcis the address space to encode

Implements ghidra::Encoder.

References ghidra::a_v(), ghidra::AttributeId::getName(), ghidra::AddrSpace::getName(), outStream, tag_content, tag_start, and tagStatus.

◆ writeString()

void ghidra::XmlEncode::writeString ( const AttributeId attribId,
const string &  val 
)
virtual

Write an annotated string into the encoding.

The string is associated with the given AttributeId annotation and the current open element.

Parameters
attribIdis the given AttributeId annotation
valis the string to encode

Implements ghidra::Encoder.

References ghidra::a_v(), ghidra::AttributeId::getName(), outStream, tag_content, tag_start, and tagStatus.

◆ writeStringIndexed()

void ghidra::XmlEncode::writeStringIndexed ( const AttributeId attribId,
uint4  index,
const string &  val 
)
virtual

Write an annotated string, using an indexed attribute, into the encoding.

Multiple attributes with a shared name can be written to the same element by calling this method multiple times with a different index value. The encoding will use attribute ids up to the base id plus the maximum index passed in. Implementors must be careful to not use other attributes with ids bigger than the base id within the element taking the indexed attribute.

Parameters
attribIdis the shared AttributeId
indexis the unique index to associated with the string
valis the string to encode

Implements ghidra::Encoder.

References ghidra::AttributeId::getName(), and outStream.

◆ writeUnsignedInteger()

void ghidra::XmlEncode::writeUnsignedInteger ( const AttributeId attribId,
uintb  val 
)
virtual

Write an annotated unsigned integer value into the encoding.

The integer is associated with the given AttributeId annotation and the current open element.

Parameters
attribIdis the given AttributeId annotation
valis the unsigned integer value to encode

Implements ghidra::Encoder.

References ghidra::a_v_u(), ghidra::AttributeId::getName(), outStream, tag_content, tag_start, and tagStatus.


The documentation for this class was generated from the following files: