~paul-lucas/zorba/bug-932374

« back to all changes in this revision

Viewing changes to swig/Collection.h

  • Committer: Paul J. Lucas
  • Date: 2012-09-21 20:26:47 UTC
  • mfrom: (10819.2.235 zorba)
  • Revision ID: paul@lucasmail.org-20120921202647-fy9n4jduhrnljrnb
MergeĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
#ifndef API_COLLECTION_H
17
17
#define API_COLLECTION_H
18
18
 
 
19
/** \brief A Collection is a persistent sequence of node items.
 
20
 *
 
21
 * Instances of this class can be used to modify or retrieve the contents
 
22
 * of a collection.
 
23
 *
 
24
 * The variable aNodes passed to any of the insert functions is evaluated
 
25
 * as though it were an enclosed expression in an element constructor.
 
26
 * The result of this step is a sequence of nodes to be inserted into the collection.
 
27
 *
 
28
 */
19
29
class Collection
20
30
{
21
31
private:
25
35
  Collection(const Collection& aMgr) : theCollection(aMgr.theCollection) {}
26
36
  Collection(zorba::Collection* aMgr) : theCollection(aMgr) {}
27
37
 
 
38
  /**
 
39
   * This function returns the sequence of nodes of the collection.
 
40
   *
 
41
   * @return The sequence contained in the given collection.
 
42
   *
 
43
   */
28
44
  ItemSequence contents();
 
45
 
 
46
  /**
 
47
   * This function deletes the first node from a collection.
 
48
   *
 
49
   * @throw XDDY0011 if the collection doesn't contain any node.
 
50
   *
 
51
   */
29
52
  void deleteNodeFirst();
 
53
  
 
54
  /**
 
55
   * This function deletes the last node from a collection.
 
56
   *
 
57
   * @throw XDDY0011 if the collection doesn't contain any node.
 
58
   *
 
59
   */
30
60
  void deleteNodeLast();
 
61
 
 
62
  /**
 
63
   * This function deletes zero of more nodes from a collection. 
 
64
   *
 
65
   * @param aNodes the nodes in the collection that should be deleted.
 
66
   *
 
67
   * @throw XDDY0011 if any nodes in the given sequence is not a member of a collection
 
68
   *        or not all nodes of the sequence belong to the same collection.
 
69
   *
 
70
   */
31
71
  void deleteNodes(const ItemSequence &aNodes );
 
72
 
 
73
  /**
 
74
   * This function deletes the n first nodes from a collection.
 
75
   *
 
76
   * @throw XDDY0011 if the collection doesn't contain any node.
 
77
   *
 
78
   */
32
79
  void deleteNodesFirst(unsigned long aNumNodes );
 
80
 
 
81
  /**
 
82
   * This function deletes the n last nodes from a collection.
 
83
   *
 
84
   * @throw XDDY0011 if the collection doesn't contain any node.
 
85
   *
 
86
   */
33
87
  void deleteNodesLast(unsigned long aNumNodes );
34
 
  //std::vector< Annotation > getAnnotations():
 
88
 
 
89
  /**
 
90
   * \brief Get the name of the collection.
 
91
   *
 
92
   * @return The name of the collection.
 
93
   */
35
94
  Item getName();
 
95
 
 
96
  /**
 
97
   * Retrieves the sequence type for this (static declared) collection.
 
98
   *
 
99
   * @return the sequence type for the said collection, or 0
 
100
   *  if this collection is not statically declared.
 
101
   *
 
102
   * @see isStatic()
 
103
   */
36
104
  TypeIdentifier getType();
 
105
 
 
106
  /**
 
107
   * This function returns the index of the given node in the collection.
 
108
   *
 
109
   * @param aNode The node to retrieve the index from.
 
110
   *
 
111
   * @return Returns the position of the given node in the collection.
 
112
   *
 
113
   * @throw XDDY0011 if node is not contained in any collection.
 
114
   *
 
115
   */
37
116
  long long indexOf(const Item &aNode );
 
117
 
 
118
  /**
 
119
   * This function inserts copies of the given
 
120
   * nodes into a collection at the position directly following the
 
121
   * given target node.
 
122
   *
 
123
   * @param aTarget the node in the collection after which the
 
124
   *        sequence should be inserted.
 
125
   * @param aNodes The sequences of nodes whose copies should
 
126
   *        be added to the collection.
 
127
   *
 
128
   * @throw XDDY0011 if any nodes in the sequence is not a member of a collection
 
129
   *        or not all nodes of the sequence belong to the same collection.
 
130
   *
 
131
   */
38
132
  void insertNodesAfter(const Item &aTarget, const ItemSequence &aNodes );
 
133
 
 
134
  /**
 
135
   * This function inserts copies of the given
 
136
   * nodes into a collection at the position directly preceding the
 
137
   * given target node.
 
138
   *
 
139
   * @param aTarget the node in the collection before which the
 
140
   *        sequence should be inserted.
 
141
   * @param aNodes The sequences of nodes whose copies should
 
142
   *        be added to the collection.
 
143
   *
 
144
   * @throw XDDY0011 if any nodes in the sequence is not a member of a collection
 
145
   *        or not all nodes of the sequence belong to the same collection.
 
146
   *
 
147
   */
39
148
  void insertNodesBefore(const Item &aTarget, const ItemSequence &aNodes );
 
149
 
 
150
  /**
 
151
   * This function inserts copies of the
 
152
   * given nodes at the beginning of the collection.
 
153
   *
 
154
   * @param aNodes The sequences of nodes whose copies
 
155
   *        should be added to the collection.
 
156
   *
 
157
   */
40
158
  void insertNodesFirst(const ItemSequence &aNodes );
 
159
 
 
160
  /**
 
161
   * This function inserts copies of the
 
162
   * given nodes at the end of the collection.
 
163
   *
 
164
   * @param aNodes The sequences of nodes whose copies
 
165
   *        should be added to the collection.
 
166
   *
 
167
   */
41
168
  void insertNodesLast(const ItemSequence &aNodes );
 
169
 
 
170
  /**
 
171
   * The function checks if this collection has been statically declared.
 
172
   *
 
173
   * @return true if the collection is a static collection, false otherwise.
 
174
   */
42
175
  bool isStatic();
 
176
 
43
177
  //void  registerDiagnosticHandler(DiagnosticHandler *aDiagnosticHandler );
44
178
};
45
179