File: XmlOutputEventHandler.h

package info (click to toggle)
opensp 1.5.2-13
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, sid, stretch
  • size: 8,932 kB
  • ctags: 10,036
  • sloc: cpp: 65,784; ansic: 17,124; sh: 11,503; xml: 2,704; makefile: 926; perl: 561; yacc: 288; sed: 16
file content (156 lines) | stat: -rw-r--r-- 4,674 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
// Copyright (c) 1997 James Clark
// See the file COPYING for copying permission.

#ifndef XmlOutputEventHandler_INCLUDED
#define XmlOutputEventHandler_INCLUDED 1

#ifdef __GNUG__
#pragma interface
#endif

#include "ErrorCountEventHandler.h"
#include "Message.h"
#include "OutputCharStream.h"
#include "Boolean.h"
#include "CharsetInfo.h"
#include "ExtendEntityManager.h"
#include "IList.h"
#include "Ptr.h"
#include "SubstTable.h"

#ifdef SP_NAMESPACE
namespace SP_NAMESPACE {
#endif

class CharsetInfo;

class XmlOutputEventHandler : public ErrorCountEventHandler {
public:
  struct Options {
    Options();
    PackedBoolean nlInTag;
    PackedBoolean id;
    PackedBoolean notation;
    PackedBoolean ndata;
    PackedBoolean comment;
    PackedBoolean cdata;
    PackedBoolean lower;
    PackedBoolean piEscape;
    PackedBoolean empty;
    PackedBoolean attlist;
    PackedBoolean reportEnts;
    PackedBoolean reportIS;
    PackedBoolean expExt;
    PackedBoolean expInt;
    PackedBoolean intDecl;
    PackedBoolean extDecl;
    PackedBoolean sdataAsPi;
    PackedBoolean preserveCase;
    PackedBoolean overwrite;
    PackedBoolean writeOutsideOutDir;
  };
  XmlOutputEventHandler(const Options &,
			OutputCharStream *,
			const StringC &encodingName,
			const char *outputDir,
			const char *dtdLoc,
		        const Ptr<ExtendEntityManager> &,
	  		const CharsetInfo &,
			CmdLineApp *);
  ~XmlOutputEventHandler();
  void data(DataEvent *);
  void startElement(StartElementEvent *);
  void endElement(EndElementEvent *);
  void pi(PiEvent *);
  void startDtd(StartDtdEvent *);
  void endDtd(EndDtdEvent *);
  void endProlog(EndPrologEvent *event);
  void sdataEntity(SdataEntityEvent *);
  void externalDataEntity(ExternalDataEntityEvent *);
  void subdocEntity(SubdocEntityEvent *);
  void commentDecl(CommentDeclEvent *);
  void markedSectionStart(MarkedSectionStartEvent *);
  void markedSectionEnd(MarkedSectionEndEvent *);
  void message(MessageEvent *);
  void sgmlDecl(SgmlDeclEvent *);
private:
  XmlOutputEventHandler(const XmlOutputEventHandler &); // undefined
  void operator=(const XmlOutputEventHandler &); // undefined
  OutputCharStream &os();
  void outputData(const Char *s, size_t n, Boolean inLit, Boolean inSuperLit);
  void outputData(const Char *s, size_t n, Boolean inLit);
  void outputCdata(const Char *s, size_t n);
  void outputExternalId(const EntityDecl &decl);
  void outputAttribute(const AttributeList &attributes, size_t i);
  int fsiToUrl(const StringC &fsi, const Location &loc, StringC &url);
  int filenameToUrl(const StringC &filename, const Location &loc, StringC &url);
  void maybeStartDoctype(Boolean &doctypeStarted, const Dtd &dtd);
  void closeCdataSection();
  void entityDefaulted(EntityDefaultedEvent *event);
  void inputOpened(InputSource *in);
  void inputClosed(InputSource *in);
  const StringC &generalName(const StringC &name, StringC &buf);
  Boolean equalsIgnoreCase(const StringC &str1, StringC &str2);
  char *convertSuffix(char *name);
  int maybeCreateDirectories(char *path);
  Boolean checkFirstSeen(const StringC &name);
  void uniqueFilename(char *filename);
  char getQuoteMark(const StringC *contents);

  CmdLineApp *app_;
  Ptr<ExtendEntityManager> entityManager_;
  IList<OutputCharStream> outputStack_;
  IList<OutputByteStream> outputFileStack_;
  Vector<StringC> filesCreated_;
  Vector<StringC> originalFilePaths_;
  const CharsetInfo *systemCharset_;
  OutputCharStream *os_;
  OutputCharStream *extEnts_;
  OutputCharStream *intEnts_;
  FileOutputByteStream *extEntFile_;
  FileOutputByteStream *intEntFile_;
  const char *outputDir_;
  const char *dtdLoc_;
  Boolean inDtd_;
  Boolean useCdata_;
  Boolean inCdata_;
  int nCdataEndMatched_;
  Options options_;
  Boolean namecaseGeneral_;
  SubstTable lowerSubst_;
  StringC nameBuf_;
  NamedTable<Named> entTable_;
};

inline
OutputCharStream &XmlOutputEventHandler::os()
{
  return *os_;
}

class NullOutputByteStream : public OutputByteStream {
public:
  NullOutputByteStream();
  virtual ~NullOutputByteStream();
  void flush();
  void sputc(char c);
  void sputn(const char *, size_t);
  OutputByteStream &operator<<(char);
  OutputByteStream &operator<<(unsigned char);
  OutputByteStream &operator<<(const char *);
  OutputByteStream &operator<<(int);
  OutputByteStream &operator<<(unsigned);
  OutputByteStream &operator<<(long);
  OutputByteStream &operator<<(unsigned long);
  OutputByteStream &operator<<(const String<char> &);
  char *getBufferPtr() const;
  size_t getBufferSize() const;
  void usedBuffer(size_t);
  void flushBuf(char);
};

#ifdef SP_NAMESPACE
}
#endif

#endif /* not XmlOutputEventHandler_INCLUDED */