Root/
Source at commit 1322 created 12 years 8 months ago. By meklort, Add doxygen to utils folder | |
---|---|
1 | /******************************************************************************␊ |
2 | *␊ |
3 | * $Id: outputgen.cpp,v 1.15 2001/03/19 19:27:41 root Exp $␊ |
4 | *␊ |
5 | * Copyright (C) 1997-2011 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 "qtbc.h"␊ |
21 | #include "outputgen.h"␊ |
22 | #include "message.h"␊ |
23 | #include "portable.h"␊ |
24 | ␊ |
25 | OutputGenerator::OutputGenerator()␊ |
26 | {␊ |
27 | //printf("OutputGenerator::OutputGenerator()\n");␊ |
28 | file=0;␊ |
29 | active=TRUE;␊ |
30 | genStack = new QStack<bool>;␊ |
31 | genStack->setAutoDelete(TRUE);␊ |
32 | }␊ |
33 | ␊ |
34 | OutputGenerator::~OutputGenerator()␊ |
35 | {␊ |
36 | //printf("OutputGenerator::~OutputGenerator()\n");␊ |
37 | delete file;␊ |
38 | delete genStack;␊ |
39 | }␊ |
40 | ␊ |
41 | void OutputGenerator::startPlainFile(const char *name)␊ |
42 | {␊ |
43 | //printf("startPlainFile(%s)\n",name);␊ |
44 | fileName=dir+"/"+name;␊ |
45 | file = new QFile(fileName);␊ |
46 | if (!file)␊ |
47 | {␊ |
48 | err("Could not create file object for %s\n",fileName.data());␊ |
49 | exit(1);␊ |
50 | }␊ |
51 | if (!file->open(IO_WriteOnly))␊ |
52 | {␊ |
53 | err("Could not open file %s for writing\n",fileName.data());␊ |
54 | exit(1);␊ |
55 | }␊ |
56 | t.setDevice(file);␊ |
57 | }␊ |
58 | ␊ |
59 | void OutputGenerator::endPlainFile()␊ |
60 | {␊ |
61 | delete file;␊ |
62 | file=0;␊ |
63 | fileName.resize(0);␊ |
64 | }␊ |
65 | ␊ |
66 | void OutputGenerator::pushGeneratorState()␊ |
67 | {␊ |
68 | genStack->push(new bool(isEnabled()));␊ |
69 | //printf("%p:pushGeneratorState(%d)\n",this,genStack->count());␊ |
70 | }␊ |
71 | ␊ |
72 | void OutputGenerator::popGeneratorState()␊ |
73 | {␊ |
74 | //printf("%p:popGeneratorState(%d)\n",this,genStack->count());␊ |
75 | bool *lb = genStack->pop();␊ |
76 | ASSERT(lb!=0);␊ |
77 | if (lb==0) return; // for some robustness against superfluous \endhtmlonly commands.␊ |
78 | if (*lb) enable(); else disable();␊ |
79 | delete lb;␊ |
80 | }␊ |
81 | ␊ |
82 |