InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
XMLContentIterator.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Lonnie Millett
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 __XMLContentIterator__
25 #define __XMLContentIterator__
26 
27 #include "IIDXMLElement.h"
28 #include "TextRange.h"
29 
37 {
38  public:
39 
41  typedef std::ptrdiff_t difference_type;
42  typedef const value_type* pointer;
43  typedef const value_type& reference;
44  friend class const_iterator;
45  typedef std::bidirectional_iterator_tag iterator_category;
46 
52 
56 
62  XMLContentIterator(const IIDXMLElement* element, int32 position);
63 
67 
68 
73  const InDesign::TextRange& operator * () const { ASSERT(fCurrent.IsValid()); return fCurrent;}
74 
79  const InDesign::TextRange* operator -> () const { ASSERT(fCurrent.IsValid()); return &fCurrent;}
80 
86 
92 
96  XMLContentIterator operator ++ (int) {XMLContentIterator tmp(*this); ++(*this); return tmp;}
97 
103 
107  XMLContentIterator operator -- (int) {XMLContentIterator tmp(*this); --(*this); return tmp;}
108 
114 
119  XMLContentIterator operator + (int32 n) const {return XMLContentIterator(*this) += n;}
120 
126 
131  XMLContentIterator operator - (int32 n) const {return XMLContentIterator(*this) -= n;}
132 
137  int32 Position() const {return fPosition;}
138 
143  //const InDesign::TextRange operator [] (int32 i) const {XMLContentIterator tmp(*this); tmp += i; return *tmp;}
144 
149  bool16 IsValid() const { return fCurrent.IsValid(); }
150 
151  friend XMLContentIterator operator + (int32 n, const XMLContentIterator& rhs) {return XMLContentIterator(rhs) += n;}
152  friend bool operator ==(const XMLContentIterator& x, const XMLContentIterator& y) {return x.fCurrent.Start() == y.fCurrent.Start() && x.fCurrent.End() == y.fCurrent.End();}
153  friend bool operator !=(const XMLContentIterator& x, const XMLContentIterator& y) {return x.fCurrent.Start() != y.fCurrent.Start() || x.fCurrent.End() != y.fCurrent.End();}
154  friend bool operator < (const XMLContentIterator& x, const XMLContentIterator& y) {return x.fPosition < y.fPosition;}
155  friend bool operator <=(const XMLContentIterator& x, const XMLContentIterator& y) {return x.fPosition <= y.fPosition;}
156  friend bool operator > (const XMLContentIterator& x, const XMLContentIterator& y) {return x.fPosition > y.fPosition;}
157  friend bool operator >=(const XMLContentIterator& x, const XMLContentIterator& y) {return x.fPosition >= y.fPosition;}
158 
159  private:
160  void CalcCurrentTextRange();
161  bool16 GetElementMarkerPositions(ITextModel *textModel, IIDXMLElement *element, TextIndex *startIndex, TextIndex *endIndex);
162 
164  TextIndex fStartIndex;
165  TextIndex fEndIndex;
166  InDesign::TextRange fCurrent;
167  int32 fPosition;
168 };
169 
170 #endif