"Fossies" - the Fresh Open Source Software Archive

Member "OpenSP-1.5.2/nsgmls/SgmlsEventHandler.h" (14 May 2005, 4362 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 "SgmlsEventHandler.h" see the Fossies "Dox" file reference documentation.

    1 // Copyright (c) 1994 James Clark
    2 // See the file COPYING for copying permission.
    3 
    4 #ifndef SgmlsEventHandler_INCLUDED
    5 #define SgmlsEventHandler_INCLUDED 1
    6 
    7 #include <stddef.h>
    8 #include "Event.h"
    9 #include "Boolean.h"
   10 #include "StringC.h"
   11 #include "OutputCharStream.h"
   12 #include "StringSet.h"
   13 #include "Location.h"
   14 #include "Syntax.h"
   15 #include "Sd.h"
   16 #include "Ptr.h"
   17 #include "LinkProcess.h"
   18 #include "Message.h"
   19 #include "ErrorCountEventHandler.h"
   20 
   21 #ifdef SP_NAMESPACE
   22 namespace SP_NAMESPACE {
   23 #endif
   24 
   25 class SgmlParser;
   26 struct StorageObjectSpec;
   27 
   28 class SgmlsSubdocState {
   29 public:
   30   SgmlsSubdocState();
   31   SgmlsSubdocState(const SgmlParser *);
   32   void init(const SgmlParser *);
   33   void swap(SgmlsSubdocState &);
   34 protected:
   35   const SgmlParser *parser_;
   36   StringSet definedEntities_;
   37   StringSet definedNotations_;
   38   Boolean haveLinkProcess_;
   39   LinkProcess linkProcess_;
   40 private:
   41   SgmlsSubdocState(const SgmlsSubdocState &); // undefined
   42   void operator=(const SgmlsSubdocState &);   // undefined
   43 };
   44 
   45 class SgmlsEventHandler : public ErrorCountEventHandler,
   46   private SgmlsSubdocState, private Messenger {
   47 public:
   48   enum {
   49     outputAll = 07777,
   50     outputLine = 01,
   51     outputEntity = 02,
   52     outputId = 04,
   53     outputIncluded = 010,
   54     outputNotationSysid = 020,
   55     outputNonSgml = 040,
   56     outputEmpty = 0100,
   57     outputDataAtt = 0200,
   58     outputComment = 0400,
   59     outputTagOmission = 01000,
   60     outputAttributeOmission = 02000,
   61     outputParserInformation = 04000,
   62     outputPostfix = 010000, // note this not in outputAll
   63     };
   64       
   65   SgmlsEventHandler(const SgmlParser *,
   66             OutputCharStream *,
   67             Messenger *,
   68             unsigned outputFlags);
   69   ~SgmlsEventHandler();
   70   void data(DataEvent *);
   71   void startElement(StartElementEvent *);
   72   void endElement(EndElementEvent *);
   73   void pi(PiEvent *);
   74   void commentDecl(CommentDeclEvent *);
   75   void sdataEntity(SdataEntityEvent *);
   76   void externalDataEntity(ExternalDataEntityEvent *);
   77   void subdocEntity(SubdocEntityEvent *);
   78   void nonSgmlChar(NonSgmlCharEvent *);
   79   void appinfo(AppinfoEvent *);
   80   void uselink(UselinkEvent *);
   81   void sgmlDecl(SgmlDeclEvent *);
   82   void endProlog(EndPrologEvent *);
   83   void message(MessageEvent *);
   84   void entityDefaulted(EntityDefaultedEvent *event);
   85 protected:
   86   void dispatchMessage(const Message &);
   87   void initMessage(Message &);
   88 private:
   89   SgmlsEventHandler(const SgmlsEventHandler &); // undefined
   90   void operator=(const SgmlsEventHandler &);    // undefined
   91 
   92   void features(unsigned outputFlags);
   93   void attributes(const AttributeList &attributes, char code,
   94           const StringC *ownerName);
   95   void startAttribute(const StringC &name, char code,
   96               const StringC *ownerName);
   97   void defineEntity(const Entity *entity);
   98   void defineExternalDataEntity(const ExternalDataEntity *entity);
   99   void defineSubdocEntity(const SubdocEntity *entity);
  100   void defineExternalTextEntity(const ExternalEntity *entity);
  101   void defineInternalEntity(const InternalEntity *entity);
  102   void defineNotation(const Notation *notation);
  103   void externalId(const ExternalId &id, Boolean outputFile = 1);
  104   Boolean markEntity(const Entity *);
  105   Boolean markNotation(const Notation *);
  106   void startData();
  107   void flushData();
  108 
  109   void outputLocation(const Location &loc);
  110   void outputLocation1(const Location &loc);
  111   void outputString(const StringC &str);
  112   void outputString(const Char *, size_t);
  113   static void escaper(OutputCharStream &, Char);
  114 
  115   OutputCharStream &os();
  116 
  117   Messenger *messenger_;
  118   Location currentLocation_;
  119   OutputCharStream *os_;
  120   Boolean inDocument_;
  121   Boolean haveData_;
  122   ConstPtr<Sd> sd_;
  123   ConstPtr<Syntax> syntax_;
  124   const StorageObjectSpec *lastSos_;
  125   unsigned long lastLineno_;
  126   Location lastLoc_;
  127   PackedBoolean outputLine_;
  128   PackedBoolean outputIncluded_;
  129   PackedBoolean outputEntity_;
  130   PackedBoolean outputId_;
  131   PackedBoolean outputNotationSysid_;
  132   PackedBoolean outputNonSgml_;
  133   PackedBoolean outputEmpty_;
  134   PackedBoolean outputDataAtt_;
  135   PackedBoolean outputComment_;
  136   PackedBoolean outputTagOmission_;
  137   PackedBoolean outputAttributeOmission_;
  138   PackedBoolean outputParserInformation_;
  139 };
  140 
  141 inline
  142 void SgmlsEventHandler::outputString(const StringC &str)
  143 {
  144   outputString(str.data(), str.size());
  145 }
  146 
  147 inline
  148 OutputCharStream &SgmlsEventHandler::os()
  149 {
  150   return *os_;
  151 }
  152 
  153 #ifdef SP_NAMESPACE
  154 }
  155 #endif
  156 
  157 #endif /* not SgmlsEventHandler_INCLUDED */