2004-03-01 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mcs / class / System.XML / System.Xml.XPath / XPathNodeIterator.cs
1 //
2 // System.Xml.XPath.XPathNodeIterator
3 //
4 // Author:
5 //   Jason Diamond (jason@injektilo.org)
6 //
7 // (C) 2002 Jason Diamond  http://injektilo.org/
8 //
9
10 using System;
11
12 namespace System.Xml.XPath
13 {
14         public abstract class XPathNodeIterator : ICloneable
15         {
16                 private int _count = -1;
17
18                 #region Constructor
19
20                 protected XPathNodeIterator ()
21                 {
22                 }
23
24                 #endregion
25
26                 #region Properties
27
28                 public virtual int Count
29                 {
30                         get
31                         {
32                                 if (_count == -1)
33                                 {
34                                         // compute and cache the count
35                                         XPathNodeIterator tmp = Clone ();
36                                         while (tmp.MoveNext ())
37                                                 ;
38                                         _count = tmp.CurrentPosition;
39                                 }
40                                 return _count;
41                         }
42                 }
43
44                 public abstract XPathNavigator Current { get; }
45
46                 public abstract int CurrentPosition { get; }
47
48                 #endregion
49
50                 #region Methods
51
52                 public abstract XPathNodeIterator Clone ();
53
54                 object ICloneable.Clone ()
55                 {
56                         return Clone ();
57                 }
58
59                 public abstract bool MoveNext ();
60                 
61                 #endregion
62         }
63 }