winIDEA SDK
|
This class provides convenient access to coverage data exported to XML file, so that writing XML parser is not required.
Use class CCoverageController2 to record and export the data.
Instances of this class chould be obtained with one of createInstance() static methods.
Two ways of parsing are provided (see parameter isLoadDataInMemory
in methods createInstance()):
createInstance() getParserWarnings() closeParser() use getter methods as needed
createInstance()
getParserWarnings()
then either:
call getStatistic() if you are interested in coverage
statistic of one area only
call getIterator() to obtain information about all areas.
Once iterator's method hasNext() returns false
,
this object can no longer be used.
finally call method closeParser()
#include <CCoverageData2.h>
Public Member Functions | |
void | closeParser () |
This method releases parser resources and closes XML file. More... | |
CCoverageMetaInfoSPtr | getCoverageMetaInfo () |
Returns coverage meta-data as specified by the user in winIDEA coverage 'Set information' dialog. More... | |
CCoverageStatIteratorSPtr | getIterator (CCoverageStatistic2::EAreaType areaType) |
Returns iterator, which iterates all nodes in coverage file sequentially, and returns only nodes of the given type. More... | |
std::string | getParserWarnings () |
This method returns warnings related to input XML document. More... | |
CCoverageStatistic2SPtr | getRoot () |
Returns root node of type CCoverageStatistic2, which contains all other nodes. More... | |
CCoverageStatistic2SPtr | getStatistic (CCoverageStatistic2::EAreaType areaType, const std::string &areaName) |
This method searches the coverage data tree and returns the first node with the given type and name found. More... | |
CCoverageStatistic2SPtr | getStatistic (const std::string &partition, const std::string &folder, const std::string &module, const std::string &qualFuncName) |
Returns statistic for the given function. More... | |
Static Public Member Functions | |
static CCoverageData2SPtr | createInstance (CCoverageController2SPtr coverageCtrl, const std::string &exportFileName, bool isLoadDataInMemory) |
This factory method exports data to file, and returns initialized object. More... | |
static CCoverageData2SPtr | createInstance (const std::string &fileName, bool isLoadDataInMemory) |
This factory method parses statistic information from coverage XML export file and returns initialized object. More... | |
void isys::CCoverageData2::closeParser | ( | ) |
This method releases parser resources and closes XML file.
If this method is not called, the XML file remains opened and can not be overwritten or deleted until the application exits. Furthermore, memory allocated by by this object is not released until this method is called!
Python example: test_get_root.py
|
static |
This factory method exports data to file, and returns initialized object.
Use it, when you've just recorded data (have CCoverageController2 object available), and have not exported it yet. Note also that this method is not as flexible as direct export and method createInstance(fileName, isLoadDataInMemory).
Note: if exportFileName
is relative, it is saved relative to winIDEA working directory, not the script working directory. This method tries to do its best to open the saved file, but if winIDEA is on remote host, it will fail. In such cases try to export the coverage data with CCoverageController2::exportData() and use the overloaded method createInstance(fileName)
instead.
Important: To release memory and file, always call closeParser() when done using parser!
coverageCtrl | coverage document controller which will be used to obtain data. |
exportFileName | name of the file to export data to |
isLoadDataInMemory | if true , the exported file is immediately parsed and all data is loaded into memory. This provides faster browsing, but may not be appropriate for large coverage files. If false , use iterator (see getIterator()) to parse statistic node by node. This approach is not as flexible as the frst one, but it is very memory efficient. |
Python example: test_coverage_create_instance.py
|
static |
This factory method parses statistic information from coverage XML export file and returns initialized object.
Important: To release memory and file, always call closeParser() when done using parser!
fileName | name of the file with coverage XML export. If you use relative file path, be aware that script working directory is used as a starting point, not winIDEA workspace directory. |
isLoadDataInMemory | if true , the exported file is immediately parsed and all data is loaded into memory. This provides faster browsing, but may not be appropriate for large coverage files. If false , use iterator (see getIterator()) to parse statistic node by node. This approach is not as flexible as the first one, but it is very memory efficient. |
Python example: test_coverage_create_instance.py
CCoverageMetaInfoSPtr isys::CCoverageData2::getCoverageMetaInfo | ( | ) |
Returns coverage meta-data as specified by the user in winIDEA coverage 'Set information' dialog.
Python example: test_get_coverage_meta_info.py
CCoverageStatIteratorSPtr isys::CCoverageData2::getIterator | ( | CCoverageStatistic2::EAreaType | areaType | ) |
Returns iterator, which iterates all nodes in coverage file sequentially, and returns only nodes of the given type.
Specify areaType
= EAnyArea
to get all nodes.
Python example: test_get_iterator.py
std::string isys::CCoverageData2::getParserWarnings | ( | ) |
This method returns warnings related to input XML document.
If there were no warnings, an empty string is returned. Always call this method after createInstance(). If XML document is made with newer version of winIDEA than SDK, it will warn you about possible missing info.
Python example: test_get_root.py
CCoverageStatistic2SPtr isys::CCoverageData2::getRoot | ( | ) |
Returns root node of type CCoverageStatistic2, which contains all other nodes.
This method may be called only if all data is loaded into memory (see the second parameter of createInstance()).
IllegalStateException | if coverage data is not loaded into memory (see the second parameter in createInstance()). |
Python example: test_get_root.py
CCoverageStatistic2SPtr isys::CCoverageData2::getStatistic | ( | CCoverageStatistic2::EAreaType | areaType, |
const std::string & | areaName | ||
) |
This method searches the coverage data tree and returns the first node with the given type and name found.
Although this method works also when data is not loaded into memory (createInstance() was called with
parameter isLoadDataInMemory
= false
), the parser has to be closed after each call and this class instantiated again, which makes it very inefficient. Also, if iterator was used before this method was called, results are unpredictable, and calling getIterator() after calling this method is forbidden.
Python example: test_get_statistic.py
CCoverageStatistic2SPtr isys::CCoverageData2::getStatistic | ( | const std::string & | partition, |
const std::string & | folder, | ||
const std::string & | module, | ||
const std::string & | qualFuncName | ||
) |
Returns statistic for the given function.
This works only when data is loaded into memory.
partition | name of download file, for example sample.elf |
folder | folder where source file is located, may be given relative to winIDEA workspace (xjrf file). |
module | name of a source file, which contains the function, for example main.c |
qualFuncName | name of the function for which we want to get coverage statistics, for example main |
Python example: test_get_statistic.py