From ca25ddbe4b7623e5724dc232949e1132388c0bfc Mon Sep 17 00:00:00 2001 From: "davidmc%netscape.com" Date: Mon, 19 Apr 1999 22:28:03 +0000 Subject: [PATCH] clarify and increase number of oid<->pos<-> row table methods --- db/mork/src/orkinTable.cpp | 125 ++++++++++++++++++---------- db/mork/src/orkinTable.h | 19 +++-- mailnews/db/mork/src/orkinTable.cpp | 125 ++++++++++++++++++---------- mailnews/db/mork/src/orkinTable.h | 19 +++-- 4 files changed, 184 insertions(+), 104 deletions(-) diff --git a/db/mork/src/orkinTable.cpp b/db/mork/src/orkinTable.cpp index 0943ad4196e5..4477257e9c3d 100644 --- a/db/mork/src/orkinTable.cpp +++ b/db/mork/src/orkinTable.cpp @@ -332,7 +332,7 @@ orkinTable::DropActivity( // tell collection usage no longer expected if ( ev ) { morkTable* table = (morkTable*) mHandle_Object; - ev->StubMethodOnlyError(); + // ev->StubMethodOnlyError(); // okay to do nothing outErr = ev->AsErr(); } return outErr; @@ -475,18 +475,95 @@ orkinTable::GetTableRowCursor( // make a cursor, starting iteration at inRowPos // { ----- begin row position methods ----- /*virtual*/ mdb_err -orkinTable::RowPosToOid( // get row member for a table position +orkinTable::PosToOid( // get row member for a table position nsIMdbEnv* mev, // context mdb_pos inRowPos, // zero-based ordinal position of row in table mdbOid* outOid) // row oid at the specified position { mdb_err outErr = 0; + mdbOid roid; + roid.mOid_Scope = 0; + roid.mOid_Id = -1; + morkEnv* ev = this->CanUseTable(mev, /*inMutable*/ morkBool_kFalse, &outErr); if ( ev ) { - ev->StubMethodOnlyError(); + morkTable* table = (morkTable*) mHandle_Object; + morkRow* row = table->SafeRowAt(ev, inRowPos); + if ( row ) + roid = row->mRow_Oid; + outErr = ev->AsErr(); } + if ( outOid ) + *outOid = roid; + return outErr; +} + +/*virtual*/ mdb_err +orkinTable::OidToPos( // test for the table position of a row member + nsIMdbEnv* mev, // context + const mdbOid* inOid, // row to find in table + mdb_pos* outPos) // zero-based ordinal position of row in table +{ + mdb_err outErr = 0; + morkEnv* ev = this->CanUseTable(mev, /*inMutable*/ morkBool_kFalse, &outErr); + if ( ev ) + { + mork_pos pos = ((morkTable*) mHandle_Object)->ArrayHasOid(ev, inOid); + if ( outPos ) + *outPos = pos; + outErr = ev->AsErr(); + } + return outErr; +} + +/*virtual*/ mdb_err +orkinTable::PosToRow( // get row member for a table position + nsIMdbEnv* mev, // context + mdb_pos inRowPos, // zero-based ordinal position of row in table + nsIMdbRow** acqRow) // acquire row at table position inRowPos +{ + mdb_err outErr = 0; + nsIMdbRow* outRow = 0; + morkEnv* ev = this->CanUseTable(mev, /*inMutable*/ morkBool_kFalse, &outErr); + if ( ev ) + { + morkTable* table = (morkTable*) mHandle_Object; + morkStore* store = table->mTable_Store; + morkRow* row = table->SafeRowAt(ev, inRowPos); + if ( row && store ) + outRow = row->AcquireRowHandle(ev, store); + + outErr = ev->AsErr(); + } + if ( acqRow ) + *acqRow = outRow; + return outErr; +} + +/*virtual*/ mdb_err +orkinTable::RowToPos( // test for the table position of a row member + nsIMdbEnv* mev, // context + nsIMdbRow* ioRow, // row to find in table + mdb_pos* outPos) // zero-based ordinal position of row in table +{ + mdb_err outErr = 0; + mork_pos pos = -1; + morkEnv* ev = this->CanUseTable(mev, /*inMutable*/ morkBool_kFalse, &outErr); + if ( ev ) + { + morkRow* row = 0; + orkinRow* orow = (orkinRow*) ioRow; + if ( orow->CanUseRow(mev, /*inMutable*/ morkBool_kFalse, &outErr, &row) ) + { + morkTable* table = (morkTable*) mHandle_Object; + pos = table->ArrayHasOid(ev, &row->mRow_Oid); + } + outErr = ev->AsErr(); + } + if ( outPos ) + *outPos = pos; return outErr; } @@ -526,24 +603,6 @@ orkinTable::HasOid( // test for the table position of a row member return outErr; } -/*virtual*/ mdb_err -orkinTable::OidToPos( // test for the table position of a row member - nsIMdbEnv* mev, // context - const mdbOid* inOid, // row to find in table - mdb_pos* outPos) // zero-based ordinal position of row in table -{ - mdb_err outErr = 0; - morkEnv* ev = this->CanUseTable(mev, /*inMutable*/ morkBool_kFalse, &outErr); - if ( ev ) - { - mork_pos pos = ((morkTable*) mHandle_Object)->ArrayHasOid(ev, inOid); - if ( outPos ) - *outPos = pos; - outErr = ev->AsErr(); - } - return outErr; -} - /*virtual*/ mdb_err orkinTable::CutOid( // make sure the row with inOid is not a member nsIMdbEnv* mev, // context @@ -649,30 +708,6 @@ orkinTable::HasRow( // test for the table position of a row member } -/*virtual*/ mdb_err -orkinTable::RowToPos( // test for the table position of a row member - nsIMdbEnv* mev, // context - nsIMdbRow* ioRow, // row to find in table - mdb_pos* outPos) // zero-based ordinal position of row in table -{ - mdb_err outErr = 0; - morkEnv* ev = this->CanUseTable(mev, /*inMutable*/ morkBool_kFalse, &outErr); - if ( ev ) - { - morkRow* row = 0; - orkinRow* orow = (orkinRow*) ioRow; - if ( orow->CanUseRow(mev, /*inMutable*/ morkBool_kFalse, &outErr, &row) ) - { - morkTable* table = (morkTable*) mHandle_Object; - mork_pos pos = table->ArrayHasOid(ev, &row->mRow_Oid); - if ( outPos ) - *outPos = pos; - } - outErr = ev->AsErr(); - } - return outErr; -} - /*virtual*/ mdb_err orkinTable::CutRow( // make sure the row with inOid is not a member nsIMdbEnv* mev, // context diff --git a/db/mork/src/orkinTable.h b/db/mork/src/orkinTable.h index 5c31f9da9864..36a60f22d462 100644 --- a/db/mork/src/orkinTable.h +++ b/db/mork/src/orkinTable.h @@ -205,11 +205,21 @@ public: // type identification // } ----- end row position methods ----- // { ----- begin row position methods ----- - virtual mdb_err RowPosToOid( // get row member for a table position + virtual mdb_err PosToOid( // get row member for a table position nsIMdbEnv* ev, // context mdb_pos inRowPos, // zero-based ordinal position of row in table mdbOid* outOid); // row oid at the specified position - + + virtual mdb_err OidToPos( // test for the table position of a row member + nsIMdbEnv* ev, // context + const mdbOid* inOid, // row to find in table + mdb_pos* outPos); // zero-based ordinal position of row in table + + virtual mdb_err PosToRow( // test for the table position of a row member + nsIMdbEnv* ev, // context + mdb_pos inRowPos, // zero-based ordinal position of row in table + nsIMdbRow** acqRow); // acquire row at table position inRowPos + virtual mdb_err RowToPos( // test for the table position of a row member nsIMdbEnv* ev, // context nsIMdbRow* ioRow, // row to find in table @@ -227,11 +237,6 @@ public: // type identification const mdbOid* inOid, // row to find in table mdb_bool* outHasOid); // whether inOid is a member row - virtual mdb_err OidToPos( // test for the table position of a row member - nsIMdbEnv* ev, // context - const mdbOid* inOid, // row to find in table - mdb_pos* outPos); // zero-based ordinal position of row in table - virtual mdb_err CutOid( // make sure the row with inOid is not a member nsIMdbEnv* ev, // context const mdbOid* inOid); // row to remove from table diff --git a/mailnews/db/mork/src/orkinTable.cpp b/mailnews/db/mork/src/orkinTable.cpp index 0943ad4196e5..4477257e9c3d 100644 --- a/mailnews/db/mork/src/orkinTable.cpp +++ b/mailnews/db/mork/src/orkinTable.cpp @@ -332,7 +332,7 @@ orkinTable::DropActivity( // tell collection usage no longer expected if ( ev ) { morkTable* table = (morkTable*) mHandle_Object; - ev->StubMethodOnlyError(); + // ev->StubMethodOnlyError(); // okay to do nothing outErr = ev->AsErr(); } return outErr; @@ -475,18 +475,95 @@ orkinTable::GetTableRowCursor( // make a cursor, starting iteration at inRowPos // { ----- begin row position methods ----- /*virtual*/ mdb_err -orkinTable::RowPosToOid( // get row member for a table position +orkinTable::PosToOid( // get row member for a table position nsIMdbEnv* mev, // context mdb_pos inRowPos, // zero-based ordinal position of row in table mdbOid* outOid) // row oid at the specified position { mdb_err outErr = 0; + mdbOid roid; + roid.mOid_Scope = 0; + roid.mOid_Id = -1; + morkEnv* ev = this->CanUseTable(mev, /*inMutable*/ morkBool_kFalse, &outErr); if ( ev ) { - ev->StubMethodOnlyError(); + morkTable* table = (morkTable*) mHandle_Object; + morkRow* row = table->SafeRowAt(ev, inRowPos); + if ( row ) + roid = row->mRow_Oid; + outErr = ev->AsErr(); } + if ( outOid ) + *outOid = roid; + return outErr; +} + +/*virtual*/ mdb_err +orkinTable::OidToPos( // test for the table position of a row member + nsIMdbEnv* mev, // context + const mdbOid* inOid, // row to find in table + mdb_pos* outPos) // zero-based ordinal position of row in table +{ + mdb_err outErr = 0; + morkEnv* ev = this->CanUseTable(mev, /*inMutable*/ morkBool_kFalse, &outErr); + if ( ev ) + { + mork_pos pos = ((morkTable*) mHandle_Object)->ArrayHasOid(ev, inOid); + if ( outPos ) + *outPos = pos; + outErr = ev->AsErr(); + } + return outErr; +} + +/*virtual*/ mdb_err +orkinTable::PosToRow( // get row member for a table position + nsIMdbEnv* mev, // context + mdb_pos inRowPos, // zero-based ordinal position of row in table + nsIMdbRow** acqRow) // acquire row at table position inRowPos +{ + mdb_err outErr = 0; + nsIMdbRow* outRow = 0; + morkEnv* ev = this->CanUseTable(mev, /*inMutable*/ morkBool_kFalse, &outErr); + if ( ev ) + { + morkTable* table = (morkTable*) mHandle_Object; + morkStore* store = table->mTable_Store; + morkRow* row = table->SafeRowAt(ev, inRowPos); + if ( row && store ) + outRow = row->AcquireRowHandle(ev, store); + + outErr = ev->AsErr(); + } + if ( acqRow ) + *acqRow = outRow; + return outErr; +} + +/*virtual*/ mdb_err +orkinTable::RowToPos( // test for the table position of a row member + nsIMdbEnv* mev, // context + nsIMdbRow* ioRow, // row to find in table + mdb_pos* outPos) // zero-based ordinal position of row in table +{ + mdb_err outErr = 0; + mork_pos pos = -1; + morkEnv* ev = this->CanUseTable(mev, /*inMutable*/ morkBool_kFalse, &outErr); + if ( ev ) + { + morkRow* row = 0; + orkinRow* orow = (orkinRow*) ioRow; + if ( orow->CanUseRow(mev, /*inMutable*/ morkBool_kFalse, &outErr, &row) ) + { + morkTable* table = (morkTable*) mHandle_Object; + pos = table->ArrayHasOid(ev, &row->mRow_Oid); + } + outErr = ev->AsErr(); + } + if ( outPos ) + *outPos = pos; return outErr; } @@ -526,24 +603,6 @@ orkinTable::HasOid( // test for the table position of a row member return outErr; } -/*virtual*/ mdb_err -orkinTable::OidToPos( // test for the table position of a row member - nsIMdbEnv* mev, // context - const mdbOid* inOid, // row to find in table - mdb_pos* outPos) // zero-based ordinal position of row in table -{ - mdb_err outErr = 0; - morkEnv* ev = this->CanUseTable(mev, /*inMutable*/ morkBool_kFalse, &outErr); - if ( ev ) - { - mork_pos pos = ((morkTable*) mHandle_Object)->ArrayHasOid(ev, inOid); - if ( outPos ) - *outPos = pos; - outErr = ev->AsErr(); - } - return outErr; -} - /*virtual*/ mdb_err orkinTable::CutOid( // make sure the row with inOid is not a member nsIMdbEnv* mev, // context @@ -649,30 +708,6 @@ orkinTable::HasRow( // test for the table position of a row member } -/*virtual*/ mdb_err -orkinTable::RowToPos( // test for the table position of a row member - nsIMdbEnv* mev, // context - nsIMdbRow* ioRow, // row to find in table - mdb_pos* outPos) // zero-based ordinal position of row in table -{ - mdb_err outErr = 0; - morkEnv* ev = this->CanUseTable(mev, /*inMutable*/ morkBool_kFalse, &outErr); - if ( ev ) - { - morkRow* row = 0; - orkinRow* orow = (orkinRow*) ioRow; - if ( orow->CanUseRow(mev, /*inMutable*/ morkBool_kFalse, &outErr, &row) ) - { - morkTable* table = (morkTable*) mHandle_Object; - mork_pos pos = table->ArrayHasOid(ev, &row->mRow_Oid); - if ( outPos ) - *outPos = pos; - } - outErr = ev->AsErr(); - } - return outErr; -} - /*virtual*/ mdb_err orkinTable::CutRow( // make sure the row with inOid is not a member nsIMdbEnv* mev, // context diff --git a/mailnews/db/mork/src/orkinTable.h b/mailnews/db/mork/src/orkinTable.h index 5c31f9da9864..36a60f22d462 100644 --- a/mailnews/db/mork/src/orkinTable.h +++ b/mailnews/db/mork/src/orkinTable.h @@ -205,11 +205,21 @@ public: // type identification // } ----- end row position methods ----- // { ----- begin row position methods ----- - virtual mdb_err RowPosToOid( // get row member for a table position + virtual mdb_err PosToOid( // get row member for a table position nsIMdbEnv* ev, // context mdb_pos inRowPos, // zero-based ordinal position of row in table mdbOid* outOid); // row oid at the specified position - + + virtual mdb_err OidToPos( // test for the table position of a row member + nsIMdbEnv* ev, // context + const mdbOid* inOid, // row to find in table + mdb_pos* outPos); // zero-based ordinal position of row in table + + virtual mdb_err PosToRow( // test for the table position of a row member + nsIMdbEnv* ev, // context + mdb_pos inRowPos, // zero-based ordinal position of row in table + nsIMdbRow** acqRow); // acquire row at table position inRowPos + virtual mdb_err RowToPos( // test for the table position of a row member nsIMdbEnv* ev, // context nsIMdbRow* ioRow, // row to find in table @@ -227,11 +237,6 @@ public: // type identification const mdbOid* inOid, // row to find in table mdb_bool* outHasOid); // whether inOid is a member row - virtual mdb_err OidToPos( // test for the table position of a row member - nsIMdbEnv* ev, // context - const mdbOid* inOid, // row to find in table - mdb_pos* outPos); // zero-based ordinal position of row in table - virtual mdb_err CutOid( // make sure the row with inOid is not a member nsIMdbEnv* ev, // context const mdbOid* inOid); // row to remove from table