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#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
26{
27 //printf("OutputGenerator::OutputGenerator()\n");
28}
29
31{
32 //printf("startPlainFile(%s)\n",qPrint(name));
33 m_fileName=m_dir+"/"+name;
35 if (m_file==nullptr)
36 {
37 term("Could not open file {} for writing\n",m_fileName);
38 }
40}
41
49
51{
52 return m_dir;
53}
54
56{
57 return m_fileName;
58}
59
60size_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
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:88
void clear()
Definition dstring.h:218
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
DString dir() const
Definition outputgen.cpp:50
void startPlainFile(const DString &name)
Definition outputgen.cpp:30
void endPlainFile()
Definition outputgen.cpp:42
TextStream m_t
Definition outputgen.h:113
DString m_fileName
Definition outputgen.h:116
DString fileName() const
Definition outputgen.cpp:55
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:349
int fclose(FILE *f)
Definition portable.cpp:369
size_t updateColumnCount(const char *s, size_t col)
Definition outputgen.cpp:60
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:24