decompiler  1.0.0
Public Member Functions | List of all members
ghidra::Encoder Class Referenceabstract

A class for writing structured data to a stream. More...

#include <marshal.hh>

Inheritance diagram for ghidra::Encoder:
ghidra::PackedEncode ghidra::XmlEncode

Public Member Functions

virtual ~Encoder (void)
 Destructor.
 
virtual void openElement (const ElementId &elemId)=0
 Begin a new element in the encoding. More...
 
virtual void closeElement (const ElementId &elemId)=0
 End the current element in the encoding. More...
 
virtual void writeBool (const AttributeId &attribId, bool val)=0
 Write an annotated boolean value into the encoding. More...
 
virtual void writeSignedInteger (const AttributeId &attribId, intb val)=0
 Write an annotated signed integer value into the encoding. More...
 
virtual void writeUnsignedInteger (const AttributeId &attribId, uintb val)=0
 Write an annotated unsigned integer value into the encoding. More...
 
virtual void writeString (const AttributeId &attribId, const string &val)=0
 Write an annotated string into the encoding. More...
 
virtual void writeStringIndexed (const AttributeId &attribId, uint4 index, const string &val)=0
 Write an annotated string, using an indexed attribute, into the encoding. More...
 
virtual void writeSpace (const AttributeId &attribId, const AddrSpace *spc)=0
 Write an address space reference into the encoding. More...
 

Detailed Description

A class for writing structured data to a stream.

The resulting encoded data is structured similarly to an XML document. The document contains a nested set of elements, with labels corresponding to the ElementId class. A single element can hold zero or more attributes and zero or more child elements. An attribute holds a primitive data element (bool, integer, string) and is labeled by an AttributeId. The document is written using a sequence of openElement() and closeElement() calls, intermixed with write*() calls to encode the data primitives. All primitives written using a write*() call are associated with current open element, and all write*() calls for one element must come before opening any child element. The traditional XML element text content can be written using the special ATTRIB_CONTENT AttributeId, which must be the last write*() call associated with the specific element.

Member Function Documentation

◆ closeElement()

virtual void ghidra::Encoder::closeElement ( const ElementId elemId)
pure 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

Implemented in ghidra::PackedEncode, and ghidra::XmlEncode.

Referenced by ghidra::InjectContextGhidra::encode(), ghidra::LoadImageXml::encode(), ghidra::XmlArchitecture::encode(), ghidra::RawBinaryArchitecture::encode(), ghidra::BfdArchitecture::encode(), ghidra::BlockEdge::encode(), ghidra::LoadTable::encode(), ghidra::StringManager::encode(), ghidra::Comment::encode(), ghidra::TrackedContext::encode(), ghidra::Override::encode(), ghidra::CPoolRecord::encode(), ghidra::Address::encode(), ghidra::SymbolEntry::encode(), ghidra::SeqNum::encode(), ghidra::CommentDatabaseInternal::encode(), ghidra::ConstantPoolInternal::CheapSorter::encode(), ghidra::FlowBlock::encode(), ghidra::Funcdata::encode(), ghidra::ConstantPoolInternal::encode(), ghidra::Range::encode(), ghidra::Datatype::encode(), ghidra::HighVariable::encode(), ghidra::ScopeLocal::encode(), ghidra::PcodeOp::encode(), ghidra::TypeField::encode(), ghidra::Architecture::encode(), ghidra::RangeList::encode(), ghidra::Symbol::encode(), ghidra::FunctionSymbol::encode(), ghidra::TypeChar::encode(), ghidra::ContextInternal::encode(), ghidra::EquateSymbol::encode(), ghidra::TypeUnicode::encode(), ghidra::UnionFacetSymbol::encode(), ghidra::LabSymbol::encode(), ghidra::TypeVoid::encode(), ghidra::Varnode::encode(), ghidra::ExternRefSymbol::encode(), ghidra::TypePointer::encode(), ghidra::TypeArray::encode(), ghidra::TypeEnum::encode(), ghidra::TypeStruct::encode(), ghidra::JumpBasicOverride::encode(), ghidra::TypeUnion::encode(), ghidra::TypePartialUnion::encode(), ghidra::TypePointerRel::encode(), ghidra::JumpTable::encode(), ghidra::TypeCode::encode(), ghidra::TypeSpacebase::encode(), ghidra::TypeFactory::encode(), ghidra::ScopeInternal::encode(), ghidra::Database::encode(), ghidra::ProtoStoreInternal::encode(), ghidra::FuncProto::encode(), ghidra::BlockGraph::encodeBody(), ghidra::BlockGoto::encodeBody(), ghidra::BlockMultiGoto::encodeBody(), ghidra::BlockIf::encodeBody(), ghidra::ContextInternal::encodeContext(), ghidra::TypeFactory::encodeCoreTypes(), ghidra::FuncProto::encodeEffect(), ghidra::Funcdata::encodeHigh(), ghidra::Funcdata::encodeJumpTable(), ghidra::FuncProto::encodeLikelyTrash(), ghidra::Datatype::encodeRef(), ghidra::ContextDatabase::encodeTracked(), ghidra::Funcdata::encodeTree(), and ghidra::Datatype::encodeTypedef().

◆ openElement()

virtual void ghidra::Encoder::openElement ( const ElementId elemId)
pure 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

Implemented in ghidra::PackedEncode, and ghidra::XmlEncode.

Referenced by ghidra::InjectContextGhidra::encode(), ghidra::LoadImageXml::encode(), ghidra::XmlArchitecture::encode(), ghidra::RawBinaryArchitecture::encode(), ghidra::BfdArchitecture::encode(), ghidra::BlockEdge::encode(), ghidra::LoadTable::encode(), ghidra::StringManager::encode(), ghidra::Comment::encode(), ghidra::TrackedContext::encode(), ghidra::Override::encode(), ghidra::CPoolRecord::encode(), ghidra::Address::encode(), ghidra::SymbolEntry::encode(), ghidra::SeqNum::encode(), ghidra::CommentDatabaseInternal::encode(), ghidra::ConstantPoolInternal::CheapSorter::encode(), ghidra::FlowBlock::encode(), ghidra::Funcdata::encode(), ghidra::ConstantPoolInternal::encode(), ghidra::Range::encode(), ghidra::Datatype::encode(), ghidra::HighVariable::encode(), ghidra::ScopeLocal::encode(), ghidra::PcodeOp::encode(), ghidra::TypeField::encode(), ghidra::Architecture::encode(), ghidra::RangeList::encode(), ghidra::Symbol::encode(), ghidra::FunctionSymbol::encode(), ghidra::TypeChar::encode(), ghidra::ContextInternal::encode(), ghidra::EquateSymbol::encode(), ghidra::TypeUnicode::encode(), ghidra::UnionFacetSymbol::encode(), ghidra::LabSymbol::encode(), ghidra::TypeVoid::encode(), ghidra::Varnode::encode(), ghidra::ExternRefSymbol::encode(), ghidra::TypePointer::encode(), ghidra::TypeArray::encode(), ghidra::TypeEnum::encode(), ghidra::TypeStruct::encode(), ghidra::JumpBasicOverride::encode(), ghidra::TypeUnion::encode(), ghidra::TypePartialUnion::encode(), ghidra::TypePointerRel::encode(), ghidra::JumpTable::encode(), ghidra::TypeCode::encode(), ghidra::TypeSpacebase::encode(), ghidra::TypeFactory::encode(), ghidra::ScopeInternal::encode(), ghidra::Database::encode(), ghidra::ProtoStoreInternal::encode(), ghidra::FuncProto::encode(), ghidra::BlockGraph::encodeBody(), ghidra::BlockGoto::encodeBody(), ghidra::BlockMultiGoto::encodeBody(), ghidra::BlockIf::encodeBody(), ghidra::ContextInternal::encodeContext(), ghidra::TypeFactory::encodeCoreTypes(), ghidra::FuncProto::encodeEffect(), ghidra::Funcdata::encodeHigh(), ghidra::Funcdata::encodeJumpTable(), ghidra::FuncProto::encodeLikelyTrash(), ghidra::Datatype::encodeRef(), ghidra::ContextDatabase::encodeTracked(), ghidra::Funcdata::encodeTree(), and ghidra::Datatype::encodeTypedef().

◆ writeBool()

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

◆ writeSignedInteger()

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

◆ writeSpace()

virtual void ghidra::Encoder::writeSpace ( const AttributeId attribId,
const AddrSpace spc 
)
pure 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

Implemented in ghidra::PackedEncode, and ghidra::XmlEncode.

Referenced by ghidra::Override::encode(), ghidra::Range::encode(), ghidra::ScopeLocal::encode(), ghidra::PcodeOp::encode(), ghidra::TypePointer::encode(), ghidra::TypeSpacebase::encode(), ghidra::AddrSpace::encodeAttributes(), ghidra::JoinSpace::encodeAttributes(), and ghidra::FspecSpace::encodeAttributes().

◆ writeString()

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

◆ writeStringIndexed()

virtual void ghidra::Encoder::writeStringIndexed ( const AttributeId attribId,
uint4  index,
const string &  val 
)
pure 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

Implemented in ghidra::PackedEncode, and ghidra::XmlEncode.

Referenced by ghidra::JoinSpace::encodeAttributes().

◆ writeUnsignedInteger()

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

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