retdec
Public Member Functions | Protected Attributes | List of all members
retdec::fileinfo::IterativeDistributionGetter Class Referenceabstract

#include <iterative_distribution_getter.h>

Inheritance diagram for retdec::fileinfo::IterativeDistributionGetter:
Inheritance graph
[legend]
Collaboration diagram for retdec::fileinfo::IterativeDistributionGetter:
Collaboration graph
[legend]

Public Member Functions

 IterativeDistributionGetter (FileInformation &fileInfo)
 
Getters
std::size_t getDistribution (std::size_t structIndex, std::vector< std::size_t > &distr) const
 
std::size_t getHeaderDesc (std::size_t structIndex, std::vector< std::string > &desc, std::vector< std::string > &abb) const
 
void getHeader (std::size_t structIndex, std::string &header) const
 
bool getDistributionFlags (std::size_t structIndex, std::vector< bool > &flags) const
 
Virtual getters
virtual bool getRecord (std::size_t structIndex, std::size_t recIndex, std::vector< std::string > &record) const override
 
Pure virtual getters
virtual bool getFlagDescriptors (std::size_t structIndex, std::vector< std::string > &desc, std::vector< std::string > &abbv) const =0
 
- Public Member Functions inherited from retdec::fileinfo::IterativeGetter
 IterativeGetter (FileInformation &fileInfo)
 
std::size_t getNumberOfStructures () const
 
std::size_t getNumberOfStoredRecords (std::size_t structIndex) const
 
std::size_t getHeaderElements (std::size_t structIndex, std::vector< std::string > &elements) const
 
void getTitle (std::string &structTitle) const
 
bool hasBasicInfo (std::size_t structIndex) const
 
virtual std::size_t getBasicInfo (std::size_t structIndex, std::vector< std::string > &desc, std::vector< std::string > &info) const =0
 

Protected Member Functions

Other pure virtual methods
virtual bool loadRecord (std::size_t structIndex, std::size_t recIndex, std::vector< std::string > &record)=0
 
Other methods
void loadRecords ()
 

Protected Attributes

std::vector< std::vector< std::vector< std::string > > > records
 records from all structures More...
 
std::vector< std::size_t > distribution
 distribution of header (common for all structures) More...
 
std::vector< std::string > commonHeaderDesc
 description of header elements (common for all structures) More...
 
std::vector< std::vector< std::size_t > > extraDistribution
 distribution of extra elements for each structure More...
 
std::vector< std::vector< std::string > > extraDesc
 description of extra header elements for each structure More...
 
std::vector< std::vector< bool > > distFlags
 distribution flags More...
 
std::vector< std::vector< bool > > hexMap
 map of hexadecimal elements (columns) More...
 
std::vector< std::vector< std::size_t > > hexPadding
 padding of hexadecimal columns More...
 
- Protected Attributes inherited from retdec::fileinfo::IterativeGetter
FileInformationfileinfo
 information about file More...
 
std::size_t numberOfStructures
 number of presented structures (e.g. number of symbol tables) More...
 
std::vector< std::size_t > numberOfStoredRecords
 number of records in each structure More...
 
std::vector< std::string > commonHeaderElements
 parts of header (common for all structures) More...
 
std::vector< std::size_t > numberOfExtraElements
 number of extra elements in each structure More...
 
std::vector< std::vector< std::string > > extraHeaderElements
 parts of header (specific for each structure) More...
 
std::string title
 title of presented structure More...
 

Detailed Description

Abstract class for loading information about file.

This class enable iterative queries to a set of items (e.g. queries to symbols from symbol tables).

Constructor & Destructor Documentation

◆ IterativeDistributionGetter()

retdec::fileinfo::IterativeDistributionGetter::IterativeDistributionGetter ( FileInformation fileInfo)

Constructor

Parameters
fileInfoInformation about file

Constructor in subclass must initialize distribution, commonHeaderDesc, extraDistribution, extraDesc and other members which are descripted in constructor of superclass.

Constructor in subclass must also ensure that the number of elements in distribution, commonHeaderElements and commonHeaderDesc are the same. Length of element in commonHeaderElements may be less than value on corresponding index in distribution. In which case header returned by method getHeader() is filled by spaces. If length of element is greater or equal, returned header will be automatically erased.

Constructor in subclass must furthermore ensure that each element in extraDistribution and in extraDesc contains exactly as many elements as numberOfExtraElements[i], where i is index of extraDistribution, extraDesc and numberOfExtraElements.

Finally, constructor in subclass must invoke method loadRecords.

Member Function Documentation

◆ getDistribution()

std::size_t retdec::fileinfo::IterativeDistributionGetter::getDistribution ( std::size_t  structIndex,
std::vector< std::size_t > &  distr 
) const

Get distribution of header

Parameters
structIndexIndex of selected structure (indexed from 0)
distrInto this parameter is stored distribution (length) of the individual parts of header. At end of distr is stored distribution for extra elements of selected structure.
Returns
Total length of header

Before loading information about distribution, everything from vector distr is deleted If structIndex is out of range, method returns 0 and distr is left unchanged.

◆ getDistributionFlags()

bool retdec::fileinfo::IterativeDistributionGetter::getDistributionFlags ( std::size_t  structIndex,
std::vector< bool > &  flags 
) const

Get distribution flags of one structure

Parameters
structIndexIndex of selected structure (indexed from 0)
flagsInto this parameter the flags are stored.
Returns
true if flags were successfully saved, false otherwise

Before loading flags, everything from vector flags is deleted.

If method returns true, flags contains as many elements as vector returned by the method getDistribution(structIndex).

If structIndex is out of range, method returns false.

◆ getFlagDescriptors()

bool retdec::fileinfo::IterativeDistributionGetter::getFlagDescriptors ( std::size_t  structIndex,
std::vector< std::string > &  desc,
std::vector< std::string > &  abbv 
) const
pure virtual

Get descriptors (and its abbreviations) of all records in structure

Parameters
structIndexIndex of selected structure (indexed from 0)
descVector for save descriptors
abbvVector for save abbreviations
Returns
true if index of selected structure is valid, false otherwise. If index is not valid, desc and abbv are left unchanged.

Into desc is stored each flag descriptor, which is assigned to at least one record. Into abbv are stored abbreviations of descriptors, which are stored in desc.

Before loading descriptors, everything from vectors desc and abbv is deleted.

Implemented in retdec::fileinfo::VisualBasicExternTablePlainGetter, retdec::fileinfo::VersionInfoStringTablePlainGetter, retdec::fileinfo::VersionInfoLanguageTablePlainGetter, retdec::fileinfo::TypeRefTablePlainGetter, retdec::fileinfo::TlsInfoPlainGetter, retdec::fileinfo::SymbolTablesPlainGetter, retdec::fileinfo::StringsPlainGetter, retdec::fileinfo::SegmentPlainGetter, retdec::fileinfo::SectionPlainGetter, retdec::fileinfo::RichHeaderPlainGetter, retdec::fileinfo::ResourcePlainGetter, retdec::fileinfo::RelocationTablesPlainGetter, retdec::fileinfo::PatternMatchesPlainGetter, retdec::fileinfo::MissingDepsPlainGetter, retdec::fileinfo::LoaderInfoPlainGetter, retdec::fileinfo::ImportTablePlainGetter, retdec::fileinfo::ExportTablePlainGetter, retdec::fileinfo::ElfNotesPlainGetter, retdec::fileinfo::ElfCoreMapPlainGetter, retdec::fileinfo::ElfAuxVPlainGetter, retdec::fileinfo::DynamicSectionsPlainGetter, retdec::fileinfo::DataDirectoryPlainGetter, and retdec::fileinfo::AnomaliesPlainGetter.

◆ getHeader()

void retdec::fileinfo::IterativeDistributionGetter::getHeader ( std::size_t  structIndex,
std::string &  header 
) const

Get header of presented structure

Parameters
structIndexIndex of selected structure (indexed from 0)
headerInto this parameter the header is stored. At end of this parameter is stored short description of extra information for selected structure.

If structIndex is out of range, header is left unchanged

Into vectors desc and abb are stored only descriptors of significant elements. Significant element is each element (column), which has set at least one value in related structure.

◆ getHeaderDesc()

std::size_t retdec::fileinfo::IterativeDistributionGetter::getHeaderDesc ( std::size_t  structIndex,
std::vector< std::string > &  desc,
std::vector< std::string > &  abb 
) const

Get description of header elements

Parameters
structIndexIndex of selected structure (indexed from 0)
descVector for save descriptors (descriptor is full description of header element)
abbVector for save abbreviations of descriptors (abbreviation is equal to short description in header)
Returns
Number of stored descriptors

The first element in abb corresponds to the first element in desc etc. Before loading information, everything from vectors desc and abb is deleted. It is guaranteed that the number of elements in desc and abb are the same. At end of both vectors is stored description (or abbreviation) for extra elements of selected structure.

If structIndex is out of range, method returns 0 and desc and abb is left unchanged.

Into vectors desc and abb are stored only descriptors of significant elements. Significant element is each element (column), which has set at least one value in related structure.

◆ getRecord()

bool retdec::fileinfo::IterativeDistributionGetter::getRecord ( std::size_t  structIndex,
std::size_t  recIndex,
std::vector< std::string > &  record 
) const
overridevirtual

If method returns true, record contains as many elements as vector returned by the method getDistribution(structIndex).

More detailed description is in superclass.

Implements retdec::fileinfo::IterativeGetter.

◆ loadRecord()

bool retdec::fileinfo::IterativeDistributionGetter::loadRecord ( std::size_t  structIndex,
std::size_t  recIndex,
std::vector< std::string > &  record 
)
protectedpure virtual

Load one record

Parameters
structIndexIndex of selected structure (indexed from 0)
recIndexIndex of record in selected structure (indexed from 0)
recordVector for save record. At end of vector are stored special additional information, if these information are present. Number and semantics of additional information may be different for every separate structure.
Returns
true if record was successfully saved, false otherwise

Before loading record, everything from vector record is deleted.

If method returns true, record contains as many elements as vector returned by the method getHeaderElements(structIndex) as well as vector returned by the method getDistribution(structIndex).

If structIndex or recIndex is out of range, method returns false.

Implemented in retdec::fileinfo::VisualBasicExternTablePlainGetter, retdec::fileinfo::VersionInfoStringTablePlainGetter, retdec::fileinfo::VersionInfoLanguageTablePlainGetter, retdec::fileinfo::TypeRefTablePlainGetter, retdec::fileinfo::TlsInfoPlainGetter, retdec::fileinfo::SymbolTablesPlainGetter, retdec::fileinfo::StringsPlainGetter, retdec::fileinfo::SegmentPlainGetter, retdec::fileinfo::SectionPlainGetter, retdec::fileinfo::RichHeaderPlainGetter, retdec::fileinfo::ResourcePlainGetter, retdec::fileinfo::RelocationTablesPlainGetter, retdec::fileinfo::PatternMatchesPlainGetter, retdec::fileinfo::MissingDepsPlainGetter, retdec::fileinfo::LoaderInfoPlainGetter, retdec::fileinfo::ImportTablePlainGetter, retdec::fileinfo::ExportTablePlainGetter, retdec::fileinfo::ElfNotesPlainGetter, retdec::fileinfo::ElfCoreMapPlainGetter, retdec::fileinfo::ElfAuxVPlainGetter, retdec::fileinfo::DynamicSectionsPlainGetter, retdec::fileinfo::DataDirectoryPlainGetter, and retdec::fileinfo::AnomaliesPlainGetter.

◆ loadRecords()

void retdec::fileinfo::IterativeDistributionGetter::loadRecords ( )
protected

Load records from all structures and store them into member records

This method load records from all structures and set member distFlags. Member distFlags represents so-called distribution flags. This flags consist of set of vectors. Each vector represents flags for related structure (first vector represents flags for first structure, etc.). Each distribution flag in each vector is related to one item from commonHeaderElements and to one item from commonHeaderDesc (first item from distFlags to first item from commonHeaderElements and to first item from commonHeaderDesc, etc.) of related structure. If flag is set to false, related item from commonHeaderElements (and from commonHeaderDesc) will not be included to presented header. If any structure contains extra information, surplus values in distFlags represents flags for extraHeaderElements[structIndex] and for extraDesc[structIndex].

This method must be invoke in constructor of subclass after members numberOfStructures and numberOfStoredRecords are set.

Member Data Documentation

◆ commonHeaderDesc

std::vector<std::string> retdec::fileinfo::IterativeDistributionGetter::commonHeaderDesc
protected

description of header elements (common for all structures)

◆ distFlags

std::vector<std::vector<bool> > retdec::fileinfo::IterativeDistributionGetter::distFlags
protected

distribution flags

◆ distribution

std::vector<std::size_t> retdec::fileinfo::IterativeDistributionGetter::distribution
protected

distribution of header (common for all structures)

◆ extraDesc

std::vector<std::vector<std::string> > retdec::fileinfo::IterativeDistributionGetter::extraDesc
protected

description of extra header elements for each structure

◆ extraDistribution

std::vector<std::vector<std::size_t> > retdec::fileinfo::IterativeDistributionGetter::extraDistribution
protected

distribution of extra elements for each structure

◆ hexMap

std::vector<std::vector<bool> > retdec::fileinfo::IterativeDistributionGetter::hexMap
protected

map of hexadecimal elements (columns)

◆ hexPadding

std::vector<std::vector<std::size_t> > retdec::fileinfo::IterativeDistributionGetter::hexPadding
protected

padding of hexadecimal columns

◆ records

std::vector<std::vector<std::vector<std::string> > > retdec::fileinfo::IterativeDistributionGetter::records
protected

records from all structures


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