My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
outputgen.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  *
4  *
5  * Copyright (C) 1997-2015 by Dimitri van Heesch.
6  *
7  * Permission to use, copy, modify, and distribute this software and its
8  * documentation under the terms of the GNU General Public License is hereby
9  * granted. No representations are made about the suitability of this software
10  * for any purpose. It is provided "as is" without express or implied warranty.
11  * See the GNU General Public License for more details.
12  *
13  * Documents produced by Doxygen are derivative works derived from the
14  * input used in their production; they are not affected by this license.
15  *
16  */
17 
18 #include <stdlib.h>
19 
20 #include <qfile.h>
21 
22 #include "outputgen.h"
23 #include "message.h"
24 #include "portable.h"
25 
27 {
28  //printf("OutputGenerator::OutputGenerator()\n");
29  file=0;
30  active=TRUE;
31  genStack = new QStack<bool>;
32  genStack->setAutoDelete(TRUE);
33 }
34 
36 {
37  //printf("OutputGenerator::~OutputGenerator()\n");
38  delete file;
39  delete genStack;
40 }
41 
42 void OutputGenerator::startPlainFile(const char *name)
43 {
44  //printf("startPlainFile(%s)\n",name);
45  fileName=dir+"/"+name;
46  file = new QFile(fileName);
47  if (!file->open(IO_WriteOnly))
48  {
49  err("Could not open file %s for writing\n",fileName.data());
50  exit(1);
51  }
52  t.setDevice(file);
53 }
54 
56 {
57  t.unsetDevice();
58  delete file;
59  file=0;
60  fileName.resize(0);
61 }
62 
64 {
65  genStack->push(new bool(isEnabled()));
66  //printf("%p:pushGeneratorState(%d) enabled=%d\n",this,genStack->count(),isEnabled());
67 }
68 
70 {
71  //printf("%p:popGeneratorState(%d) enabled=%d\n",this,genStack->count(),isEnabled());
72  bool *lb = genStack->pop();
73  ASSERT(lb!=0);
74  if (lb==0) return; // for some robustness against superfluous \endhtmlonly commands.
75  if (*lb) enable(); else disable();
76  delete lb;
77 }
78