#include #include #include #include #include #include #include struct Property { QString retType; QString name; QString type; QString desc; }; struct Param { QString name; QString type; QString desc; }; typedef QVector ParamList; typedef QVector ParamSetList; struct Event { ParamList params; QString wslot; QString wsignal; QString signal; QString desc; QString name; }; struct Method { ParamSetList params; bool vparamstyle; bool ctor; QString name; QString retType; QString desc; }; struct Class { QString type; QString name; QVector props; QVector methods; QVector events; }; int main(int argc, char *argv[]) { QTime t; t.start(); Q_UNUSED(argc) Q_UNUSED(argv) QDomDocument doc; QFile loc(*(argv + 1)); QDomElement root; QVector classList; loc.open(QIODevice::ReadOnly); doc.setContent(&loc); root = doc.documentElement(); QDomNodeList classes = root.elementsByTagName("class"); for (unsigned int i = 0; i < classes.length(); i++) { Class temp; QDomElement classEle = classes.at(i).toElement(); temp.name = classEle.attribute("name"); temp.type = classEle.attribute("type"); QDomNodeList events = classEle.elementsByTagName("event"); for (unsigned int j = 0; j < events.length(); j++) { Event eTemp; QDomElement event = events.at(j).toElement(); eTemp.name = event.attribute("name"); ParamList params; QDomNodeList prms = event.elementsByTagName("param"); for (unsigned int k = 0; k < prms.length(); k++) { Param pTemp; QDomElement param = prms.at(k).toElement(); pTemp.name = param.attribute("name"); pTemp.type = param.attribute("type"); pTemp.desc = param.text(); params.push_back(pTemp); } eTemp.params = params; eTemp.wsignal = event.attribute("wsignal", ""); eTemp.wslot = event.attribute("wslot", ""); eTemp.signal = event.attribute("signal", ""); eTemp.desc = event.elementsByTagName("desc").at(0).toElement().text(); temp.events.push_back(eTemp); } QDomNodeList methods = classEle.elementsByTagName("method"); for (unsigned int j = 0; j < methods.length(); j++) { Method mTemp; QDomElement method = methods.at(j).toElement(); mTemp.name = method.attribute("name"); mTemp.ctor = false; ParamSetList paramsl; mTemp.vparamstyle = (method.attribute("vparamstyle", "") == "true"); mTemp.ctor = (method.attribute("constructor", "") == "true") ? (true) : (false); if (!mTemp.vparamstyle) { QDomNodeList prms = method.elementsByTagName("param"); ParamList params; for (unsigned int k = 0; k < prms.length(); k++) { Param pTemp; QDomElement param = prms.at(k).toElement(); pTemp.name = param.attribute("name"); pTemp.type = param.attribute("type"); pTemp.desc = param.text(); params.push_back(pTemp); } paramsl.push_back(params); } else { QDomNodeList pRms = method.elementsByTagName("paramset"); for (unsigned int k = 0; k < pRms.length(); k++) { QDomNodeList prms = pRms.at(k).toElement().elementsByTagName("param"); ParamList params; for (unsigned int f = 0; f < prms.length(); f++) { Param pTemp; QDomElement param = prms.at(f).toElement(); pTemp.name = param.attribute("name"); pTemp.type = param.attribute("type"); pTemp.desc = param.text(); params.push_back(pTemp); } paramsl.push_back(params); } } mTemp.params = paramsl; mTemp.retType = method.elementsByTagName("return").at(0).toElement().attribute("type", ""); mTemp.desc = method.elementsByTagName("desc").at(0).toElement().text(); temp.methods.push_back(mTemp); } QDomNodeList props = classEle.elementsByTagName("property"); for (unsigned int j = 0; j < props.length(); j++) { Property prTemp; QDomElement prop = props.at(j).toElement(); prTemp.name = prop.attribute("name"); prTemp.desc = prop.elementsByTagName("desc").at(0).toElement().text(); prTemp.retType = prop.elementsByTagName("return").at(0).toElement().attribute("type", ""); prTemp.type = prop.attribute("type"); temp.props.push_back(prTemp); } classList.push_back(temp); } /* OUTPUT MANUAL */ std::cout << "" << std::endl << "" << std::endl << " " << std::endl << " KWinScripting :: APIDoX" << std::endl << " " << std::endl << " " << std::endl << std::endl << " " << std::endl << "
" << std::endl; for (int i = 0; i < classList.size(); i++) { Class here = classList.at(i); std::cout << "
" << std::endl << "

" << here.name.toStdString() << "[" << here.type.toStdString() << "]

" << std::endl; if (here.events.size() != 0) { std::cout << "
" << std::endl << "

Events

" << std::endl; for (int j = 0; j < here.events.size(); j++) { std::cout << "
" << std::endl << "

" << here.name.toStdString() << "." << here.events.at(j).name.toStdString() << "

" << std::endl << "

" << here.events.at(j).desc.toStdString() << "

" << std::endl; ParamList p = here.events.at(j).params; if (p.size() > 0) { std::cout << "
    " << std::endl; for (int k = 0; k < p.size(); k++) { std::cout << "
  • " << p.at(k).name.toStdString() << " {" << p.at(k).type.toStdString() << "}: " << p.at(k).desc.toStdString() << "
  • " << std::endl; } std::cout << "
" << std::endl; } std::cout << "
" << std::endl; } std::cout << "
" << std::endl; } if (here.methods.size() != 0) { std::cout << "
" << std::endl << "

Methods

" << std::endl; for (int j = 0; j < here.methods.size(); j++) { std::cout << "
" << std::endl << "

" << here.name.toStdString() << "." << here.methods.at(j).name.toStdString(); if (here.methods.at(j).retType != "") { std::cout << "[ret: " << here.methods.at(j).retType.toStdString() << "] "; } if (here.methods.at(j).ctor) { std::cout << "[constructor]"; } if (here.methods.at(j).vparamstyle) { std::cout << "[variable parameter styles]"; } std::cout << "

" << std::endl; ParamSetList pslist = here.methods.at(j).params; std::cout << "
    " << std::endl; if (pslist.size() == 0) { std::cout << "
  • " << here.name.toStdString() << "." << here.methods.at(j).name.toStdString() << "()
  • " << std::endl; } else { for (int m = 0; m < pslist.size(); m++) { ParamList plist = pslist.at(m); std::cout << "
  • " << here.name.toStdString() << "." << here.methods.at(j).name.toStdString() << "("; for (int f = 0; f < plist.size(); f++) { std::cout << plist.at(f).name.toStdString() << " {" << plist.at(f).type.toStdString() << "}"; if (f != plist.size() - 1) { std::cout << ", "; } } std::cout << ")
  • " << std::endl; } } std::cout << "
" << std::endl; std::cout << "

" << here.methods.at(j).desc.toStdString() << "

" << std::endl; if (pslist.size() != 0) { for (int m = 0; m < pslist.size(); m++) { ParamList plist = pslist.at(m); if (plist.size() == 0) { continue; } std::cout << "

" << here.methods.at(j).name.toStdString() << "("; for (int f = 0; f < plist.size(); f++) { std::cout << plist.at(f).name.toStdString() << " {" << plist.at(f).type.toStdString() << "}"; if (f != plist.size() - 1) { std::cout << ", "; } } std::cout << ")
" << std::endl; std::cout << "

    " << std::endl; for (int f = 0; f < plist.size(); f++) { std::cout << "
  • " << plist.at(f).name.toStdString() << " {" << plist.at(f).type.toStdString() << "}: " << plist.at(f).desc.toStdString() << "
  • " << std::endl; } std::cout << "
" << std::endl; std::cout << "

" << std::endl; } } std::cout << "
" << std::endl; } std::cout << "
" << std::endl; } if (here.props.size() != 0) { std::cout << "
" << std::endl << "

Properties

" << std::endl; for (int j = 0; j < here.props.size(); j++) { std::cout << "
" << std::endl << "

" << here.name.toStdString() << "." << here.props.at(j).name.toStdString() << " [ret: " << here.props.at(j).retType.toStdString() << "] [" << here.props.at(j).type.toStdString() << "]

" << std::endl << "

" << here.props.at(j).desc.toStdString() << "

" << std::endl; std::cout << "
" << std::endl; } std::cout << "
" << std::endl; } std::cout << "
" << std::endl; } std::cout << "
" << std::endl << " " << std::endl << ""; return 0; }