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
// own header
17
#include "
outputgen.h
"
18
19
// other includes
20
#include "
message.h
"
21
#include "
portable.h
"
22
23
OutputGenerator::OutputGenerator
(
const
DString
&
dir
) :
m_t
(nullptr),
m_dir
(
dir
)
24
{
25
//printf("OutputGenerator::OutputGenerator()\n");
26
}
27
28
void
OutputGenerator::startPlainFile
(
const
DString
&name)
29
{
30
//printf("startPlainFile(%s)\n",qPrint(name));
31
m_fileName
=
m_dir
+
"/"
+name;
32
m_file
=
Portable::fopen
(
m_fileName
.
data
(),
"wb"
);
33
if
(
m_file
==
nullptr
)
34
{
35
term
(
"Could not open file {} for writing\n"
,
m_fileName
);
36
}
37
m_t
.
setFile
(
m_file
);
38
}
39
40
void
OutputGenerator::endPlainFile
()
41
{
42
m_t
.
flush
();
43
m_t
.
setStream
(
nullptr
);
44
Portable::fclose
(
m_file
);
45
m_fileName
.
clear
();
46
}
47
48
DString
OutputGenerator::dir
()
const
49
{
50
return
m_dir
;
51
}
52
53
DString
OutputGenerator::fileName
()
const
54
{
55
return
m_fileName
;
56
}
57
58
size_t
updateColumnCount
(
const
char
*s,
size_t
col)
59
{
60
if
(s)
61
{
62
const
int
tabSize =
Config_getInt
(TAB_SIZE);
63
char
c;
64
while
((c=*s++))
65
{
66
switch
(c)
67
{
68
case
'\t'
: col+=tabSize - (col%tabSize);
69
break
;
70
case
'\n'
: col=0;
71
break
;
72
default
:
73
col++;
74
if
(
static_cast<
signed
char
>
(c)<0)
// multi-byte character
75
{
76
int
numBytes =
getUTF8CharNumBytes
(c);
77
for
(
int
i=0;i<numBytes-1 && (c=*s++);i++) {}
// skip over extra chars
78
if
(c==0)
return
col;
// end of string half way a multibyte char
79
}
80
break
;
81
}
82
}
83
}
84
return
col;
85
}
86
87
88
DString
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition
dstring.h:84
DString::clear
void clear()
Definition
dstring.h:214
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:157
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:48
OutputGenerator::startPlainFile
void startPlainFile(const DString &name)
Definition
outputgen.cpp:28
OutputGenerator::endPlainFile
void endPlainFile()
Definition
outputgen.cpp:40
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:53
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
message.h
term
#define term(fmt,...)
Definition
message.h:137
Portable::fopen
FILE * fopen(const DString &fileName, const DString &mode)
Definition
portable.cpp:365
Portable::fclose
int fclose(FILE *f)
Definition
portable.cpp:385
updateColumnCount
size_t updateColumnCount(const char *s, size_t col)
Definition
outputgen.cpp:58
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:27
src
outputgen.cpp
Generated by
1.19.0