Blame src/outputgen.cpp

Packit Service 50c9f2
/******************************************************************************
Packit Service 50c9f2
 *
Packit Service 50c9f2
 * 
Packit Service 50c9f2
 *
Packit Service 50c9f2
 * Copyright (C) 1997-2015 by Dimitri van Heesch.
Packit Service 50c9f2
 *
Packit Service 50c9f2
 * Permission to use, copy, modify, and distribute this software and its
Packit Service 50c9f2
 * documentation under the terms of the GNU General Public License is hereby 
Packit Service 50c9f2
 * granted. No representations are made about the suitability of this software 
Packit Service 50c9f2
 * for any purpose. It is provided "as is" without express or implied warranty.
Packit Service 50c9f2
 * See the GNU General Public License for more details.
Packit Service 50c9f2
 *
Packit Service 50c9f2
 * Documents produced by Doxygen are derivative works derived from the
Packit Service 50c9f2
 * input used in their production; they are not affected by this license.
Packit Service 50c9f2
 *
Packit Service 50c9f2
 */
Packit Service 50c9f2
Packit Service 50c9f2
#include <stdlib.h>
Packit Service 50c9f2
Packit Service 50c9f2
#include <qfile.h>
Packit Service 50c9f2
Packit Service 50c9f2
#include "outputgen.h"
Packit Service 50c9f2
#include "message.h"
Packit Service 50c9f2
#include "portable.h"
Packit Service 50c9f2
Packit Service 50c9f2
OutputGenerator::OutputGenerator()
Packit Service 50c9f2
{
Packit Service 50c9f2
  //printf("OutputGenerator::OutputGenerator()\n");
Packit Service 50c9f2
  file=0;
Packit Service 50c9f2
  active=TRUE;
Packit Service 50c9f2
  genStack = new QStack<bool>;
Packit Service 50c9f2
  genStack->setAutoDelete(TRUE);
Packit Service 50c9f2
}
Packit Service 50c9f2
Packit Service 50c9f2
OutputGenerator::~OutputGenerator()
Packit Service 50c9f2
{
Packit Service 50c9f2
  //printf("OutputGenerator::~OutputGenerator()\n");
Packit Service 50c9f2
  delete file;
Packit Service 50c9f2
  delete genStack;
Packit Service 50c9f2
}
Packit Service 50c9f2
Packit Service 50c9f2
void OutputGenerator::startPlainFile(const char *name)
Packit Service 50c9f2
{
Packit Service 50c9f2
  //printf("startPlainFile(%s)\n",name);
Packit Service 50c9f2
  fileName=dir+"/"+name;
Packit Service 50c9f2
  file = new QFile(fileName);
Packit Service 50c9f2
  if (!file->open(IO_WriteOnly))
Packit Service 50c9f2
  {
Packit Service 50c9f2
    err("Could not open file %s for writing\n",fileName.data());
Packit Service 50c9f2
    exit(1);
Packit Service 50c9f2
  }
Packit Service 50c9f2
  t.setDevice(file);
Packit Service 50c9f2
}
Packit Service 50c9f2
Packit Service 50c9f2
void OutputGenerator::endPlainFile()
Packit Service 50c9f2
{
Packit Service 50c9f2
  t.unsetDevice();
Packit Service 50c9f2
  delete file;
Packit Service 50c9f2
  file=0;
Packit Service 50c9f2
  fileName.resize(0);
Packit Service 50c9f2
}
Packit Service 50c9f2
Packit Service 50c9f2
void OutputGenerator::pushGeneratorState()
Packit Service 50c9f2
{
Packit Service 50c9f2
  genStack->push(new bool(isEnabled()));
Packit Service 50c9f2
  //printf("%p:pushGeneratorState(%d) enabled=%d\n",this,genStack->count(),isEnabled());
Packit Service 50c9f2
}
Packit Service 50c9f2
Packit Service 50c9f2
void OutputGenerator::popGeneratorState()
Packit Service 50c9f2
{
Packit Service 50c9f2
  //printf("%p:popGeneratorState(%d) enabled=%d\n",this,genStack->count(),isEnabled());
Packit Service 50c9f2
  bool *lb = genStack->pop();
Packit Service 50c9f2
  ASSERT(lb!=0);
Packit Service 50c9f2
  if (lb==0) return; // for some robustness against superfluous \endhtmlonly commands.
Packit Service 50c9f2
  if (*lb) enable(); else disable();
Packit Service 50c9f2
  delete lb;
Packit Service 50c9f2
}
Packit Service 50c9f2