Doxygen
Loading...
Searching...
No Matches
mangen.cpp File Reference
#include "mangen.h"
#include <memory>
#include <string>
#include "config.h"
#include "datetime.h"
#include "dir.h"
#include "fileinfo.h"
#include "language.h"
#include "mandocvisitor.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 299 of file mangen.cpp.

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

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 82 of file mangen.cpp.

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

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

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

◆ getExtension()

DString getExtension ( )
static

Definition at line 39 of file mangen.cpp.

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

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

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 107 of file mangen.cpp.

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

References docifyToString().

Referenced by ManGenerator::writeInheritedSectionTitle().