Doxygen
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
24{
25 //printf("OutputGenerator::OutputGenerator()\n");
26}
27
29{
30 //printf("startPlainFile(%s)\n",qPrint(name));
31 m_fileName=m_dir+"/"+name;
33 if (m_file==nullptr)
34 {
35 term("Could not open file {} for writing\n",m_fileName);
36 }
38}
39
47
49{
50 return m_dir;
51}
52
54{
55 return m_fileName;
56}
57
58size_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
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:84
void clear()
Definition dstring.h:214
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
DString dir() const
Definition outputgen.cpp:48
void startPlainFile(const DString &name)
Definition outputgen.cpp:28
void endPlainFile()
Definition outputgen.cpp:40
TextStream m_t
Definition outputgen.h:113
DString m_fileName
Definition outputgen.h:116
DString fileName() const
Definition outputgen.cpp:53
void setStream(std::ostream *s)
Sets or changes the std::ostream to write to.
Definition textstream.h:67
void flush()
Flushes the buffer.
Definition textstream.h:212
void setFile(FILE *f)
Definition textstream.h:74
#define Config_getInt(name)
Definition config.h:34
#define term(fmt,...)
Definition message.h:137
FILE * fopen(const DString &fileName, const DString &mode)
Definition portable.cpp:365
int fclose(FILE *f)
Definition portable.cpp:385
size_t updateColumnCount(const char *s, size_t col)
Definition outputgen.cpp:58
Portable versions of functions that are platform dependent.
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