00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
#include "doxydoc.h"
00011
00012
#include <list>
00013
00014
#include <qstring.h>
00015
#include <qstringlist.h>
00016
#include <qdom.h>
00017
#include <qdir.h>
00018
#include <qfile.h>
00019
#include <qregexp.h>
00020
00021 void DoxyDoc::formatType(
QString& str ) {
00022 str.replace(
QRegExp(
" "),
"" );
00023 }
00024
00025 DoxyDoc::DoxyDoc(
const QStringList& dir ) {
00026
for (uint i = 0; i < dir.count(); ++i)
00027
m_dirs.push_back(
QDir(*(dir.at(i))));
00028 }
00029
00030
00031 QString DoxyDoc::functionDescription(
const QString& tmpscope,
const QString& name,
const QString& tmptype,
const QString& tmparguments) {
00032
QString scope = tmpscope;
00033
bool foundfile =
false;
00034
00035
QString filename =
"/class" + scope.replace(
QRegExp(
"_"),
"__").replace(
QRegExp(
"::"),
"_1_1" ) +
".xml";
00036
00037
00038
for (std::list<QDir>::const_iterator ci =
m_dirs.begin(); !foundfile && ci !=
m_dirs.end(); ++ci){
00039
if (QFile::exists( ci->path() + filename)){
00040
if (
m_file.name() != ci->path() + filename ) {
00041
m_file.close();
00042
m_file.setName( ci->path() + filename );
00043
if ( !
m_file.open( IO_ReadOnly ) ) {
00044
m_file.setName(
"" );
00045
return "";
00046 }
00047
QDomDocument m_doc;
00048 m_doc.setContent(
m_file.readAll() );
00049
m_file.close();
00050
m_list = m_doc.elementsByTagName(
"memberdef" );
00051 foundfile =
true;
00052
00053 }
else
00054 foundfile =
true;
00055 }
00056 }
00057
if (!foundfile)
00058
return QString::null;
00059
00060
QString type = tmptype;
00061
formatType( type );
00062
00063
for ( uint i = 0; i <
m_list.count(); ++i ) {
00064
00065
QDomElement elem =
m_list.item(i).toElement();
00066
if ((elem.elementsByTagName(
"name").item(0).toElement().text() == name) && elem.elementsByTagName(
"type").item(0).toElement().text() == tmptype){
00067
QDomNodeList paramnodes = elem.elementsByTagName(
"param");
00068
QString nodearguments =
"", arguments = tmparguments;
00069
for (
unsigned int j = 0; j < paramnodes.count(); ++j )
00070 nodearguments += paramnodes.item( j ).childNodes().item( 0 ).toElement().text() +
",";
00071
if ( nodearguments !=
"") {
00072 nodearguments = nodearguments.left( nodearguments.length() - 1 );
00073
formatType( nodearguments );
00074 }
00075
formatType(arguments);
00076
if ( arguments == nodearguments ) {
00077
QString brief =
"";
00078
QDomNode briefnode = elem.elementsByTagName(
"briefdescription").item(0);
00079
if (briefnode.hasChildNodes())
00080 brief = briefnode.firstChild().toElement().text();
00081
00082
QString detailstr =
"", paramstr =
"";
00083
QDomNode detail = elem.elementsByTagName(
"detaileddescription").item(0);
00084
if (detail.hasChildNodes())
00085 detail = detail.firstChild();
00086
00087
QDomNode descnode = detail.firstChild();
00088
while (!descnode.isNull()){
00089
if (descnode.nodeName() ==
"parameterlist"){
00090
int tmpcount = descnode.childNodes().count();
00091
for (
int k = 0; k < tmpcount; ++k){
00092
00093 paramstr +=
"<li><i>" + descnode.childNodes().item(k++).toElement().text() +
"</i>\t";
00094
00095 paramstr += descnode.childNodes().item(k).toElement().text() +
"</li>";
00096 }
00097 }
else
00098
if (descnode.nodeName() ==
"simplesect"){
00099 }
else {
00100
if (descnode.isText())
00101 detailstr += descnode.toText().data();
00102
else
00103 detailstr += descnode.toElement().text();
00104 }
00105 descnode = descnode.nextSibling();
00106 }
00107
00108
00109
QString description =
"";
00110
if (brief !=
"")
00111 description += brief +
"<p>";
00112
if (detailstr !=
"")
00113 description += detailstr +
"<p>";
00114
if (paramstr !=
"")
00115 description +=
"<b>Parameterlist:</b><p>" + paramstr;
00116
00117
if (description ==
"")
00118
return QString::null;
00119
else
00120
return description;
00121 }
00122 }
00123
00124 }
00125
00126
return QString::null;
00127 }
00128
00129