Doxygen
Loading...
Searching...
No Matches
mangen.cpp File Reference
#include <stdlib.h>
#include <string.h>
#include "config.h"
#include "datetime.h"
#include "dir.h"
#include "docparser.h"
#include "doxygen.h"
#include "fileinfo.h"
#include "language.h"
#include "mandocvisitor.h"
#include "mangen.h"
#include "message.h"
#include "outputlist.h"
#include "portable.h"
#include "utf8.h"
#include "util.h"
Include dependency graph for mangen.cpp:

Go to the source code of this file.

Functions

static DString getExtension ()
static DString getSubdir ()
static DString docifyToString (const DString &str)
static DString objectLinkToString (const DString &text)
static DString buildFileName (const DString &name)

Function Documentation

◆ buildFileName()

DString buildFileName ( const DString & name)
static

Definition at line 297 of file mangen.cpp.

298{
299 DString fileName;
300 if (name.empty()) return "noname";
301
302 const char *p=name.data();
303 char c = 0;
304 while ((c=*p++))
305 {
306 switch (c)
307 {
308 case ':':
309 fileName+="_";
310 if (*p==':') p++;
311 break;
312 case '<':
313 case '>':
314 case '&':
315 case '*':
316 case '!':
317 case '^':
318 case '~':
319 case '%':
320 case '+':
321 case '/':
322 fileName+="_";
323 break;
324 default:
325 fileName+=c;
326 }
327 }
328
329 DString manExtension = "." + getExtension();
330 if (fileName.right(manExtension.length())!=manExtension)
331 {
332 fileName+=manExtension;
333 }
334
335 return fileName;
336}
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:88
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:152
DString right(size_t len) const
Definition dstring.h:315
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
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition dstring.h:155
static DString getExtension()
Definition mangen.cpp:37

References DString::data(), DString::empty(), getExtension(), DString::length(), and DString::right().

Referenced by ManGenerator::startDoxyAnchor(), and ManGenerator::startFile().

◆ docifyToString()

DString docifyToString ( const DString & str)
static

Definition at line 80 of file mangen.cpp.

81{
82 DString result;
83 result.reserve(str.length());
84 if (!str.empty())
85 {
86 const char *p=str.data();
87 char c=0;
88 while ((c=*p++))
89 {
90 switch(c)
91 {
92 case '-': result += "\\-"; break; // see bug747780
93 case '.': result += "\\&."; break; // see bug652277
94 case '\\': result += "\\\\"; break;
95 case '\n': result += "\n"; break;
96 case '\"': c = '\''; // no break!
97 default: result += c; break;
98 }
99 }
100 //printf("%s",str);fflush(stdout);
101 }
102 return result;
103}
void reserve(size_t size)
Reserve space for size bytes without changing the string contents.
Definition dstring.h:221

References DString::data(), DString::empty(), DString::length(), and DString::reserve().

Referenced by objectLinkToString(), and ManGenerator::writeInheritedSectionTitle().

◆ getExtension()

DString getExtension ( )
static

Definition at line 37 of file mangen.cpp.

38{
39 /*
40 * [.][number][rest]
41 * in case of . missing, just ignore it
42 * in case number missing, just place a 3 in front of it
43 */
44 DString ext = Config_getString(MAN_EXTENSION);
45 if (ext.empty())
46 {
47 ext = "3";
48 }
49 else
50 {
51 if (ext.at(0)=='.')
52 {
53 if (ext.length()==1)
54 {
55 ext = "3";
56 }
57 else // strip .
58 {
59 ext = ext.mid(1);
60 }
61 }
62 if (ext.at(0)<'0' || ext.at(0)>'9')
63 {
64 ext.prepend("3");
65 }
66 }
67 return ext;
68}
DString mid(size_t index, size_t len=npos) const
Definition dstring.h:322
char & at(size_t i)
Returns a reference to the character at index i.
Definition dstring.h:690
DString & prepend(const char *s)
Definition dstring.h:519
#define Config_getString(name)
Definition config.h:32

References DString::at(), Config_getString, DString::empty(), DString::length(), DString::mid(), and DString::prepend().

Referenced by buildFileName(), ManGenerator::endTitleHead(), and getSubdir().

◆ getSubdir()

DString getSubdir ( )
static

Definition at line 70 of file mangen.cpp.

71{
72 DString dir = Config_getString(MAN_SUBDIR);
73 if (dir.empty())
74 {
75 dir = "man" + getExtension();
76 }
77 return dir;
78}

References Config_getString, DString::empty(), and getExtension().

Referenced by ManGenerator::init(), ManGenerator::ManGenerator(), and ManGenerator::startDoxyAnchor().

◆ objectLinkToString()

DString objectLinkToString ( const DString & text)
static

Definition at line 105 of file mangen.cpp.

106{
107 return "\\fB" + docifyToString(text) + "\\fP";
108}
static DString docifyToString(const DString &str)
Definition mangen.cpp:80

References docifyToString().

Referenced by ManGenerator::writeInheritedSectionTitle().