InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IXMLOutStream.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Chris Parrish
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //========================================================================================
23 
24 #ifndef __IXMLOUTSTREAM__
25 #define __IXMLOUTSTREAM__
26 
27 #include "XMLID.h"
28 #include "IPMUnknown.h"
29 
30 #include "WideString.h"
31 #include "K2Vector.h"
32 #include "KeyValuePair.h"
33 
34 class IPMStream;
35 
61 class IXMLOutStream : public IPMUnknown
62 {
63  public:
64 
65  enum { kDefaultIID = IID_IXMLOUTSTREAM };
66 
68  enum eEncodingType { kUTF8, kUTF16, kShiftJIS};
69 
71  enum eAttributeType { kCDATA, kNMTOKEN, kNMTOKENS, kENTITY, kENTITIES, kID, kIDREF, kIDREFS, kNOTATION, kEnumeration };
73 
75  enum eAttributeQualifier { kQNone, kQRequired, kQImplied, kQFixed };
76 
77  //=====================================================================================
78  // CLASS : AttributeDfn
79  //=====================================================================================
83  class AttributeDfn {
84  public:
85  typedef object_type data_type;
86 
89  {}
96  : fName(n), fType(t), fQualifier(q), fDefault()
97  {}
105  : fName(n), fType(t), fQualifier(q), fDefault(d)
106  {}
113  AttributeDfn(const WideString &n, eAttributeType t, const UTF16TextChar *d, eAttributeQualifier q)
114  : fName(n), fType(t), fQualifier(q), fDefault(d)
115  {}
121  AttributeDfn(const UTF16TextChar* n, eAttributeType t, eAttributeQualifier q)
122  : fName(n), fType(t), fQualifier(q), fDefault()
123  {}
130  AttributeDfn(const UTF16TextChar* n, eAttributeType t, const WideString &d, eAttributeQualifier q)
131  : fName(n), fType(t), fQualifier(q), fDefault(d)
132  {}
139  AttributeDfn(const UTF16TextChar* n, eAttributeType t, const UTF16TextChar* d, eAttributeQualifier q)
140  : fName(n), fType(t), fQualifier(q), fDefault(d)
141  {}
144  {Copy(other);}
145 
147  bool16 operator==(const AttributeDfn &other) const
148  {return (fName == other.fName) && (fType == other.fType);}
151  {Copy(other); return *this;}
152 
153  private:
154  void Copy(const AttributeDfn &other)
155  {fName = other.fName; fType = other.fType; fQualifier = other.fQualifier; fDefault = other.fDefault;}
156 
157  public:
158  WideString fName;
162  };
163 
166 
167  //=====================================================================================
168  // CLASS : Attribute
169  //=====================================================================================
173  class Attribute {
174  public:
175  typedef object_type data_type;
176 
179  {}
184  Attribute(const WideString &n, const WideString &v)
185  : fName(n), fValue(v)
186  {}
191  Attribute(const UTF16TextChar *n, const UTF16TextChar *v)
192  : fName(n), fValue(v)
193  {}
195  Attribute(const Attribute &other)
196  {Copy(other);}
197 
201  const WideString &GetName() const
202  {return fName;}
206  const WideString &GetValue() const
207  {return fValue;}
208 
210  bool16 operator==(const Attribute &other) const
211  {return (fName == other.fName) && (fValue == other.fValue);}
214  {Copy(other); return *this;}
215 
216  private:
217  void Copy(const Attribute &other)
218  {fName = other.fName; fValue = other.fValue;}
219 
220  public:
221  WideString fName;
223  };
224 
227 
229 
230  typedef K2Vector<Entity> EntityMap;
231 
232 
238  };
239 
241  enum eContentParticleOccurrence { kExactlyOnce, kOneOrMore, kZeroOrMore, kOptional
246  };
247 
249  enum eKeyword { kKW_SPACE, kKW_PCDATA, kKW_ANY, kKW_EMPTY, kKW_REQUIRED, kKW_IMPLIED, kKW_FIXED, kKW_SYSTEM, kKW_PUBLIC, kKW_NDATA
260  };
261 
262 
263  //----- Stream
264 
271  virtual bool16 Open(eEncodingType encoding = kUTF16, bool16 stripInvalid = kTrue) = 0;
272 
275  virtual void Close() = 0;
276 
280  virtual ErrorCode Flush() = 0;
281 
282 
283  //----- Standard elements and data
284 
290  virtual void DocHeader(const WideString& version, bool16 standalone = kTrue) = 0;
291 
297  void DocHeader(const UTF16TextChar* version, bool16 standalone = kTrue)
298  { this->DocHeader(WideString(version), standalone); }
299 
303  virtual void TextDeclaration(const WideString& version) = 0;
304 
308  void TextDeclaration(const UTF16TextChar* version)
309  { this->TextDeclaration(WideString(version)); }
310 
316  virtual void DocType(const WideString& root, const WideString& URI) = 0;
317 
323  void DocType(const UTF16TextChar* root, const WideString& URI)
324  { this->DocType(WideString(root), URI); }
325 
331  void DocType(const WideString& root, const UTF16TextChar* URI)
332  { this->DocType(root, WideString(URI)); }
333 
339  void DocType(const UTF16TextChar* root, const UTF16TextChar* URI)
340  { this->DocType(WideString(root), WideString(URI)); }
341 
348  virtual void DocType(const WideString& root, const WideString& name, const WideString& URI) = 0;
349 
354  virtual void BeginDocType(const WideString& root, bool16 newLine = kFalse) = 0;
355 
360  void BeginDocType(const UTF16TextChar* root, bool16 newLine = kFalse)
361  { this->BeginDocType(WideString(root), newLine); }
362 
368  virtual void BeginDocType(const WideString& root, const WideString& systemIDLiteral, bool16 newLine = kFalse) = 0;
369 
376  virtual void BeginDocType(const WideString& root, const WideString& publicIDLiteral, const WideString& systemIDLiteral, bool16 newLine = kFalse) = 0;
377 
381  virtual void EndDocType(bool16 newLine = kFalse) = 0;
382 
388  virtual void WriteAttributeList(const WideString &elementName, const AttributeDfnList &dfns, bool16 newLine = kFalse) = 0;
389 
395  void WriteAttributeList(const UTF16TextChar* elementName, const AttributeDfnList &dfns, bool16 newLine = kFalse)
396  { this->WriteAttributeList(WideString(elementName), dfns, newLine); }
397 
402  virtual void BeginElementTypeDecl(const WideString& elementName, bool16 newLine = kFalse) = 0;
403 
408  void BeginElementTypeDecl(const UTF16TextChar* elementName, bool16 newLine = kFalse)
409  { this->BeginElementTypeDecl(WideString(elementName), newLine); }
410 
414  virtual void EndElementTypeDecl(bool16 newLine = kFalse) = 0;
415 
420  virtual void BeginContentModelDecl(eContentParticleSeparator separator = kNone, bool16 newLine = kFalse) = 0;
421 
426  virtual void EndContentModelDecl(eContentParticleOccurrence occurrence = kExactlyOnce, bool16 newLine = kFalse) = 0;
427 
432  virtual void BeginMixedContentModelDecl(eContentParticleSeparator separator = kNone, bool16 newLine = kFalse) = 0;
433 
439  virtual void EndMixedContentModelDecl(bool16 writeOccurrence = kTrue, bool16 newLine = kFalse) = 0;
440 
445  virtual void WriteSeparator(eContentParticleSeparator separator, bool16 newLine = kFalse) = 0;
446 
452  virtual void WriteContentParticle(const WideString& contentParticleName, eContentParticleOccurrence occurrence = kExactlyOnce, bool16 newLine = kFalse) = 0;
453 
459  void WriteContentParticle(const UTF16TextChar* contentParticleName, eContentParticleOccurrence occurrence = kExactlyOnce, bool16 newLine = kFalse)
460  { this->WriteContentParticle(WideString(contentParticleName), occurrence, newLine); }
461 
466  virtual void WriteKeyword(eKeyword keyword, bool16 newLine = kFalse) = 0;
467 
472  virtual void BeginAttListDecl(const WideString& elementName, bool16 newLine = kFalse) = 0;
473 
478  void BeginAttListDecl(const UTF16TextChar* elementName, bool16 newLine = kFalse)
479  { this->BeginAttListDecl(WideString(elementName), newLine); }
480 
484  virtual void EndAttListDecl(bool16 newLine = kFalse) = 0;
485 
490  virtual void WriteName(const WideString& name, bool16 newLine = kFalse) = 0;
491 
496  void WriteName(const UTF16TextChar* name, bool16 newLine = kFalse)
497  { this->WriteName(WideString(name), newLine); }
498 
503  virtual void WriteAttributeType(eAttributeType attType, bool16 newLine = kFalse) = 0;
504 
509  virtual void WriteAttributeValue(const WideString& attValue, bool16 newLine = kFalse) = 0;
510 
515  void WriteAttributeValue(const UTF16TextChar* attValue, bool16 newLine = kFalse)
516  { this->WriteAttributeValue(WideString(attValue), newLine); }
517 
523  virtual void BeginEntityDecl(const WideString& entityName, bool16 generalEntity = kTrue, bool16 newLine = kFalse) = 0;
524 
530  void BeginEntityDecl(const UTF16TextChar* entityName, bool16 generalEntity = kTrue, bool16 newLine = kFalse)
531  { this->BeginEntityDecl(WideString(entityName), generalEntity, newLine); }
532 
536  virtual void EndEntityDecl(bool16 newLine = kFalse) = 0;
537 
542  virtual void BeginNotationDecl(const WideString& notationName, bool16 newLine = kFalse) = 0;
543 
548  void BeginNotationDecl(const UTF16TextChar* notationName, bool16 newLine = kFalse)
549  { this->BeginNotationDecl(WideString(notationName), newLine); }
550 
554  virtual void EndNotationDecl(bool16 newLine = kFalse) = 0;
555 
561  virtual void WriteLiteral(const WideString& literal, bool16 wrapInQuotes = kFalse, bool16 newLine = kFalse) = 0;
562 
568  void WriteLiteral(const UTF16TextChar* literal, bool16 wrapInQuotes = kFalse, bool16 newLine = kFalse)
569  { this->WriteLiteral(WideString(literal), wrapInQuotes, newLine); }
570 
575  virtual void Push(const WideString& tagName, bool16 newLine = kFalse) = 0;
576 
581  void Push(const UTF16TextChar* tagName, bool16 newLine = kFalse)
582  { this->Push(WideString(tagName), newLine); }
583 
590  virtual void PushWithAttributes(const WideString& tagName, const AttributeList& attrs, bool16 newLine = kFalse) = 0;
591 
598  void PushWithAttributes(const UTF16TextChar* tagName, const AttributeList& attrs, bool16 newLine = kFalse)
599  { this->PushWithAttributes(WideString(tagName), attrs, newLine); }
600 
606  virtual ErrorCode Pop(bool16 newLine = kFalse) = 0;
607 
615  virtual void Write(const WideString& data, bool16 newLine = kFalse, bool16 escape = kTrue) = 0;
616 
624  inline void Write(const UTF16TextChar* data, bool16 newLine = kFalse, bool16 escape = kTrue)
625  { this->Write(WideString(data), newLine, escape); }
626 
636  virtual void WritePlatformText(IPMStream *data, int32 start, int32 count, bool16 newLine = kFalse, bool16 escape = kTrue) = 0;
637 
642  virtual void WriteEmpty(const WideString& tagName, bool16 newLine = kFalse) = 0;
643 
648  void WriteEmpty(const UTF16TextChar* tagName, bool16 newLine = kFalse)
649  { this->WriteEmpty(WideString(tagName), newLine); }
650 
656  virtual void WriteEmptyWithAttributes(const WideString& tag, const AttributeList& attrs, bool16 newLine = kFalse) = 0;
657 
663  void WriteEmptyWithAttributes(const UTF16TextChar* tag, const AttributeList& attrs, bool16 newLine = kFalse)
664  { this->WriteEmptyWithAttributes(WideString(tag), attrs, newLine); }
665 
666 
671  virtual void Comment(const WideString& comment, bool16 newLine = kFalse) = 0;
672 
677  void Comment(const UTF16TextChar* comment, bool16 newLine = kFalse)
678  { this->Comment(WideString(comment), newLine); }
679 
680 
686  virtual void BeginCData(const WideString& data, bool16 escape = kFalse) = 0;
687 
693  void BeginCData(const UTF16TextChar* data, bool16 escape = kFalse)
694  { this->BeginCData(WideString(data), escape); }
695 
699  virtual void EndCData(bool16 newLine = kTrue) = 0;
700 
701 
710  virtual void BeginPI(const WideString& piTarget, const WideString& piData, bool16 newLine = kFalse, bool16 escape = kFalse) = 0;
711 
715  virtual void EndPI(bool16 newLine = kFalse) = 0;
716 
717  //----- Formatting
718 
724  virtual void IndentLevel(bool increase) = 0;
725 
729  virtual void Indent(bool on) = 0;
730 
734  virtual bool16 DoIndent(void) const = 0;
735 
738  virtual void WriteIndent(void) = 0;
739 
740  //----- Utility
741 
745  virtual bool CheckStatus() = 0;
746 
750  virtual void ResetEntityMap(bool16 addStandardXMLEntity = kTrue) = 0;
751 
755  virtual void AppendEntityMap( EntityMap& map) = 0;
756 
757 };
758 
759 #endif //__IXMLOUTSTREAM__