Doxygen
Loading...
Searching...
No Matches
xmlgen.h File Reference
#include "outputgen.h"
Include dependency graph for xmlgen.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  XMLCodeGenerator

Functions

void generateXML ()

Function Documentation

◆ generateXML()

void generateXML ( )

Definition at line 2316 of file xmlgen.cpp.

2317{
2318 // + classes
2319 // + concepts
2320 // + namespaces
2321 // + files
2322 // + groups
2323 // + related pages
2324 // - examples
2325
2326 DString outputDirectory = Config_getString(XML_OUTPUT);
2327 Dir xmlDir(outputDirectory.str());
2328 createSubDirs(xmlDir);
2329
2330 ResourceMgr::instance().copyResource("xml.xsd",outputDirectory);
2331 ResourceMgr::instance().copyResource("index.xsd",outputDirectory);
2332
2333 DString fileName=outputDirectory+"/compound.xsd";
2334 std::ofstream f = Portable::openOutputStream(fileName);
2335 if (!f.is_open())
2336 {
2337 err("Cannot open file {} for writing!\n",fileName);
2338 return;
2339 }
2340 {
2341 TextStream t(&f);
2342
2343 // write compound.xsd, but replace special marker with the entities
2344 DString compound_xsd = ResourceMgr::instance().getAsString("compound.xsd");
2345 const char *startLine = compound_xsd.data();
2346 while (*startLine)
2347 {
2348 // find end of the line
2349 const char *endLine = startLine+1;
2350 while (*endLine && *(endLine-1)!='\n') endLine++; // skip to end of the line including \n
2351 int len=static_cast<int>(endLine-startLine);
2352 if (len>0)
2353 {
2354 DString s(startLine,len);
2355 if (s.find("<!-- Automatically insert here the HTML entities -->")!=DString::npos)
2356 {
2358 }
2359 else
2360 {
2361 t.write(startLine,len);
2362 }
2363 }
2364 startLine=endLine;
2365 }
2366 }
2367 f.close();
2368
2369 fileName=outputDirectory+"/doxyfile.xsd";
2370 f = Portable::openOutputStream(fileName);
2371 if (!f.is_open())
2372 {
2373 err("Cannot open file {} for writing!\n",fileName);
2374 return;
2375 }
2376 {
2377 TextStream t(&f);
2378
2379 // write doxyfile.xsd, but replace special marker with the entities
2380 DString doxyfile_xsd = ResourceMgr::instance().getAsString("doxyfile.xsd");
2381 const char *startLine = doxyfile_xsd.data();
2382 while (*startLine)
2383 {
2384 // find end of the line
2385 const char *endLine = startLine+1;
2386 while (*endLine && *(endLine-1)!='\n') endLine++; // skip to end of the line including \n
2387 int len=static_cast<int>(endLine-startLine);
2388 if (len>0)
2389 {
2390 DString s(startLine,len);
2391 if (s.find("<!-- Automatically insert here the configuration settings -->")!=DString::npos)
2392 {
2394 }
2395 else
2396 {
2397 t.write(startLine,len);
2398 }
2399 }
2400 startLine=endLine;
2401 }
2402 }
2403 f.close();
2404
2405 fileName=outputDirectory+"/Doxyfile.xml";
2406 f = Portable::openOutputStream(fileName);
2407 if (!f.is_open())
2408 {
2409 err("Cannot open file {} for writing\n",fileName);
2410 return;
2411 }
2412 else
2413 {
2414 TextStream t(&f);
2416 }
2417 f.close();
2418
2419 fileName=outputDirectory+"/index.xml";
2420 f = Portable::openOutputStream(fileName);
2421 if (!f.is_open())
2422 {
2423 err("Cannot open file {} for writing!\n",fileName);
2424 return;
2425 }
2426 else
2427 {
2428 TextStream t(&f);
2429
2430 // write index header
2431 t << "<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n";
2432 t << "<doxygenindex xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ";
2433 t << "xsi:noNamespaceSchemaLocation=\"index.xsd\" ";
2434 t << "version=\"" << getDoxygenVersion() << "\" ";
2435 t << "xml:lang=\"" << theTranslator->trISOLang() << "\"";
2436 t << ">\n";
2437
2438 for (const auto &cd : *Doxygen::classLinkedMap)
2439 {
2440 generateXMLForClass(cd.get(),t);
2441 }
2442 for (const auto &cd : *Doxygen::conceptLinkedMap)
2443 {
2444 msg("Generating XML output for concept {}\n",cd->displayName());
2445 generateXMLForConcept(cd.get(),t);
2446 }
2447 for (const auto &nd : *Doxygen::namespaceLinkedMap)
2448 {
2449 msg("Generating XML output for namespace {}\n",nd->displayName());
2450 generateXMLForNamespace(nd.get(),t);
2451 }
2452 for (const auto &fn : *Doxygen::inputNameLinkedMap)
2453 {
2454 for (const auto &fd : *fn)
2455 {
2456 msg("Generating XML output for file {}\n",fd->name());
2457 generateXMLForFile(fd.get(),t);
2458 }
2459 }
2460 for (const auto &gd : *Doxygen::groupLinkedMap)
2461 {
2462 msg("Generating XML output for group {}\n",gd->name());
2463 generateXMLForGroup(gd.get(),t);
2464 }
2465 for (const auto &pd : *Doxygen::pageLinkedMap)
2466 {
2467 msg("Generating XML output for page {}\n",pd->name());
2468 generateXMLForPage(pd.get(),t,false);
2469 }
2470 for (const auto &req : RequirementManager::instance().requirements())
2471 {
2472 if (req->getTagFile().empty())
2473 {
2474 msg("Generating XML output for requirement {}\n", req->id());
2476 }
2477 }
2478 for (const auto &dd : *Doxygen::dirLinkedMap)
2479 {
2480 msg("Generate XML output for dir {}\n",dd->name());
2481 generateXMLForDir(dd.get(),t);
2482 }
2483 for (const auto &mod : ModuleManager::instance().modules())
2484 {
2485 msg("Generating XML output for module {}\n",mod->name());
2486 generateXMLForModule(mod.get(),t);
2487 }
2488 for (const auto &pd : *Doxygen::exampleLinkedMap)
2489 {
2490 msg("Generating XML output for example {}\n",pd->name());
2491 generateXMLForPage(pd.get(),t,true);
2492 }
2494 {
2495 msg("Generating XML output for the main page\n");
2497 }
2498
2499 //t << " </compoundlist>\n";
2500 t << "</doxygenindex>\n";
2501 }
2502
2504 clearSubDirs(xmlDir);
2505}
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:88
static constexpr size_t npos
value used to indicate 'not found' or 'to the end of the string', matching std::string::npos
Definition dstring.h:182
const std::string & str() const
Definition dstring.h:649
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition dstring.h:161
Class representing a directory in the file system.
Definition dir.h:73
static NamespaceLinkedMap * namespaceLinkedMap
Definition doxygen.h:108
static ConceptLinkedMap * conceptLinkedMap
Definition doxygen.h:90
static std::unique_ptr< PageDef > mainPage
Definition doxygen.h:93
static FileNameLinkedMap * inputNameLinkedMap
Definition doxygen.h:97
static ClassLinkedMap * classLinkedMap
Definition doxygen.h:88
static PageLinkedMap * exampleLinkedMap
Definition doxygen.h:91
static PageLinkedMap * pageLinkedMap
Definition doxygen.h:92
static DirLinkedMap * dirLinkedMap
Definition doxygen.h:120
static GroupLinkedMap * groupLinkedMap
Definition doxygen.h:107
void writeXMLSchema(TextStream &t)
static HtmlEntityMapper & instance()
Returns the one and only instance of the HTML entity mapper.
static ModuleManager & instance()
static RequirementManager & instance()
static ResourceMgr & instance()
Returns the one and only instance of this class.
bool copyResource(const DString &name, const DString &targetDir) const
Copies a registered resource to a given target directory.
DString getAsString(const DString &name) const
Gets the resource data as a C string.
Text streaming class that buffers data.
Definition textstream.h:36
virtual DString trISOLang()=0
#define Config_getString(name)
Definition config.h:32
Translator * theTranslator
Definition language.cpp:71
#define msg(fmt,...)
Definition message.h:94
#define err(fmt,...)
Definition message.h:127
void writeXMLDoxyfile(TextStream &t)
void writeXSDDoxyfile(TextStream &t)
std::ofstream openOutputStream(const DString &name, bool append=false)
Definition portable.cpp:665
void clearSubDirs(const Dir &d)
Definition util.cpp:2998
void createSubDirs(const Dir &d)
Definition util.cpp:2971
static void generateXMLForGroup(const GroupDef *gd, TextStream &ti)
Definition xmlgen.cpp:1956
static void generateXMLForClass(const ClassDef *cd, TextStream &ti)
Definition xmlgen.cpp:1463
static void generateXMLForFile(FileDef *fd, TextStream &ti)
Definition xmlgen.cpp:1840
static void generateXMLForNamespace(const NamespaceDef *nd, TextStream &ti)
Definition xmlgen.cpp:1767
static void generateXMLForRequirement(const RequirementIntf *req, TextStream &ti)
Definition xmlgen.cpp:2287
static void generateXMLForModule(const ModuleDef *mod, TextStream &ti)
Definition xmlgen.cpp:1711
static void generateXMLForConcept(const ConceptDef *cd, TextStream &ti)
Definition xmlgen.cpp:1633
static void generateXMLForDir(DirDef *dd, TextStream &ti)
Definition xmlgen.cpp:2026
static void generateXMLForPage(PageDef *pd, TextStream &ti, bool isExample)
Definition xmlgen.cpp:2120
static void writeCombineScript()
Definition xmlgen.cpp:140

References Doxygen::classLinkedMap, clearSubDirs(), Doxygen::conceptLinkedMap, Config_getString, ResourceMgr::copyResource(), createSubDirs(), DString::data(), Doxygen::dirLinkedMap, err, Doxygen::exampleLinkedMap, DString::find(), generateXMLForClass(), generateXMLForConcept(), generateXMLForDir(), generateXMLForFile(), generateXMLForGroup(), generateXMLForModule(), generateXMLForNamespace(), generateXMLForPage(), generateXMLForRequirement(), ResourceMgr::getAsString(), Doxygen::groupLinkedMap, Doxygen::inputNameLinkedMap, HtmlEntityMapper::instance(), ModuleManager::instance(), RequirementManager::instance(), ResourceMgr::instance(), Doxygen::mainPage, msg, Doxygen::namespaceLinkedMap, DString::npos, Portable::openOutputStream(), Doxygen::pageLinkedMap, DString::str(), theTranslator, Translator::trISOLang(), TextStream::write(), writeCombineScript(), Config::writeXMLDoxyfile(), HtmlEntityMapper::writeXMLSchema(), and Config::writeXSDDoxyfile().

Referenced by generateOutput().