Reenable test.
[wine-gecko.git] / db / mork / src / morkSortingRowCursor.cpp
blob20210411dd255c4f228a24bcf9d1a8da0cbf2bd9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1999
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef _MDB_
39 #include "mdb.h"
40 #endif
42 #ifndef _MORK_
43 #include "mork.h"
44 #endif
46 #ifndef _MORKNODE_
47 #include "morkNode.h"
48 #endif
50 #ifndef _MORKENV_
51 #include "morkEnv.h"
52 #endif
54 #ifndef _MORKCURSOR_
55 #include "morkCursor.h"
56 #endif
58 #ifndef _MORKSORTINGROWCURSOR_
59 #include "morkSortingRowCursor.h"
60 #endif
62 #ifndef _ORKINTABLEROWCURSOR_
63 #include "orkinTableRowCursor.h"
64 #endif
66 #ifndef _MORKSTORE_
67 #include "morkStore.h"
68 #endif
70 #ifndef _MORKTABLE_
71 #include "morkTable.h"
72 #endif
74 #ifndef _MORKSORTING_
75 #include "morkSorting.h"
76 #endif
78 #ifndef _MORKROW_
79 #include "morkRow.h"
80 #endif
82 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
84 // ````` ````` ````` ````` `````
85 // { ===== begin morkNode interface =====
87 /*public virtual*/ void
88 morkSortingRowCursor::CloseMorkNode(morkEnv* ev) // CloseSortingRowCursor() only if open
90 if ( this->IsOpenNode() )
92 this->MarkClosing();
93 this->CloseSortingRowCursor(ev);
94 this->MarkShut();
98 /*public virtual*/
99 morkSortingRowCursor::~morkSortingRowCursor() // CloseSortingRowCursor() executed earlier
101 MORK_ASSERT(this->IsShutNode());
104 /*public non-poly*/
105 morkSortingRowCursor::morkSortingRowCursor(morkEnv* ev,
106 const morkUsage& inUsage,
107 nsIMdbHeap* ioHeap, morkTable* ioTable, mork_pos inRowPos,
108 morkSorting* ioSorting)
109 : morkTableRowCursor(ev, inUsage, ioHeap, ioTable, inRowPos)
110 , mSortingRowCursor_Sorting( 0 )
112 if ( ev->Good() )
114 if ( ioSorting )
116 morkSorting::SlotWeakSorting(ioSorting, ev, &mSortingRowCursor_Sorting);
117 if ( ev->Good() )
119 // mNode_Derived = morkDerived_kTableRowCursor;
120 // mNode_Derived must stay equal to kTableRowCursor
123 else
124 ev->NilPointerError();
128 /*public non-poly*/ void
129 morkSortingRowCursor::CloseSortingRowCursor(morkEnv* ev)
131 if ( this )
133 if ( this->IsNode() )
135 mCursor_Pos = -1;
136 mCursor_Seed = 0;
137 morkSorting::SlotWeakSorting((morkSorting*) 0, ev, &mSortingRowCursor_Sorting);
138 this->CloseTableRowCursor(ev);
139 this->MarkShut();
141 else
142 this->NonNodeError(ev);
144 else
145 ev->NilPointerError();
148 // } ===== end morkNode methods =====
149 // ````` ````` ````` ````` `````
151 /*static*/ void
152 morkSortingRowCursor::NonSortingRowCursorTypeError(morkEnv* ev)
154 ev->NewError("non morkSortingRowCursor");
157 orkinTableRowCursor*
158 morkSortingRowCursor::AcquireUniqueRowCursorHandle(morkEnv* ev)
160 return this->AcquireTableRowCursorHandle(ev);
163 mork_bool
164 morkSortingRowCursor::CanHaveDupRowMembers(morkEnv* ev)
166 return morkBool_kFalse; // false is correct
169 mork_count
170 morkSortingRowCursor::GetMemberCount(morkEnv* ev)
172 morkTable* table = mTableRowCursor_Table;
173 if ( table )
174 return table->mTable_RowArray.mArray_Fill;
175 else
176 return 0;
178 // morkSorting* sorting = mSortingRowCursor_Sorting;
179 // if ( sorting )
180 // return sorting->mSorting_RowArray.mArray_Fill;
181 // else
182 // return 0;
185 morkRow*
186 morkSortingRowCursor::NextRow(morkEnv* ev, mdbOid* outOid, mdb_pos* outPos)
188 morkRow* outRow = 0;
189 mork_pos pos = -1;
191 morkSorting* sorting = mSortingRowCursor_Sorting;
192 if ( sorting )
194 if ( sorting->IsOpenNode() )
196 morkArray* array = &sorting->mSorting_RowArray;
197 pos = mCursor_Pos;
198 if ( pos < 0 )
199 pos = 0;
200 else
201 ++pos;
203 if ( pos < (mork_pos)(array->mArray_Fill))
205 mCursor_Pos = pos; // update for next time
206 morkRow* row = (morkRow*) array->At(pos);
207 if ( row )
209 if ( row->IsRow() )
211 outRow = row;
212 *outOid = row->mRow_Oid;
214 else
215 row->NonRowTypeError(ev);
217 else
218 ev->NilPointerError();
220 else
222 outOid->mOid_Scope = 0;
223 outOid->mOid_Id = morkId_kMinusOne;
226 else
227 sorting->NonOpenNodeError(ev);
229 else
230 ev->NilPointerError();
232 *outPos = pos;
233 return outRow;
236 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789