Doxygen
Toggle main menu visibility
Loading...
Searching...
No Matches
outputgen.cpp
Go to the documentation of this file.
1
/******************************************************************************
2
*
3
* Copyright (C) 1997-2026 by Dimitri van Heesch.
4
*
5
* Permission to use, copy, modify, and distribute this software and its
6
* documentation under the terms of the GNU General Public License is hereby
7
* granted. No representations are made about the suitability of this software
8
* for any purpose. It is provided "as is" without express or implied warranty.
9
* See the GNU General Public License for more details.
10
*
11
* Documents produced by Doxygen are derivative works derived from the
12
* input used in their production; they are not affected by this license.
13
*
14
*/
15
16
#include <stdexcept>
17
18
#include <stdlib.h>
19
20
#include "
doxygen.h
"
21
#include "
outputgen.h
"
22
#include "
message.h
"
23
#include "
portable.h
"
24
25
OutputGenerator::OutputGenerator
(
const
DString
&
dir
) :
m_t
(nullptr),
m_dir
(
dir
)
26
{
27
//printf("OutputGenerator::OutputGenerator()\n");
28
}
29
30
void
OutputGenerator::startPlainFile
(
const
DString
&name)
31
{
32
//printf("startPlainFile(%s)\n",qPrint(name));
33
m_fileName
=
m_dir
+
"/"
+name;
34
m_file
=
Portable::fopen
(
m_fileName
.
data
(),
"wb"
);
35
if
(
m_file
==
nullptr
)
36
{
37
term
(
"Could not open file {} for writing\n"
,
m_fileName
);
38
}
39
m_t
.
setFile
(
m_file
);
40
}
41
42
void
OutputGenerator::endPlainFile
()
43
{
44
m_t
.
flush
();
45
m_t
.
setStream
(
nullptr
);
46
Portable::fclose
(
m_file
);
47
m_fileName
.
clear
();
48
}
49
50
DString
OutputGenerator::dir
()
const
51
{
52
return
m_dir
;
53
}
54
55
DString
OutputGenerator::fileName
()
const
56
{
57
return
m_fileName
;
58
}
59
60
size_t
updateColumnCount
(
const
char
*s,
size_t
col)
61
{
62
if
(s)
63
{
64
const
int
tabSize =
Config_getInt
(TAB_SIZE);
65
char
c;
66
while
((c=*s++))
67
{
68
switch
(c)
69
{
70
case
'\t'
: col+=tabSize - (col%tabSize);
71
break
;
72
case
'\n'
: col=0;
73
break
;
74
default
:
75
col++;
76
if
(c<0)
// multi-byte character
77
{
78
int
numBytes =
getUTF8CharNumBytes
(c);
79
for
(
int
i=0;i<numBytes-1 && (c=*s++);i++) {}
// skip over extra chars
80
if
(c==0)
return
col;
// end of string half way a multibyte char
81
}
82
break
;
83
}
84
}
85
}
86
return
col;
87
}
88
89
90
DString
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition
dstring.h:88
DString::clear
void clear()
Definition
dstring.h:218
DString::data
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
OutputGenerator::OutputGenerator
OutputGenerator()
Definition
outputgen.h:98
OutputGenerator::m_file
FILE * m_file
Definition
outputgen.h:117
OutputGenerator::dir
DString dir() const
Definition
outputgen.cpp:50
OutputGenerator::startPlainFile
void startPlainFile(const DString &name)
Definition
outputgen.cpp:30
OutputGenerator::endPlainFile
void endPlainFile()
Definition
outputgen.cpp:42
OutputGenerator::m_t
TextStream m_t
Definition
outputgen.h:113
OutputGenerator::m_fileName
DString m_fileName
Definition
outputgen.h:116
OutputGenerator::fileName
DString fileName() const
Definition
outputgen.cpp:55
OutputGenerator::m_dir
DString m_dir
Definition
outputgen.h:114
TextStream::setStream
void setStream(std::ostream *s)
Sets or changes the std::ostream to write to.
Definition
textstream.h:67
TextStream::flush
void flush()
Flushes the buffer.
Definition
textstream.h:212
TextStream::setFile
void setFile(FILE *f)
Definition
textstream.h:74
Config_getInt
#define Config_getInt(name)
Definition
config.h:34
doxygen.h
message.h
term
#define term(fmt,...)
Definition
message.h:137
Portable::fopen
FILE * fopen(const DString &fileName, const DString &mode)
Definition
portable.cpp:349
Portable::fclose
int fclose(FILE *f)
Definition
portable.cpp:369
updateColumnCount
size_t updateColumnCount(const char *s, size_t col)
Definition
outputgen.cpp:60
outputgen.h
portable.h
Portable versions of functions that are platform dependent.
getUTF8CharNumBytes
uint8_t getUTF8CharNumBytes(char c)
Returns the number of bytes making up a single UTF8 character given the first byte in the sequence.
Definition
utf8.cpp:24
src
outputgen.cpp
Generated by
1.19.0