Ghidra 11.3.2
Ghidra internal decompiler documentation.
Loading...
Searching...
No Matches
ghidra::Encoder Class Referenceabstract

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

#include <marshal.hh>

Inheritance diagram for ghidra::Encoder:
[legend]

Public Member Functions

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

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::XmlEncode, and ghidra::PackedEncode.

Referenced by ghidra::EmitMarkup::closeParen(), ghidra::Address::encode(), ghidra::SeqNum::encode(), ghidra::Range::encode(), ghidra::RangeList::encode(), ghidra::TrackedContext::encode(), ghidra::ContextInternal::encode(), ghidra::LoadImageXml::encode(), ghidra::XmlArchitecture::encode(), ghidra::Architecture::encode(), ghidra::BlockEdge::encode(), ghidra::FlowBlock::encode(), ghidra::Comment::encode(), ghidra::CommentDatabaseInternal::encode(), ghidra::CPoolRecord::encode(), ghidra::ConstantPoolInternal::CheapSorter::encode(), ghidra::ConstantPoolInternal::encode(), ghidra::SymbolEntry::encode(), ghidra::Symbol::encode(), ghidra::FunctionSymbol::encode(), ghidra::EquateSymbol::encode(), ghidra::UnionFacetSymbol::encode(), ghidra::LabSymbol::encode(), ghidra::ExternRefSymbol::encode(), ghidra::ScopeInternal::encode(), ghidra::Database::encode(), ghidra::ProtoStoreInternal::encode(), ghidra::FuncProto::encode(), ghidra::LoadTable::encode(), ghidra::JumpBasicOverride::encode(), ghidra::JumpTable::encode(), ghidra::PcodeOp::encode(), ghidra::Signature::encode(), ghidra::VarnodeSignature::encode(), ghidra::BlockSignature::encode(), ghidra::CopySignature::encode(), ghidra::SigManager::encode(), ghidra::StringManager::encode(), ghidra::Datatype::encode(), ghidra::TypeField::encode(), ghidra::TypeChar::encode(), ghidra::TypeUnicode::encode(), ghidra::TypeVoid::encode(), ghidra::TypePointer::encode(), ghidra::TypeArray::encode(), ghidra::TypeEnum::encode(), ghidra::TypeStruct::encode(), ghidra::TypeUnion::encode(), ghidra::TypePartialEnum::encode(), ghidra::TypePartialUnion::encode(), ghidra::TypePointerRel::encode(), ghidra::TypeCode::encode(), ghidra::TypeSpacebase::encode(), ghidra::TypeFactory::encode(), ghidra::HighVariable::encode(), ghidra::ScopeLocal::encode(), ghidra::Varnode::encode(), ghidra::InjectContextGhidra::encode(), ghidra::SourceFileIndexer::encode(), ghidra::SleighBase::encode(), ghidra::Override::encode(), ghidra::Address::encode(), ghidra::Funcdata::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::SleighBase::encodeSlaSpace(), ghidra::ContextDatabase::encodeTracked(), ghidra::Funcdata::encodeTree(), ghidra::Datatype::encodeTypedef(), ghidra::EmitMarkup::endBlock(), ghidra::EmitMarkup::endDocument(), ghidra::EmitMarkup::endFuncProto(), ghidra::EmitMarkup::endFunction(), ghidra::EmitMarkup::endReturnType(), ghidra::EmitMarkup::endStatement(), ghidra::EmitMarkup::endVarDecl(), ghidra::EmitMarkup::openParen(), ghidra::EmitMarkup::print(), ghidra::EmitMarkup::tagCaseLabel(), ghidra::EmitMarkup::tagComment(), ghidra::EmitMarkup::tagField(), ghidra::EmitMarkup::tagFuncName(), ghidra::EmitMarkup::tagLabel(), ghidra::EmitMarkup::tagLine(), ghidra::EmitMarkup::tagLine(), ghidra::EmitMarkup::tagOp(), ghidra::EmitMarkup::tagType(), and ghidra::EmitMarkup::tagVariable().

◆ 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::XmlEncode, and ghidra::PackedEncode.

Referenced by ghidra::EmitMarkup::beginBlock(), ghidra::EmitMarkup::beginDocument(), ghidra::EmitMarkup::beginFuncProto(), ghidra::EmitMarkup::beginFunction(), ghidra::EmitMarkup::beginReturnType(), ghidra::EmitMarkup::beginStatement(), ghidra::EmitMarkup::beginVarDecl(), ghidra::EmitMarkup::closeParen(), ghidra::Address::encode(), ghidra::SeqNum::encode(), ghidra::Range::encode(), ghidra::RangeList::encode(), ghidra::TrackedContext::encode(), ghidra::ContextInternal::encode(), ghidra::LoadImageXml::encode(), ghidra::XmlArchitecture::encode(), ghidra::Architecture::encode(), ghidra::BlockEdge::encode(), ghidra::FlowBlock::encode(), ghidra::Comment::encode(), ghidra::CommentDatabaseInternal::encode(), ghidra::CPoolRecord::encode(), ghidra::ConstantPoolInternal::CheapSorter::encode(), ghidra::ConstantPoolInternal::encode(), ghidra::SymbolEntry::encode(), ghidra::Symbol::encode(), ghidra::FunctionSymbol::encode(), ghidra::EquateSymbol::encode(), ghidra::UnionFacetSymbol::encode(), ghidra::LabSymbol::encode(), ghidra::ExternRefSymbol::encode(), ghidra::ScopeInternal::encode(), ghidra::Database::encode(), ghidra::ProtoStoreInternal::encode(), ghidra::FuncProto::encode(), ghidra::LoadTable::encode(), ghidra::JumpBasicOverride::encode(), ghidra::JumpTable::encode(), ghidra::PcodeOp::encode(), ghidra::Signature::encode(), ghidra::VarnodeSignature::encode(), ghidra::BlockSignature::encode(), ghidra::CopySignature::encode(), ghidra::SigManager::encode(), ghidra::StringManager::encode(), ghidra::Datatype::encode(), ghidra::TypeField::encode(), ghidra::TypeChar::encode(), ghidra::TypeUnicode::encode(), ghidra::TypeVoid::encode(), ghidra::TypePointer::encode(), ghidra::TypeArray::encode(), ghidra::TypeEnum::encode(), ghidra::TypeStruct::encode(), ghidra::TypeUnion::encode(), ghidra::TypePartialEnum::encode(), ghidra::TypePartialUnion::encode(), ghidra::TypePointerRel::encode(), ghidra::TypeCode::encode(), ghidra::TypeSpacebase::encode(), ghidra::TypeFactory::encode(), ghidra::HighVariable::encode(), ghidra::ScopeLocal::encode(), ghidra::Varnode::encode(), ghidra::InjectContextGhidra::encode(), ghidra::SourceFileIndexer::encode(), ghidra::SleighBase::encode(), ghidra::Override::encode(), ghidra::Address::encode(), ghidra::Funcdata::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::SleighBase::encodeSlaSpace(), ghidra::ContextDatabase::encodeTracked(), ghidra::Funcdata::encodeTree(), ghidra::Datatype::encodeTypedef(), ghidra::EmitMarkup::openParen(), ghidra::EmitMarkup::print(), ghidra::EmitMarkup::tagCaseLabel(), ghidra::EmitMarkup::tagComment(), ghidra::EmitMarkup::tagField(), ghidra::EmitMarkup::tagFuncName(), ghidra::EmitMarkup::tagLabel(), ghidra::EmitMarkup::tagLine(), ghidra::EmitMarkup::tagLine(), ghidra::EmitMarkup::tagOp(), ghidra::EmitMarkup::tagType(), and ghidra::EmitMarkup::tagVariable().

◆ writeBool()

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

◆ writeOpcode()

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

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

Parameters
attribIdis the given annotation
opcis the opcode

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

◆ writeSignedInteger()

virtual void ghidra::Encoder::writeSignedInteger ( const AttributeId attribId,
intb  val 
)
pure 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

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

Referenced by ghidra::EmitMarkup::beginBlock(), ghidra::EmitMarkup::closeParen(), ghidra::BlockEdge::encode(), ghidra::CPoolRecord::encode(), ghidra::UnionFacetSymbol::encode(), ghidra::FuncProto::encode(), ghidra::LoadTable::encode(), ghidra::PcodeOp::encode(), ghidra::BlockSignature::encode(), ghidra::CopySignature::encode(), ghidra::TypeField::encode(), ghidra::TypeArray::encode(), ghidra::TypePartialEnum::encode(), ghidra::TypePartialUnion::encode(), ghidra::TypePointerRel::encode(), ghidra::HighVariable::encode(), ghidra::Varnode::encode(), ghidra::SourceFileIndexer::encode(), ghidra::SleighBase::encode(), ghidra::Override::encode(), ghidra::Funcdata::encode(), ghidra::AddrSpace::encodeAttributes(), ghidra::FspecSpace::encodeAttributes(), ghidra::Datatype::encodeBasic(), ghidra::BlockGraph::encodeBody(), ghidra::BlockGoto::encodeBody(), ghidra::BlockMultiGoto::encodeBody(), ghidra::BlockIf::encodeBody(), ghidra::FlowBlock::encodeHeader(), ghidra::BlockCopy::encodeHeader(), ghidra::Symbol::encodeHeader(), ghidra::Datatype::encodeRef(), ghidra::SleighBase::encodeSlaSpace(), ghidra::Funcdata::encodeTree(), ghidra::EmitMarkup::openParen(), ghidra::EmitMarkup::tagField(), ghidra::EmitMarkup::tagLine(), and ghidra::EmitMarkup::tagLine().

◆ writeSpace()

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

◆ writeString()

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

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

Referenced by ghidra::EmitMarkup::closeParen(), ghidra::LoadImageXml::encode(), ghidra::Comment::encode(), ghidra::CPoolRecord::encode(), ghidra::FunctionSymbol::encode(), ghidra::ExternRefSymbol::encode(), ghidra::ScopeInternal::encode(), ghidra::ProtoStoreInternal::encode(), ghidra::FuncProto::encode(), ghidra::StringManager::encode(), ghidra::TypeField::encode(), ghidra::TypeEnum::encode(), ghidra::HighVariable::encode(), ghidra::SourceFileIndexer::encode(), ghidra::SleighBase::encode(), ghidra::Override::encode(), ghidra::Funcdata::encode(), ghidra::FspecSpace::encodeAttributes(), ghidra::IopSpace::encodeAttributes(), ghidra::FspecSpace::encodeAttributes(), ghidra::IopSpace::encodeAttributes(), ghidra::Datatype::encodeBasic(), ghidra::BlockGraph::encodeBody(), ghidra::ContextInternal::encodeContext(), ghidra::BlockCondition::encodeHeader(), ghidra::Symbol::encodeHeader(), ghidra::Datatype::encodeRef(), ghidra::SleighBase::encodeSlaSpace(), ghidra::Datatype::encodeTypedef(), ghidra::EmitMarkup::openParen(), ghidra::EmitMarkup::print(), ghidra::EmitMarkup::tagCaseLabel(), ghidra::EmitMarkup::tagComment(), ghidra::EmitMarkup::tagField(), ghidra::EmitMarkup::tagFuncName(), ghidra::EmitMarkup::tagLabel(), ghidra::EmitMarkup::tagOp(), ghidra::EmitMarkup::tagType(), and ghidra::EmitMarkup::tagVariable().

◆ 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::XmlEncode, and ghidra::PackedEncode.

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

◆ writeUnsignedInteger()

virtual void ghidra::Encoder::writeUnsignedInteger ( const AttributeId attribId,
uintb  val 
)
pure 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

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

Referenced by ghidra::EmitMarkup::beginReturnType(), ghidra::EmitMarkup::beginStatement(), ghidra::EmitMarkup::beginVarDecl(), ghidra::SeqNum::encode(), ghidra::Range::encode(), ghidra::TrackedContext::encode(), ghidra::XmlArchitecture::encode(), ghidra::CPoolRecord::encode(), ghidra::ConstantPoolInternal::CheapSorter::encode(), ghidra::SymbolEntry::encode(), ghidra::FunctionSymbol::encode(), ghidra::EquateSymbol::encode(), ghidra::ScopeInternal::encode(), ghidra::Database::encode(), ghidra::JumpBasicOverride::encode(), ghidra::JumpTable::encode(), ghidra::PcodeOp::encode(), ghidra::Signature::encode(), ghidra::VarnodeSignature::encode(), ghidra::BlockSignature::encode(), ghidra::CopySignature::encode(), ghidra::TypePointer::encode(), ghidra::TypeEnum::encode(), ghidra::TypePointerRel::encode(), ghidra::HighVariable::encode(), ghidra::Varnode::encode(), ghidra::SleighBase::encode(), ghidra::Funcdata::encode(), ghidra::AddrSpace::encodeAttributes(), ghidra::JoinSpace::encodeAttributes(), ghidra::FspecSpace::encodeAttributes(), ghidra::AddrSpace::encodeAttributes(), ghidra::FspecSpace::encodeAttributes(), ghidra::Datatype::encodeBasic(), ghidra::BlockGoto::encodeBody(), ghidra::BlockIf::encodeBody(), ghidra::ContextInternal::encodeContext(), ghidra::Symbol::encodeHeader(), ghidra::Datatype::encodeRef(), ghidra::Datatype::encodeTypedef(), ghidra::EmitMarkup::print(), ghidra::EmitMarkup::tagCaseLabel(), ghidra::EmitMarkup::tagComment(), ghidra::EmitMarkup::tagField(), ghidra::EmitMarkup::tagFuncName(), ghidra::EmitMarkup::tagLabel(), ghidra::EmitMarkup::tagOp(), ghidra::EmitMarkup::tagType(), and ghidra::EmitMarkup::tagVariable().


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