Advanced Usage
This example covers more advanced usage of the ViennaIPD API. The library provides, for example, iterators to traverse the various objects and their children.
Advanced ViennaIPD API usage
#include <iostream> #include "ipd.h" int main(int argc, char** argv) { // some variables ipdIterator_t *iNode = NULL; ipdTreeNode_t *tn = NULL; // inititalize the ViennaIPD library ipdInit(NULL, NULL); // create a database with an arbitrary name ipdCreateBase("NameOfTheDatabase", 0); // read a ViennaIPD file ipdReadInputDeck("viennaipd.ipd"); // create an iterator ipdIteratorNewAtRootSection(&iNode, ipdANY); // traverse the nodes on the root level while (ipdIteratorIsValid(iNode)) { // get the name of the current node ipdConstString itemName = ipdIteratorGetItemName(iNode); // is the current object a variable ... if (ipdIteratorGetType(iNode) == ipdVARIABLE) // or a section? else if (ipdIteratorGetType(iNode) == ipdSECTION) // increase the iterator ipdIteratorDoNext(iNode); } // free the ViennaIPD internal datastructures ipdIteratorFree(iNode); ipdFreeAll(); return 0; }