retdec
Public Types | Public Member Functions | Private Attributes | List of all members
retdec::llvmir2hll::APICallInfo Class Reference

A representation of information about an API call. More...

#include <api_call_info.h>

Collaboration diagram for retdec::llvmir2hll::APICallInfo:
Collaboration graph
[legend]

Public Types

using ParamNum = unsigned
 
using ParamBindMap = std::map< ParamNum, std::string >
 Mapping of a parameter number into a bind ID. More...
 
using param_bind_iterator = ParamBindMap::const_iterator
 

Public Member Functions

 APICallInfo (std::string funcName)
 Constructs an API call information for a function named funcName. More...
 
bool operator== (const APICallInfo &other) const
 Returns true if this info is equal to other, false otherwise. More...
 
bool operator!= (const APICallInfo &other) const
 Returns true if this info is not equal to other, false otherwise. More...
 
Function Name Accessors
const std::string getFuncName () const
 Returns the name of the function that this API call information describes. More...
 
Return Value Binding
APICallInfobindReturnValue (const std::string &bindId)
 Binds bindId to the return value. More...
 
bool hasBoundReturnValue () const
 Returns true if the return value has been bound to some ID, false otherwise. More...
 
std::string getReturnValueBind () const
 Returns the ID of the bind to the return value. More...
 
Parameter Binding
APICallInfobindParam (ParamNum n, const std::string &bindId)
 Binds bindId to the given parameter. More...
 
bool hasBoundParam (ParamNum n) const
 Returns true if parameter number n has been bound to some ID, false otherwise. More...
 
std::string getParamBind (ParamNum n) const
 Returns the ID of the bind to the given parameter. More...
 
param_bind_iterator param_bind_begin () const
 Returns an iterator to the first parameter bind. More...
 
param_bind_iterator param_bind_end () const
 Returns an iterator past the last parameter bind. More...
 

Private Attributes

std::string funcName
 Name of the function. More...
 
std::string returnValueBind
 ID of the bind to the return value. If there is no bind, it is empty. More...
 
ParamBindMap paramBinds
 

Detailed Description

A representation of information about an API call.

Use APICallInfoSeq to join serveral information into a sequence.

Member Typedef Documentation

◆ param_bind_iterator

using retdec::llvmir2hll::APICallInfo::param_bind_iterator = ParamBindMap::const_iterator

Iterator for iterating over ParamBindMap. Attributes (i is an iterator):

  • i->first is the parameter's number,
  • i->second is the parameter's bind ID.

◆ ParamBindMap

Mapping of a parameter number into a bind ID.

◆ ParamNum

Parameter number (the first parameter has number 1, the second has number 2 etc.)

Constructor & Destructor Documentation

◆ APICallInfo()

retdec::llvmir2hll::APICallInfo::APICallInfo ( std::string  funcName)

Constructs an API call information for a function named funcName.

Preconditions
  • funcName is nonempty

Member Function Documentation

◆ bindParam()

APICallInfo & retdec::llvmir2hll::APICallInfo::bindParam ( ParamNum  n,
const std::string &  bindId 
)

Binds bindId to the given parameter.

Parameters
[in]nParameter's number (the first parameter has number 1, the second has number 2 etc.)
[in]bindIdID to be bound to the parameter number n.
Returns
A reference to the modified info. This allows the bind calls to be chained, like this:
APICallInfo("fopen")
.bindRetVal("X")
.bindParam(1, "Y")
APICallInfo(std::string funcName)
Constructs an API call information for a function named funcName.
Definition: api_call_info.cpp:24

If this function is called several times, the last bind is stored.

Preconditions
  • n > 0
  • bindId is nonempty

◆ bindReturnValue()

APICallInfo & retdec::llvmir2hll::APICallInfo::bindReturnValue ( const std::string &  bindId)

Binds bindId to the return value.

Returns
A reference to the modified info. This allows the bind calls to be chained, like this:
APICallInfo("fopen")
.bindRetVal("X")
.bindParam(1, "Y")

If this function is called several times, the last bind is stored.

Preconditions
  • bindId is nonempty

◆ getFuncName()

const std::string retdec::llvmir2hll::APICallInfo::getFuncName ( ) const

Returns the name of the function that this API call information describes.

◆ getParamBind()

std::string retdec::llvmir2hll::APICallInfo::getParamBind ( ParamNum  n) const

Returns the ID of the bind to the given parameter.

Parameters
[in]nParameter's number (the first parameter has number 1, the second has number 2 etc.)

If the parameter has not been bound to anything, this function returns the empty string.

Preconditions
  • n > 0
  • the parameter is bound

◆ getReturnValueBind()

std::string retdec::llvmir2hll::APICallInfo::getReturnValueBind ( ) const

Returns the ID of the bind to the return value.

Preconditions
  • the return value is bound

◆ hasBoundParam()

bool retdec::llvmir2hll::APICallInfo::hasBoundParam ( ParamNum  n) const

Returns true if parameter number n has been bound to some ID, false otherwise.

Parameters
[in]nParameter's number (the first parameter has number 1, the second has number 2 etc.)
Preconditions
  • n > 0

◆ hasBoundReturnValue()

bool retdec::llvmir2hll::APICallInfo::hasBoundReturnValue ( ) const

Returns true if the return value has been bound to some ID, false otherwise.

◆ operator!=()

bool retdec::llvmir2hll::APICallInfo::operator!= ( const APICallInfo other) const

Returns true if this info is not equal to other, false otherwise.

◆ operator==()

bool retdec::llvmir2hll::APICallInfo::operator== ( const APICallInfo other) const

Returns true if this info is equal to other, false otherwise.

◆ param_bind_begin()

APICallInfo::param_bind_iterator retdec::llvmir2hll::APICallInfo::param_bind_begin ( ) const

Returns an iterator to the first parameter bind.

◆ param_bind_end()

APICallInfo::param_bind_iterator retdec::llvmir2hll::APICallInfo::param_bind_end ( ) const

Returns an iterator past the last parameter bind.

Member Data Documentation

◆ funcName

std::string retdec::llvmir2hll::APICallInfo::funcName
private

Name of the function.

◆ paramBinds

ParamBindMap retdec::llvmir2hll::APICallInfo::paramBinds
private

ID of the binds to parameters (if any). If there are no binds, it is empty.

◆ returnValueBind

std::string retdec::llvmir2hll::APICallInfo::returnValueBind
private

ID of the bind to the return value. If there is no bind, it is empty.


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