Doxygen
Loading...
Searching...
No Matches
xmlgen.h File Reference

#include <src/xmlgen.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 2349 of file xmlgen.cpp.

2350{
2351 // + classes
2352 // + concepts
2353 // + namespaces
2354 // + files
2355 // + groups
2356 // + related pages
2357 // - examples
2358
2359 DString outputDirectory = Config_getString(XML_OUTPUT);
2360 Dir xmlDir(outputDirectory.str());
2361 createSubDirs(xmlDir);
2362
2363 ResourceMgr::instance().copyResource("xml.xsd",outputDirectory);
2364 ResourceMgr::instance().copyResource("index.xsd",outputDirectory);
2365
2366 DString fileName=outputDirectory+"/compound.xsd";
2367 std::ofstream f = Portable::openOutputStream(fileName);
2368 if (!f.is_open())
2369 {
2370 err("Cannot open file {} for writing!\n",fileName);
2371 return;
2372 }
2373 {
2374 TextStream t(&f);
2375
2376 // write compound.xsd, but replace special marker with the entities
2377 DString compound_xsd = ResourceMgr::instance().getAsString("compound.xsd");
2378 const char *startLine = compound_xsd.data();
2379 while (*startLine)
2380 {
2381 // find end of the line
2382 const char *endLine = startLine+1;
2383 while (*endLine && *(endLine-1)!='\n') endLine++; // skip to end of the line including \n
2384 int len=static_cast<int>(endLine-startLine);
2385 if (len>0)
2386 {
2387 DString s(startLine,len);
2388 if (s.find("<!-- Automatically insert here the HTML entities -->")!=DString::npos)
2389 {
2391 }
2392 else
2393 {
2394 t.write(startLine,len);
2395 }
2396 }
2397 startLine=endLine;
2398 }
2399 }
2400 f.close();
2401
2402 fileName=outputDirectory+"/doxyfile.xsd";
2403 f = Portable::openOutputStream(fileName);
2404 if (!f.is_open())
2405 {
2406 err("Cannot open file {} for writing!\n",fileName);
2407 return;
2408 }
2409 {
2410 TextStream t(&f);
2411
2412 // write doxyfile.xsd, but replace special marker with the entities
2413 DString doxyfile_xsd = ResourceMgr::instance().getAsString("doxyfile.xsd");
2414 const char *startLine = doxyfile_xsd.data();
2415 while (*startLine)
2416 {
2417 // find end of the line
2418 const char *endLine = startLine+1;
2419 while (*endLine && *(endLine-1)!='\n') endLine++; // skip to end of the line including \n
2420 int len=static_cast<int>(endLine-startLine);
2421 if (len>0)
2422 {
2423 DString s(startLine,len);
2424 if (s.find("<!-- Automatically insert here the configuration settings -->")!=DString::npos)
2425 {
2427 }
2428 else
2429 {
2430 t.write(startLine,len);
2431 }
2432 }
2433 startLine=endLine;
2434 }
2435 }
2436 f.close();
2437
2438 fileName=outputDirectory+"/Doxyfile.xml";
2439 f = Portable::openOutputStream(fileName);
2440 if (!f.is_open())
2441 {
2442 err("Cannot open file {} for writing\n",fileName);
2443 return;
2444 }
2445 else
2446 {
2447 TextStream t(&f);
2449 }
2450 f.close();
2451
2452 fileName=outputDirectory+"/index.xml";
2453 f = Portable::openOutputStream(fileName);
2454 if (!f.is_open())
2455 {
2456 err("Cannot open file {} for writing!\n",fileName);
2457 return;
2458 }
2459 else
2460 {
2461 TextStream t(&f);
2462
2463 // write index header
2464 t << "<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n";
2465 t << "<doxygenindex xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ";
2466 t << "xsi:noNamespaceSchemaLocation=\"index.xsd\" ";
2467 t << "version=\"" << getDoxygenVersion() << "\" ";
2468 t << "xml:lang=\"" << theTranslator->trISOLang() << "\"";
2469 t << ">\n";
2470
2471 for (const auto &cd : *Doxygen::classLinkedMap)
2472 {
2473 generateXMLForClass(cd.get(),t);
2474 }
2475 for (const auto &cd : *Doxygen::conceptLinkedMap)
2476 {
2477 msg("Generating XML output for concept {}\n",cd->displayName());
2478 generateXMLForConcept(cd.get(),t);
2479 }
2480 for (const auto &nd : *Doxygen::namespaceLinkedMap)
2481 {
2482 msg("Generating XML output for namespace {}\n",nd->displayName());
2483 generateXMLForNamespace(nd.get(),t);
2484 }
2485 for (const auto &fn : *Doxygen::inputNameLinkedMap)
2486 {
2487 for (const auto &fd : *fn)
2488 {
2489 msg("Generating XML output for file {}\n",fd->name());
2490 generateXMLForFile(fd.get(),t);
2491 }
2492 }
2493 for (const auto &gd : *Doxygen::groupLinkedMap)
2494 {
2495 msg("Generating XML output for group {}\n",gd->name());
2496 generateXMLForGroup(gd.get(),t);
2497 }
2498 for (const auto &pd : *Doxygen::pageLinkedMap)
2499 {
2500 msg("Generating XML output for page {}\n",pd->name());
2501 generateXMLForPage(pd.get(),t,false);
2502 }
2503 for (const auto &req : RequirementManager::instance().requirements())
2504 {
2505 if (req->getTagFile().empty())
2506 {
2507 msg("Generating XML output for requirement {}\n", req->id());
2509 }
2510 }
2511 for (const auto &dd : *Doxygen::dirLinkedMap)
2512 {
2513 msg("Generate XML output for dir {}\n",dd->name());
2514 generateXMLForDir(dd.get(),t);
2515 }
2516 for (const auto &mod : ModuleManager::instance().modules())
2517 {
2518 msg("Generating XML output for module {}\n",mod->name());
2519 generateXMLForModule(mod.get(),t);
2520 }
2521 for (const auto &pd : *Doxygen::exampleLinkedMap)
2522 {
2523 msg("Generating XML output for example {}\n",pd->name());
2524 generateXMLForPage(pd.get(),t,true);
2525 }
2527 {
2528 msg("Generating XML output for the main page\n");
2530 }
2531
2532 //t << " </compoundlist>\n";
2533 t << "</doxygenindex>\n";
2534 }
2535
2537 clearSubDirs(xmlDir);
2538}
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:84
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:178
const std::string & str() const
Definition dstring.h:645
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:157
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:76
#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:681
void clearSubDirs(const Dir &d)
Definition util.cpp:2997
void createSubDirs(const Dir &d)
Definition util.cpp:2970
static void generateXMLForGroup(const GroupDef *gd, TextStream &ti)
Definition xmlgen.cpp:1989
static void generateXMLForClass(const ClassDef *cd, TextStream &ti)
Definition xmlgen.cpp:1495
static void generateXMLForFile(FileDef *fd, TextStream &ti)
Definition xmlgen.cpp:1873
static void generateXMLForNamespace(const NamespaceDef *nd, TextStream &ti)
Definition xmlgen.cpp:1800
static void generateXMLForRequirement(const RequirementIntf *req, TextStream &ti)
Definition xmlgen.cpp:2320
static void generateXMLForModule(const ModuleDef *mod, TextStream &ti)
Definition xmlgen.cpp:1744
static void generateXMLForConcept(const ConceptDef *cd, TextStream &ti)
Definition xmlgen.cpp:1666
static void generateXMLForDir(DirDef *dd, TextStream &ti)
Definition xmlgen.cpp:2059
static void generateXMLForPage(PageDef *pd, TextStream &ti, bool isExample)
Definition xmlgen.cpp:2153
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().