Understand具備普遍的API,可以讓您查詢所捕獲的有關代碼的數據。它具備三種風格:Perl,Python和C。PerlAPI比其餘兩種更強大,由於它容許與Understand GUI交互,而且不須要其餘設置。這三個API都是隻讀的,它們不會修改Understand項目。在建立Understanding Eclipse Plugin的過程當中還編寫了Java API 。可是,它更輕巧,沒有其餘API的所有功能。ide
打開一個理解項目spa
讓咱們先來看一個很是簡單的Perl API腳本。命令行
sample.plorm
使用瞭解;
$ db =理解:: open(「 c:\ projects \ test.udb」);
foreach $ file($ db-> ents(「 file」)){
打印$ file-> longname(),「 \ n」;
}blog
第一行告訴Perl解釋器您想使用Understand API庫。而後,它將打開一個Understand項目文件(c:\ projectstest.udb),並遍歷該項目中每一個文件實體的列表,並在單獨的行上打印每一個文件的名稱。
要本身運行它,請更改路徑以指向您本身的項目之一。請注意,對於Windows路徑,您須要經過將斜槓加倍來對其進行轉義。
Uperl是bin \ system目錄中的Understand隨附的perl解釋器。要運行此腳本,請打開命令行/終端並運行:
cd「 c:\ program files \ scitools \ bin \ pc-win64」或系統上的適當路徑uperl.exe myscript.pl
這是Python 3 API的相同腳本。須要在系統上安裝Python,而且正確理解Python庫。
sample.py教程
導入瞭解
db =諒解.open(「 c:\ projects \ test.udb」)
對於db.ents(「 file」)中的文件:
打印(file.longname())ip
一樣,C API也是如此。
樣本ci
#include
#include
#include「 C:\ Program Files \ SciTools \ src \ udb \ udb.h」
靜態字符* dbFilename =「 c:\ projects \ test.udb」;
main(int argc,char * argv []){
UdbStatus status = udbDbOpen(dbFilename);
UdbEntity * ents;
int entsSize;
我
udbListEntity(「 file」,&ents,&entsSize);
對於(i = 0; i printf(「%s \ n」,udbEntityNameLong(ents [i]));
}
udbListEntityFree(ents);
udbDbClos??e();
}it
生成文件class
sample.exe:sample.obj
因爲C API示例的大小,這些教程的其他部分將僅顯示Perl和Python中的示例。