"Fossies" - the Fresh Open Source Software Archive

Member "OpenSP-1.5.2/sgmlnorm/sgmlnorm.cxx" (14 May 2005, 2236 Bytes) of package /linux/misc/old/OpenSP-1.5.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "sgmlnorm.cxx" see the Fossies "Dox" file reference documentation.

    1 // Copyright (c) 1996 James Clark
    2 // See the file COPYING for copying permission.
    3 
    4 #include "config.h"
    5 #include "sptchar.h"
    6 #include "ParserApp.h"
    7 #include "GenericEventHandler.h"
    8 #include "SGMLGenerator.h"
    9 #include "SgmlnormMessages.h"
   10 
   11 #ifdef SP_NAMESPACE
   12 using namespace SP_NAMESPACE;
   13 #endif
   14 
   15 class SGMLGeneratorEH : public SGMLGenerator, public GenericEventHandler {
   16 public:
   17   SGMLGeneratorEH(OutputCharStream *, unsigned genFlags, Messenger *);
   18   void reportMessage(const Message &msg, StringC &);
   19 private:
   20   Messenger *mgr_;
   21 };
   22 
   23 class SgmlnormApp : public ParserApp {
   24 public:
   25   SgmlnormApp();
   26   void processOption(AppChar opt, const AppChar *arg);
   27   ErrorCountEventHandler *makeEventHandler();
   28 private:
   29   unsigned genFlags_;
   30   Boolean rawOutput_;
   31 };
   32 
   33 SP_DEFINE_APP(SgmlnormApp)
   34 
   35 SgmlnormApp::SgmlnormApp()
   36 : rawOutput_(0), genFlags_(0)
   37 {
   38   changeOptionRegistration('n', AppChar(255));
   39   registerOption('d', SP_T("dtd"), SgmlnormMessages::dHelp);
   40   registerOption('m', SP_T("marked-sections"), SgmlnormMessages::mHelp);
   41   registerOption('n', SP_T("comments"), SgmlnormMessages::nHelp);
   42   registerOption('r', SP_T("raw"), SgmlnormMessages::rHelp);
   43   registerInfo(SgmlnormMessages::info1);
   44   registerInfo(SgmlnormMessages::info2);
   45   registerInfo(SgmlnormMessages::info3);
   46 }
   47 
   48 void SgmlnormApp::processOption(AppChar opt, const AppChar *arg)
   49 {
   50   switch (opt) {
   51   case AppChar(255):
   52     ParserApp::processOption('n', arg);
   53     break;
   54   case 'd':
   55     genFlags_ |= SGMLGenerator::generateDtd;
   56     break;
   57   case 'm':
   58     options_.eventsWanted.addMarkedSections();
   59     break;
   60   case 'n':
   61     options_.eventsWanted.addCommentDecls();
   62     break;
   63   case 'r':
   64     rawOutput_ = 1;
   65     break;
   66   default:
   67     ParserApp::processOption(opt, arg);
   68     break;
   69   }
   70 }
   71 
   72 ErrorCountEventHandler *SgmlnormApp::makeEventHandler()
   73 {
   74   OutputCharStream *os = makeStdOut();
   75   if (!rawOutput_)
   76     os = new RecordOutputCharStream(os);
   77   return new SGMLGeneratorEH(os, genFlags_, this);
   78 }
   79 
   80 SGMLGeneratorEH::SGMLGeneratorEH(OutputCharStream *os, unsigned genFlags,
   81                  Messenger *mgr)
   82 : SGMLGenerator(os, genFlags), GenericEventHandler(*this, 1), mgr_(mgr)
   83 {
   84 }
   85 
   86 void SGMLGeneratorEH::reportMessage(const Message &msg, StringC &)
   87 {
   88   mgr_->dispatchMessage(msg);
   89 }