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 2379 of file xmlgen.cpp.

2380{
2381 // + classes
2382 // + concepts
2383 // + namespaces
2384 // + files
2385 // + groups
2386 // + related pages
2387 // - examples
2388
2389 DString outputDirectory = Config_getString(XML_OUTPUT);
2390 Dir xmlDir(outputDirectory.str());
2391 createSubDirs(xmlDir);
2392
2393 ResourceMgr::instance().copyResource("xml.xsd",outputDirectory);
2394 ResourceMgr::instance().copyResource("index.xsd",outputDirectory);
2395
2396 DString fileName=outputDirectory+"/compound.xsd";
2397 std::ofstream f = Portable::openOutputStream(fileName);
2398 if (!f.is_open())
2399 {
2400 err("Cannot open file {} for writing!\n",fileName);
2401 return;
2402 }
2403 {
2404 TextStream t(&f);
2405
2406 // write compound.xsd, but replace special marker with the entities
2407 DString compound_xsd = ResourceMgr::instance().getAsString("compound.xsd");
2408 const char *startLine = compound_xsd.data();
2409 while (*startLine)
2410 {
2411 // find end of the line
2412 const char *endLine = startLine+1;
2413 while (*endLine && *(endLine-1)!='\n') endLine++; // skip to end of the line including \n
2414 int len=static_cast<int>(endLine-startLine);
2415 if (len>0)
2416 {
2417 DString s(startLine,len);
2418 if (s.find("<!-- Automatically insert here the HTML entities -->")!=DString::npos)
2419 {
2421 }
2422 else
2423 {
2424 t.write(startLine,len);
2425 }
2426 }
2427 startLine=endLine;
2428 }
2429 }
2430 f.close();
2431
2432 fileName=outputDirectory+"/doxyfile.xsd";
2433 f = Portable::openOutputStream(fileName);
2434 if (!f.is_open())
2435 {
2436 err("Cannot open file {} for writing!\n",fileName);
2437 return;
2438 }
2439 {
2440 TextStream t(&f);
2441
2442 // write doxyfile.xsd, but replace special marker with the entities
2443 DString doxyfile_xsd = ResourceMgr::instance().getAsString("doxyfile.xsd");
2444 const char *startLine = doxyfile_xsd.data();
2445 while (*startLine)
2446 {
2447 // find end of the line
2448 const char *endLine = startLine+1;
2449 while (*endLine && *(endLine-1)!='\n') endLine++; // skip to end of the line including \n
2450 int len=static_cast<int>(endLine-startLine);
2451 if (len>0)
2452 {
2453 DString s(startLine,len);
2454 if (s.find("<!-- Automatically insert here the configuration settings -->")!=DString::npos)
2455 {
2457 }
2458 else
2459 {
2460 t.write(startLine,len);
2461 }
2462 }
2463 startLine=endLine;
2464 }
2465 }
2466 f.close();
2467
2468 fileName=outputDirectory+"/Doxyfile.xml";
2469 f = Portable::openOutputStream(fileName);
2470 if (!f.is_open())
2471 {
2472 err("Cannot open file {} for writing\n",fileName);
2473 return;
2474 }
2475 else
2476 {
2477 TextStream t(&f);
2479 }
2480 f.close();
2481
2482 fileName=outputDirectory+"/index.xml";
2483 f = Portable::openOutputStream(fileName);
2484 if (!f.is_open())
2485 {
2486 err("Cannot open file {} for writing!\n",fileName);
2487 return;
2488 }
2489 else
2490 {
2491 TextStream t(&f);
2492
2493 // write index header
2494 t << "<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n";
2495 t << "<doxygenindex xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ";
2496 t << "xsi:noNamespaceSchemaLocation=\"index.xsd\" ";
2497 t << "version=\"" << getDoxygenVersion() << "\" ";
2498 t << "xml:lang=\"" << theTranslator->trISOLang() << "\"";
2499 t << ">\n";
2500
2501 for (const auto &cd : *Doxygen::classLinkedMap)
2502 {
2503 generateXMLForClass(cd.get(),t);
2504 }
2505 for (const auto &cd : *Doxygen::conceptLinkedMap)
2506 {
2507 msg("Generating XML output for concept {}\n",cd->displayName());
2508 generateXMLForConcept(cd.get(),t);
2509 }
2510 for (const auto &nd : *Doxygen::namespaceLinkedMap)
2511 {
2512 msg("Generating XML output for namespace {}\n",nd->displayName());
2513 generateXMLForNamespace(nd.get(),t);
2514 }
2515 for (const auto &fn : *Doxygen::inputNameLinkedMap)
2516 {
2517 for (const auto &fd : *fn)
2518 {
2519 msg("Generating XML output for file {}\n",fd->name());
2520 generateXMLForFile(fd.get(),t);
2521 }
2522 }
2523 for (const auto &gd : *Doxygen::groupLinkedMap)
2524 {
2525 msg("Generating XML output for group {}\n",gd->name());
2526 generateXMLForGroup(gd.get(),t);
2527 }
2528 for (const auto &pd : *Doxygen::pageLinkedMap)
2529 {
2530 msg("Generating XML output for page {}\n",pd->name());
2531 generateXMLForPage(pd.get(),t,false);
2532 }
2533 for (const auto &req : RequirementManager::instance().requirements())
2534 {
2535 if (req->getTagFile().empty())
2536 {
2537 msg("Generating XML output for requirement {}\n", req->id());
2539 }
2540 }
2541 for (const auto &dd : *Doxygen::dirLinkedMap)
2542 {
2543 msg("Generate XML output for dir {}\n",dd->name());
2544 generateXMLForDir(dd.get(),t);
2545 }
2546 for (const auto &mod : ModuleManager::instance().modules())
2547 {
2548 msg("Generating XML output for module {}\n",mod->name());
2549 generateXMLForModule(mod.get(),t);
2550 }
2551 for (const auto &pd : *Doxygen::exampleLinkedMap)
2552 {
2553 msg("Generating XML output for example {}\n",pd->name());
2554 generateXMLForPage(pd.get(),t,true);
2555 }
2557 {
2558 msg("Generating XML output for the main page\n");
2560 }
2561
2562 //t << " </compoundlist>\n";
2563 t << "</doxygenindex>\n";
2564 }
2565
2567 clearSubDirs(xmlDir);
2568}
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:679
void clearSubDirs(const Dir &d)
Definition util.cpp:3128
void createSubDirs(const Dir &d)
Definition util.cpp:3101
static void generateXMLForGroup(const GroupDef *gd, TextStream &ti)
Definition xmlgen.cpp:2020
static void generateXMLForClass(const ClassDef *cd, TextStream &ti)
Definition xmlgen.cpp:1526
static void generateXMLForFile(FileDef *fd, TextStream &ti)
Definition xmlgen.cpp:1904
static void generateXMLForNamespace(const NamespaceDef *nd, TextStream &ti)
Definition xmlgen.cpp:1831
static void generateXMLForRequirement(const RequirementIntf *req, TextStream &ti)
Definition xmlgen.cpp:2350
static void generateXMLForModule(const ModuleDef *mod, TextStream &ti)
Definition xmlgen.cpp:1775
static void generateXMLForConcept(const ConceptDef *cd, TextStream &ti)
Definition xmlgen.cpp:1697
static void generateXMLForDir(DirDef *dd, TextStream &ti)
Definition xmlgen.cpp:2090
static void generateXMLForPage(PageDef *pd, TextStream &ti, bool isExample)
Definition xmlgen.cpp:2184
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().