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

An annotation for a data element to being transferred to/from a stream. More...

#include <marshal.hh>

Collaboration diagram for ghidra::AttributeId:
[legend]

Public Member Functions

 AttributeId (const string &nm, uint4 i, int4 scope=0)
 Construct given a name and id.
 
const string & getName (void) const
 Get the attribute's name.
 
uint4 getId (void) const
 Get the attribute's id.
 
bool operator== (const AttributeId &op2) const
 Test equality with another AttributeId.
 

Static Public Member Functions

static uint4 find (const string &nm, int4 scope)
 Find the id associated with a specific attribute name.
 
static void initialize (void)
 Populate a hashtable with all AttributeId objects.
 

Static Private Member Functions

static vector< AttributeId * > & getList (void)
 Retrieve the list of static AttributeId.
 

Private Attributes

string name
 The name of the attribute.
 
uint4 id
 The (internal) id of the attribute.
 

Static Private Attributes

static unordered_map< string, uint4 > lookupAttributeId
 A map of AttributeId names to their associated id.
 

Friends

bool operator== (uint4 id, const AttributeId &op2)
 Test equality of a raw integer id with an AttributeId.
 
bool operator== (const AttributeId &op1, uint4 id)
 Test equality of an AttributeId with a raw integer id.
 

Detailed Description

An annotation for a data element to being transferred to/from a stream.

This class parallels the XML concept of an attribute on an element. An AttributeId describes a particular piece of data associated with an ElementId. The defining characteristic of the AttributeId is its name. Internally this name is associated with an integer id. The name (and id) uniquely determine the data being labeled, within the context of a specific ElementId. Within this context, an AttributeId labels either

  • An unsigned integer
  • A signed integer
  • A boolean value
  • A string

The same AttributeId can be used to label a different type of data when associated with a different ElementId.

Constructor & Destructor Documentation

◆ AttributeId()

ghidra::AttributeId::AttributeId ( const string &  nm,
uint4  i,
int4  scope = 0 
)

Construct given a name and id.

This constructor should only be invoked for static objects. It registers the attribute for inclusion in the global hashtable.

Parameters
nmis the name of the attribute
iis an id to associate with the attribute
scopeis an id for the scope of this attribute

References getList().

Member Function Documentation

◆ find()

uint4 ghidra::AttributeId::find ( const string &  nm,
int4  scope 
)
inlinestatic

Find the id associated with a specific attribute name.

The name is looked up in the scoped list of attributes. If the attribute is not in the list, a special placeholder attribute, ATTRIB_UNKNOWN, is returned as a placeholder for attributes with unrecognized names.

Parameters
nmis the name of the attribute
scopeis the id of the scope in which to lookup of the name
Returns
the associated id

References find(), id, and lookupAttributeId.

Referenced by find(), and ghidra::XmlDecode::getNextAttributeId().

◆ getList()

vector< AttributeId * > & ghidra::AttributeId::getList ( void  )
staticprivate

Retrieve the list of static AttributeId.

Access static vector of AttributeId objects that are registered during static initialization The list itself is created once on the first call to this method.

Returns
a reference to the vector

Referenced by AttributeId(), and initialize().

◆ initialize()

void ghidra::AttributeId::initialize ( void  )
static

Populate a hashtable with all AttributeId objects.

Fill the hashtable mapping attribute names to their id, from registered attribute objects.

References getList(), id, lookupAttributeId, and name.


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