00001 /****************************************************************************** 00002 * 00003 * $Id: outputlist.cpp,v 1.35 2001/03/19 19:27:41 root Exp $ 00004 * 00005 * Copyright (C) 1997-2008 by Dimitri van Heesch. 00006 * 00007 * Permission to use, copy, modify, and distribute this software and its 00008 * documentation under the terms of the GNU General Public License is hereby 00009 * granted. No representations are made about the suitability of this software 00010 * for any purpose. It is provided "as is" without express or implied warranty. 00011 * See the GNU General Public License for more details. 00012 * 00013 * Documents produced by Doxygen are derivative works derived from the 00014 * input used in their production; they are not affected by this license. 00015 * 00016 */ 00017 00025 #include "outputlist.h" 00026 #include "outputgen.h" 00027 #include "config.h" 00028 #include "message.h" 00029 #include "definition.h" 00030 00031 #include "docparser.h" 00032 00033 OutputList::OutputList(bool) 00034 { 00035 //printf("OutputList::OutputList()\n"); 00036 outputs = new QList<OutputGenerator>; 00037 outputs->setAutoDelete(TRUE); 00038 } 00039 00040 OutputList::~OutputList() 00041 { 00042 //printf("OutputList::~OutputList()\n"); 00043 delete outputs; 00044 } 00045 00046 void OutputList::add(const OutputGenerator *og) 00047 { 00048 if (og) outputs->append(og); 00049 } 00050 00051 void OutputList::disableAllBut(OutputGenerator::OutputType o) 00052 { 00053 OutputGenerator *og=outputs->first(); 00054 while (og) 00055 { 00056 og->disableIfNot(o); 00057 og=outputs->next(); 00058 } 00059 } 00060 00061 void OutputList::enableAll() 00062 { 00063 OutputGenerator *og=outputs->first(); 00064 while (og) 00065 { 00066 og->enable(); 00067 og=outputs->next(); 00068 } 00069 } 00070 00071 void OutputList::disableAll() 00072 { 00073 OutputGenerator *og=outputs->first(); 00074 while (og) 00075 { 00076 og->disable(); 00077 og=outputs->next(); 00078 } 00079 } 00080 00081 void OutputList::disable(OutputGenerator::OutputType o) 00082 { 00083 OutputGenerator *og=outputs->first(); 00084 while (og) 00085 { 00086 og->disableIf(o); 00087 og=outputs->next(); 00088 } 00089 } 00090 00091 void OutputList::enable(OutputGenerator::OutputType o) 00092 { 00093 OutputGenerator *og=outputs->first(); 00094 while (og) 00095 { 00096 og->enableIf(o); 00097 og=outputs->next(); 00098 } 00099 } 00100 00101 bool OutputList::isEnabled(OutputGenerator::OutputType o) 00102 { 00103 bool result=FALSE; 00104 OutputGenerator *og=outputs->first(); 00105 while (og) 00106 { 00107 result=result || og->isEnabled(o); 00108 og=outputs->next(); 00109 } 00110 return result; 00111 } 00112 00113 void OutputList::pushGeneratorState() 00114 { 00115 OutputGenerator *og=outputs->first(); 00116 while (og) 00117 { 00118 og->pushGeneratorState(); 00119 og=outputs->next(); 00120 } 00121 } 00122 00123 void OutputList::popGeneratorState() 00124 { 00125 OutputGenerator *og=outputs->first(); 00126 while (og) 00127 { 00128 og->popGeneratorState(); 00129 og=outputs->next(); 00130 } 00131 } 00132 00133 void OutputList::parseDoc(const char *fileName,int startLine, 00134 Definition *ctx,MemberDef * md, 00135 const QCString &docStr,bool indexWords, 00136 bool isExample,const char *exampleName, 00137 bool singleLine,bool linkFromIndex) 00138 { 00139 int count=0; 00140 if (docStr.isEmpty()) return; 00141 00142 OutputGenerator *og=outputs->first(); 00143 while (og) 00144 { 00145 if (og->isEnabled()) count++; 00146 og=outputs->next(); 00147 } 00148 if (count==0) return; // no output formats enabled. 00149 00150 DocNode *root=0; 00151 if (docStr.at(docStr.length()-1)=='\n') 00152 { 00153 root = validatingParseDoc(fileName,startLine, 00154 ctx,md,docStr,indexWords,isExample,exampleName, 00155 singleLine,linkFromIndex); 00156 } 00157 else 00158 { 00159 root = validatingParseDoc(fileName,startLine, 00160 ctx,md,docStr+"\n",indexWords,isExample,exampleName, 00161 singleLine,linkFromIndex); 00162 } 00163 00164 og=outputs->first(); 00165 while (og) 00166 { 00167 //printf("og->printDoc(extension=%s)\n", 00168 // ctx?ctx->getDefFileExtension().data():"<null>"); 00169 if (og->isEnabled()) og->printDoc(root,ctx?ctx->getDefFileExtension():QCString("")); 00170 og=outputs->next(); 00171 } 00172 00173 delete root; 00174 } 00175 00176 void OutputList::parseText(const QCString &textStr) 00177 { 00178 int count=0; 00179 OutputGenerator *og=outputs->first(); 00180 while (og) 00181 { 00182 if (og->isEnabled()) count++; 00183 og=outputs->next(); 00184 } 00185 if (count==0) return; // no output formats enabled. 00186 00187 DocNode *root = validatingParseText(textStr); 00188 00189 og=outputs->first(); 00190 while (og) 00191 { 00192 if (og->isEnabled()) og->printDoc(root,0); 00193 og=outputs->next(); 00194 } 00195 00196 delete root; 00197 } 00198 00199 00200 //-------------------------------------------------------------------------- 00201 // Create some overloaded definitions of the forall function. 00202 // Using template functions here would have made it a little less 00203 // portable (I guess). 00204 00205 // zero arguments 00206 void OutputList::forall(void (OutputGenerator::*func)()) 00207 { 00208 OutputGenerator *og=outputs->first(); 00209 while (og) 00210 { 00211 if (og->isEnabled()) (og->*func)(); 00212 og=outputs->next(); 00213 } 00214 } 00215 00216 // one argument 00217 #define FORALL1(a1,p1) \ 00218 void OutputList::forall(void (OutputGenerator::*func)(a1),a1) \ 00219 { \ 00220 OutputGenerator *og=outputs->first(); \ 00221 while (og) \ 00222 { \ 00223 if (og->isEnabled()) (og->*func)(p1); \ 00224 og=outputs->next(); \ 00225 } \ 00226 } 00227 00228 // two arguments 00229 #define FORALL2(a1,a2,p1,p2) \ 00230 void OutputList::forall(void (OutputGenerator::*func)(a1,a2),a1,a2) \ 00231 { \ 00232 OutputGenerator *og=outputs->first(); \ 00233 while (og) \ 00234 { \ 00235 if (og->isEnabled()) (og->*func)(p1,p2); \ 00236 og=outputs->next(); \ 00237 } \ 00238 } 00239 00240 // three arguments 00241 #define FORALL3(a1,a2,a3,p1,p2,p3) \ 00242 void OutputList::forall(void (OutputGenerator::*func)(a1,a2,a3),a1,a2,a3) \ 00243 { \ 00244 OutputGenerator *og=outputs->first(); \ 00245 while (og) \ 00246 { \ 00247 if (og->isEnabled()) (og->*func)(p1,p2,p3); \ 00248 og=outputs->next(); \ 00249 } \ 00250 } 00251 00252 // four arguments 00253 #define FORALL4(a1,a2,a3,a4,p1,p2,p3,p4) \ 00254 void OutputList::forall(void (OutputGenerator::*func)(a1,a2,a3,a4),a1,a2,a3,a4) \ 00255 { \ 00256 OutputGenerator *og=outputs->first(); \ 00257 while (og) \ 00258 { \ 00259 if (og->isEnabled()) (og->*func)(p1,p2,p3,p4); \ 00260 og=outputs->next(); \ 00261 } \ 00262 } 00263 00264 // five arguments 00265 #define FORALL5(a1,a2,a3,a4,a5,p1,p2,p3,p4,p5) \ 00266 void OutputList::forall(void (OutputGenerator::*func)(a1,a2,a3,a4,a5),a1,a2,a3,a4,a5) \ 00267 { \ 00268 OutputGenerator *og=outputs->first(); \ 00269 while (og) \ 00270 { \ 00271 if (og->isEnabled()) (og->*func)(p1,p2,p3,p4,p5); \ 00272 og=outputs->next(); \ 00273 } \ 00274 } 00275 00276 // now instantiate only the ones we need. 00277 00278 FORALL1(const char *a1,a1) 00279 FORALL1(char a1,a1) 00280 FORALL1(int a1,a1) 00281 FORALL1(const DotClassGraph &a1,a1) 00282 FORALL1(const DotInclDepGraph &a1,a1) 00283 FORALL1(const DotCallGraph &a1,a1) 00284 FORALL1(const DotDirDeps &a1,a1) 00285 FORALL1(const DotGfxHierarchyTable &a1,a1) 00286 FORALL1(const DotGroupCollaboration &a1,a1) 00287 FORALL1(SectionTypes a1,a1) 00288 #if defined(HAS_BOOL_TYPE) || defined(Q_HAS_BOOL_TYPE) 00289 FORALL1(bool a1,a1) 00290 FORALL2(bool a1,int a2,a1,a2) 00291 FORALL2(bool a1,bool a2,a1,a2) 00292 FORALL4(const char *a1,const char *a2,const char *a3,bool a4,a1,a2,a3,a4) 00293 #endif 00294 FORALL2(int a1,bool a2,a1,a2) 00295 FORALL2(bool a1,HighlightedItem a2,a1,a2) 00296 FORALL2(bool a1,const char *a2,a1,a2) 00297 FORALL2(ParamListTypes a1,const char *a2,a1,a2) 00298 FORALL1(IndexSections a1,a1) 00299 FORALL2(const char *a1,const char *a2,a1,a2) 00300 FORALL2(const char *a1,bool a2,a1,a2) 00301 FORALL2(const char *a1,SectionInfo::SectionType a2,a1,a2) 00302 FORALL3(bool a1,bool a2,bool a3,a1,a2,a3) 00303 FORALL3(const ClassDiagram &a1,const char *a2,const char *a3,a1,a2,a3) 00304 FORALL3(const char *a1,const char *a2,const char *a3,a1,a2,a3) 00305 FORALL3(const char *a1,const char *a2,bool a3,a1,a2,a3) 00306 FORALL3(const char *a1,const char *a2,SectionInfo::SectionType a3,a1,a2,a3) 00307 FORALL3(uchar a1,uchar a2,uchar a3,a1,a2,a3) 00308 FORALL4(SectionTypes a1,const char *a2,const char *a3,const char *a4,a1,a2,a3,a4) 00309 FORALL4(const char *a1,const char *a2,const char *a3,const char *a4,a1,a2,a3,a4) 00310 FORALL4(const char *a1,const char *a2,const char *a3,int a4,a1,a2,a3,a4) 00311 FORALL5(const char *a1,const char *a2,const char *a3,const char *a4,const char *a5,a1,a2,a3,a4,a5) 00312 00313 00314 //--------------------------------------------------------------------------