mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
remove unused mork files, r=asuth, sr=neil, 550913, only used by SM and TB
This commit is contained in:
parent
c6b7acddb3
commit
e133726913
@ -60,14 +60,6 @@
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
// #define MORK_CONFIG_USE_ORKINFILE 1
|
||||
|
||||
#ifdef MORK_CONFIG_USE_ORKINFILE
|
||||
#ifndef _ORKINFILE_
|
||||
#include "orkinFile.h"
|
||||
#endif
|
||||
#endif /*MORK_CONFIG_USE_ORKINFILE*/
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
|
||||
@ -151,19 +143,6 @@ morkFile::CloseFile(morkEnv* ev) // called by CloseMorkNode();
|
||||
// } ===== end morkNode methods =====
|
||||
// ````` ````` ````` ````` `````
|
||||
|
||||
nsIMdbFile*
|
||||
morkFile::AcquireFileHandle(morkEnv* ev)
|
||||
{
|
||||
nsIMdbFile* outFile = 0;
|
||||
|
||||
#ifdef MORK_CONFIG_USE_ORKINFILE
|
||||
return this;
|
||||
#endif /*MORK_CONFIG_USE_ORKINFILE*/
|
||||
MORK_USED_1(ev);
|
||||
|
||||
return outFile;
|
||||
}
|
||||
|
||||
/*static*/ morkFile*
|
||||
morkFile::OpenOldFile(morkEnv* ev, nsIMdbHeap* ioHeap,
|
||||
const char* inFilePath, mork_bool inFrozen)
|
||||
|
@ -136,8 +136,6 @@ public: // public static standard file creation entry point
|
||||
|
||||
public: // non-poly morkFile methods
|
||||
|
||||
nsIMdbFile* AcquireFileHandle(morkEnv* ev); // mObject_Handle
|
||||
|
||||
mork_bool FileFrozen() const { return mFile_Frozen == 'F'; }
|
||||
mork_bool FileDoTrace() const { return mFile_DoTrace == 'T'; }
|
||||
mork_bool FileIoOpen() const { return mFile_IoOpen == 'O'; }
|
||||
|
@ -59,10 +59,6 @@
|
||||
#include "morkRowCellCursor.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINROWCELLCURSOR_
|
||||
#include "orkinRowCellCursor.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKSTORE_
|
||||
#include "morkStore.h"
|
||||
#endif
|
||||
|
@ -63,10 +63,6 @@
|
||||
#include "morkUniqRowCursor.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINTABLEROWCURSOR_
|
||||
#include "orkinTableRowCursor.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKSTORE_
|
||||
#include "morkStore.h"
|
||||
#endif
|
||||
@ -75,10 +71,6 @@
|
||||
#include "morkTable.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKSORTING_
|
||||
#include "morkSorting.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKROW_
|
||||
#include "morkRow.h"
|
||||
#endif
|
||||
|
@ -1,373 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _MDB_
|
||||
#include "mdb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORK_
|
||||
#include "mork.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKNODE_
|
||||
#include "morkNode.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKMAP_
|
||||
#include "morkMap.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKENV_
|
||||
#include "morkEnv.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKTABLE_
|
||||
#include "morkTable.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKSTORE_
|
||||
#include "morkStore.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKROWSPACE_
|
||||
#include "morkRowSpace.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKARRAY_
|
||||
#include "morkArray.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKROW_
|
||||
#include "morkRow.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINSORTING_
|
||||
#include "orkinSorting.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKTABLEROWCURSOR_
|
||||
#include "morkTableRowCursor.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKSORTING_
|
||||
#include "morkSorting.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKQUICKSORT_
|
||||
#include "morkQuickSort.h"
|
||||
#endif
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
// ````` ````` ````` ````` `````
|
||||
// { ===== begin morkNode interface =====
|
||||
|
||||
/*public virtual*/ void
|
||||
morkSorting::CloseMorkNode(morkEnv* ev) /*i*/ // CloseSorting() only if open
|
||||
{
|
||||
if ( this->IsOpenNode() )
|
||||
{
|
||||
this->MarkClosing();
|
||||
this->CloseSorting(ev);
|
||||
this->MarkShut();
|
||||
}
|
||||
}
|
||||
|
||||
/*public virtual*/
|
||||
morkSorting::~morkSorting() /*i*/ // assert CloseSorting() executed earlier
|
||||
{
|
||||
MORK_ASSERT(this->IsShutNode());
|
||||
MORK_ASSERT(mSorting_Table==0);
|
||||
}
|
||||
|
||||
#define morkSorting_kExtraSlots 2 /* space for two more rows */
|
||||
|
||||
/*public non-poly*/
|
||||
morkSorting::morkSorting(morkEnv* ev, const morkUsage& inUsage,
|
||||
nsIMdbHeap* ioNodeHeap, morkTable* ioTable,
|
||||
nsIMdbCompare* ioCompare,
|
||||
nsIMdbHeap* ioSlotHeap, mork_column inCol)
|
||||
: morkObject(ev, inUsage, ioNodeHeap, morkColor_kNone, (morkHandle*) 0)
|
||||
, mSorting_Table( 0 )
|
||||
|
||||
, mSorting_Compare( 0 )
|
||||
|
||||
, mSorting_RowArray(ev, morkUsage::kMember, (nsIMdbHeap*) 0,
|
||||
ioTable->GetRowCount() + morkSorting_kExtraSlots, ioSlotHeap)
|
||||
|
||||
, mSorting_Col( inCol )
|
||||
{
|
||||
if ( ev->Good() )
|
||||
{
|
||||
if ( ioTable && ioSlotHeap && ioCompare )
|
||||
{
|
||||
if ( inCol )
|
||||
{
|
||||
nsIMdbCompare_SlotStrongCompare(ioCompare, ev, &mSorting_Compare);
|
||||
morkTable::SlotWeakTable(ioTable, ev, &mSorting_Table);
|
||||
if ( ev->Good() )
|
||||
{
|
||||
mNode_Derived = morkDerived_kSorting;
|
||||
}
|
||||
}
|
||||
else
|
||||
this->ZeroColError(ev);
|
||||
}
|
||||
else
|
||||
ev->NilPointerError();
|
||||
}
|
||||
}
|
||||
|
||||
/*public non-poly*/ void
|
||||
morkSorting::CloseSorting(morkEnv* ev) /*i*/ // called by CloseMorkNode();
|
||||
{
|
||||
if ( this )
|
||||
{
|
||||
if ( this->IsNode() )
|
||||
{
|
||||
nsIMdbCompare_SlotStrongCompare((nsIMdbCompare*) 0, ev,
|
||||
&mSorting_Compare);
|
||||
morkTable::SlotWeakTable((morkTable*) 0, ev, &mSorting_Table);
|
||||
mSorting_RowArray.CloseMorkNode(ev);
|
||||
mSorting_Col = 0;
|
||||
this->MarkShut();
|
||||
}
|
||||
else
|
||||
this->NonNodeError(ev);
|
||||
}
|
||||
else
|
||||
ev->NilPointerError();
|
||||
}
|
||||
|
||||
// } ===== end morkNode methods =====
|
||||
// ````` ````` ````` ````` `````
|
||||
|
||||
/*static*/ void
|
||||
morkSorting::NonSortingTypeError(morkEnv* ev)
|
||||
{
|
||||
ev->NewError("non morkSorting");
|
||||
}
|
||||
|
||||
/*static*/ void
|
||||
morkSorting::NonSortingTypeWarning(morkEnv* ev)
|
||||
{
|
||||
ev->NewWarning("non morkSorting");
|
||||
}
|
||||
|
||||
/*static*/ void
|
||||
morkSorting::NilTableError(morkEnv* ev)
|
||||
{
|
||||
ev->NewError("nil mSorting_Table");
|
||||
}
|
||||
|
||||
/*static*/ void
|
||||
morkSorting::NilCompareError(morkEnv* ev)
|
||||
{
|
||||
ev->NewError("nil mSorting_Compare");
|
||||
}
|
||||
|
||||
/*static*/ void
|
||||
morkSorting::ZeroColError(morkEnv* ev)
|
||||
{
|
||||
ev->NewError("zero mSorting_Col");
|
||||
}
|
||||
|
||||
nsIMdbSorting*
|
||||
morkSorting::AcquireSortingHandle(morkEnv* ev)
|
||||
{
|
||||
nsIMdbSorting* outSorting = 0;
|
||||
orkinSorting* s = (orkinSorting*) mObject_Handle;
|
||||
if ( s ) // have an old handle?
|
||||
s->AddStrongRef(ev->AsMdbEnv());
|
||||
else // need new handle?
|
||||
{
|
||||
s = orkinSorting::MakeSorting(ev, this);
|
||||
mObject_Handle = s;
|
||||
}
|
||||
if ( s )
|
||||
outSorting = s;
|
||||
return outSorting;
|
||||
}
|
||||
|
||||
|
||||
class morkSortClosure {
|
||||
public:
|
||||
|
||||
morkEnv* mSortClosure_Env;
|
||||
morkSorting* mSortClosure_Sorting;
|
||||
|
||||
public:
|
||||
morkSortClosure(morkEnv* ev, morkSorting* ioSorting);
|
||||
};
|
||||
|
||||
morkSortClosure::morkSortClosure(morkEnv* ev, morkSorting* ioSorting)
|
||||
: mSortClosure_Env(ev), mSortClosure_Sorting(ioSorting)
|
||||
{
|
||||
}
|
||||
|
||||
static mdb_order morkRow_Order(const morkRow* inA, const morkRow* inB,
|
||||
morkSortClosure* ioClosure)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void morkSorting::sort_rows(morkEnv* ev)
|
||||
{
|
||||
morkTable* table = mSorting_Table;
|
||||
if ( table )
|
||||
{
|
||||
morkArray* tra = &table->mTable_RowArray;
|
||||
mork_count count = mSorting_RowArray.mArray_Fill;
|
||||
if ( this->is_seed_stale() || count != tra->mArray_Fill )
|
||||
count = this->copy_table_row_array(ev);
|
||||
|
||||
if ( ev->Good() )
|
||||
{
|
||||
void** slots = mSorting_RowArray.mArray_Slots;
|
||||
morkSortClosure closure(ev, this);
|
||||
|
||||
morkQuickSort((mork_u1*) slots, count, sizeof(morkRow*),
|
||||
(mdbAny_Order) morkRow_Order, &closure);
|
||||
}
|
||||
}
|
||||
else
|
||||
this->NilTableError(ev);
|
||||
}
|
||||
|
||||
mork_count morkSorting::copy_table_row_array(morkEnv* ev)
|
||||
{
|
||||
morkArray* tra = &mSorting_Table->mTable_RowArray;
|
||||
mork_bool bigEnough = mSorting_RowArray.mArray_Size > tra->mArray_Fill;
|
||||
if ( !bigEnough )
|
||||
bigEnough = mSorting_RowArray.Grow(ev, tra->mArray_Fill);
|
||||
|
||||
if ( ev->Good() && bigEnough )
|
||||
{
|
||||
mSorting_RowArray.mArray_Fill = tra->mArray_Fill;
|
||||
morkRow** src = (morkRow**) tra->mArray_Slots;
|
||||
morkRow** dst = (morkRow**) mSorting_RowArray.mArray_Slots;
|
||||
morkRow** end = dst + tra->mArray_Fill;
|
||||
|
||||
while ( dst < end )
|
||||
*dst++ = *src++;
|
||||
|
||||
this->sync_with_table_seed();
|
||||
}
|
||||
|
||||
return mSorting_RowArray.mArray_Fill;
|
||||
}
|
||||
|
||||
mork_pos
|
||||
morkSorting::ArrayHasOid(morkEnv* ev, const mdbOid* inOid)
|
||||
{
|
||||
MORK_USED_1(ev);
|
||||
mork_count count = mSorting_RowArray.mArray_Fill;
|
||||
mork_pos pos = -1;
|
||||
while ( ++pos < (mork_pos)count )
|
||||
{
|
||||
morkRow* row = (morkRow*) mSorting_RowArray.At(pos);
|
||||
MORK_ASSERT(row);
|
||||
if ( row && row->EqualOid(inOid) )
|
||||
{
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
mork_bool
|
||||
morkSorting::AddRow(morkEnv* ev, morkRow* ioRow)
|
||||
{
|
||||
MORK_USED_1(ioRow);
|
||||
return ev->Good();
|
||||
}
|
||||
|
||||
mork_bool
|
||||
morkSorting::CutRow(morkEnv* ev, morkRow* ioRow)
|
||||
{
|
||||
MORK_USED_1(ioRow);
|
||||
return ev->Good();
|
||||
}
|
||||
|
||||
|
||||
mork_bool
|
||||
morkSorting::CutAllRows(morkEnv* ev)
|
||||
{
|
||||
return ev->Good();
|
||||
}
|
||||
|
||||
morkSortingRowCursor*
|
||||
morkSorting::NewSortingRowCursor(morkEnv* ev, mork_pos inRowPos)
|
||||
{
|
||||
morkSortingRowCursor* outCursor = 0;
|
||||
if ( ev->Good() )
|
||||
{
|
||||
// nsIMdbHeap* heap = mSorting_Table->mTable_Store->mPort_Heap;
|
||||
// morkSortingRowCursor* cursor = 0;
|
||||
|
||||
// $$$$$
|
||||
// morkSortingRowCursor* cursor = new(*heap, ev)
|
||||
// morkSortingRowCursor(ev, morkUsage::kHeap, heap, this, inRowPos);
|
||||
// if ( cursor )
|
||||
// {
|
||||
// if ( ev->Good() )
|
||||
// outCursor = cursor;
|
||||
// else
|
||||
// cursor->CutStrongRef(ev);
|
||||
// }
|
||||
}
|
||||
return outCursor;
|
||||
}
|
||||
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
|
||||
morkSortingMap::~morkSortingMap()
|
||||
{
|
||||
}
|
||||
|
||||
morkSortingMap::morkSortingMap(morkEnv* ev, const morkUsage& inUsage,
|
||||
nsIMdbHeap* ioHeap, nsIMdbHeap* ioSlotHeap)
|
||||
: morkNodeMap(ev, inUsage, ioHeap, ioSlotHeap)
|
||||
{
|
||||
if ( ev->Good() )
|
||||
mNode_Derived = morkDerived_kSortingMap;
|
||||
}
|
||||
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
@ -1,256 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _MORKSORTING_
|
||||
#define _MORKSORTING_ 1
|
||||
|
||||
#ifndef _MORK_
|
||||
#include "mork.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKNODE_
|
||||
#include "morkNode.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKDEQUE_
|
||||
#include "morkDeque.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKOBJECT_
|
||||
#include "morkObject.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKARRAY_
|
||||
#include "morkArray.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKROWMAP_
|
||||
#include "morkRowMap.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKNODEMAP_
|
||||
#include "morkNodeMap.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKTABLE_
|
||||
#include "morkTable.h"
|
||||
#endif
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
class nsIMdbSorting;
|
||||
#define morkDerived_kSorting /*i*/ 0x536F /* ascii 'So' */
|
||||
|
||||
class morkSorting : public morkObject {
|
||||
|
||||
// NOTE the morkLink base is for morkRowSpace::mRowSpace_SortingsByPriority
|
||||
|
||||
// public: // slots inherited from morkObject (meant to inform only)
|
||||
// nsIMdbHeap* mNode_Heap;
|
||||
|
||||
// mork_base mNode_Base; // must equal morkBase_kNode
|
||||
// mork_derived mNode_Derived; // depends on specific node subclass
|
||||
|
||||
// mork_access mNode_Access; // kOpen, kClosing, kShut, or kDead
|
||||
// mork_usage mNode_Usage; // kHeap, kStack, kMember, kGlobal, kNone
|
||||
// mork_able mNode_Mutable; // can this node be modified?
|
||||
// mork_load mNode_Load; // is this node clean or dirty?
|
||||
|
||||
// mork_uses mNode_Uses; // refcount for strong refs
|
||||
// mork_refs mNode_Refs; // refcount for strong refs + weak refs
|
||||
|
||||
// mork_color mBead_Color; // ID for this bead
|
||||
// morkHandle* mObject_Handle; // weak ref to handle for this object
|
||||
|
||||
public: // state is public because the entire Mork system is private
|
||||
|
||||
morkTable* mSorting_Table; // weak ref to table
|
||||
|
||||
nsIMdbCompare* mSorting_Compare;
|
||||
|
||||
morkArray mSorting_RowArray; // array of morkRow pointers
|
||||
|
||||
mork_column mSorting_Col; // column that gets sorted
|
||||
|
||||
public: // sorting dirty handling more than morkNode::SetNodeDirty() etc.
|
||||
|
||||
void SetSortingDirty() { this->SetNodeDirty(); }
|
||||
|
||||
mork_bool IsSortingClean() const { return this->IsNodeClean(); }
|
||||
mork_bool IsSortingDirty() const { return this->IsNodeDirty(); }
|
||||
|
||||
public: // morkNode memory management operators
|
||||
void* operator new(size_t inSize, nsIMdbHeap& ioHeap, morkEnv* ev) CPP_THROW_NEW
|
||||
{ return morkNode::MakeNew(inSize, ioHeap, ev); }
|
||||
|
||||
|
||||
// { ===== begin morkNode interface =====
|
||||
public: // morkNode virtual methods
|
||||
virtual void CloseMorkNode(morkEnv* ev); // CloseSorting() if open
|
||||
virtual ~morkSorting(); // assert that close executed earlier
|
||||
|
||||
public: // morkSorting construction & destruction
|
||||
morkSorting(morkEnv* ev, const morkUsage& inUsage,
|
||||
nsIMdbHeap* ioNodeHeap, morkTable* ioTable,
|
||||
nsIMdbCompare* ioCompare,
|
||||
nsIMdbHeap* ioSlotHeap, mork_column inCol);
|
||||
void CloseSorting(morkEnv* ev); // called by CloseMorkNode();
|
||||
|
||||
private: // copying is not allowed
|
||||
morkSorting(const morkSorting& other);
|
||||
morkSorting& operator=(const morkSorting& other);
|
||||
|
||||
public: // dynamic type identification
|
||||
mork_bool IsSorting() const
|
||||
{ return IsNode() && mNode_Derived == morkDerived_kSorting; }
|
||||
// } ===== end morkNode methods =====
|
||||
|
||||
public: // errors
|
||||
static void NonSortingTypeError(morkEnv* ev);
|
||||
static void NonSortingTypeWarning(morkEnv* ev);
|
||||
static void ZeroColError(morkEnv* ev);
|
||||
static void NilTableError(morkEnv* ev);
|
||||
static void NilCompareError(morkEnv* ev);
|
||||
|
||||
public: // utilities
|
||||
|
||||
void sort_rows(morkEnv* ev);
|
||||
mork_count copy_table_row_array(morkEnv* ev);
|
||||
|
||||
public: // other sorting methods
|
||||
|
||||
mork_seed SortingSeed() const { return mSorting_RowArray.mArray_Seed; }
|
||||
|
||||
morkRow* SafeRowAt(morkEnv* ev, mork_pos inPos)
|
||||
{ return (morkRow*) mSorting_RowArray.SafeAt(ev, inPos); }
|
||||
|
||||
nsIMdbSorting* AcquireSortingHandle(morkEnv* ev); // mObject_Handle
|
||||
|
||||
mork_count GetRowCount() const { return mSorting_RowArray.mArray_Fill; }
|
||||
mork_pos ArrayHasOid(morkEnv* ev, const mdbOid* inOid);
|
||||
|
||||
morkSortingRowCursor* NewSortingRowCursor(morkEnv* ev, mork_pos inRowPos);
|
||||
|
||||
mork_bool AddRow(morkEnv* ev, morkRow* ioRow);
|
||||
|
||||
mork_bool CutRow(morkEnv* ev, morkRow* ioRow);
|
||||
|
||||
mork_bool CutAllRows(morkEnv* ev);
|
||||
|
||||
protected: // table seed sync management
|
||||
|
||||
mork_bool is_seed_stale() const
|
||||
{ return mSorting_RowArray.mArray_Seed != mSorting_Table->TableSeed(); }
|
||||
|
||||
void sync_with_table_seed()
|
||||
{ mSorting_RowArray.mArray_Seed = mSorting_Table->TableSeed(); }
|
||||
|
||||
public: // typesafe refcounting inlines calling inherited morkNode methods
|
||||
static void SlotWeakSorting(morkSorting* me,
|
||||
morkEnv* ev, morkSorting** ioSlot)
|
||||
{ morkNode::SlotWeakNode((morkNode*) me, ev, (morkNode**) ioSlot); }
|
||||
|
||||
static void SlotStrongSorting(morkSorting* me,
|
||||
morkEnv* ev, morkSorting** ioSlot)
|
||||
{ morkNode::SlotStrongNode((morkNode*) me, ev, (morkNode**) ioSlot); }
|
||||
};
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
#define morkDerived_kSortingMap /*i*/ 0x734D /* ascii 'sM' */
|
||||
|
||||
/*| morkSortingMap: maps mork_column -> morkSorting
|
||||
|*/
|
||||
class morkSortingMap : public morkNodeMap { // for mapping cols to sortings
|
||||
|
||||
public:
|
||||
|
||||
virtual ~morkSortingMap();
|
||||
morkSortingMap(morkEnv* ev, const morkUsage& inUsage,
|
||||
nsIMdbHeap* ioHeap, nsIMdbHeap* ioSlotHeap);
|
||||
|
||||
public: // other map methods
|
||||
|
||||
mork_bool AddSorting(morkEnv* ev, morkSorting* ioSorting)
|
||||
{ return this->AddNode(ev, ioSorting->mSorting_Col, ioSorting); }
|
||||
// the AddSorting() boolean return equals ev->Good().
|
||||
|
||||
mork_bool CutSorting(morkEnv* ev, mork_column inCol)
|
||||
{ return this->CutNode(ev, inCol); }
|
||||
// The CutSorting() boolean return indicates whether removal happened.
|
||||
|
||||
morkSorting* GetSorting(morkEnv* ev, mork_column inCol)
|
||||
{ return (morkSorting*) this->GetNode(ev, inCol); }
|
||||
// Note the returned table does NOT have an increase in refcount for this.
|
||||
|
||||
mork_num CutAllSortings(morkEnv* ev)
|
||||
{ return this->CutAllNodes(ev); }
|
||||
// CutAllSortings() releases all the referenced table values.
|
||||
};
|
||||
|
||||
class morkSortingMapIter: public morkMapIter{ // typesafe wrapper class
|
||||
|
||||
public:
|
||||
morkSortingMapIter(morkEnv* ev, morkSortingMap* ioMap)
|
||||
: morkMapIter(ev, ioMap) { }
|
||||
|
||||
morkSortingMapIter( ) : morkMapIter() { }
|
||||
void InitSortingMapIter(morkEnv* ev, morkSortingMap* ioMap)
|
||||
{ this->InitMapIter(ev, ioMap); }
|
||||
|
||||
mork_change*
|
||||
FirstSorting(morkEnv* ev, mork_column* outCol, morkSorting** outSorting)
|
||||
{ return this->First(ev, outCol, outSorting); }
|
||||
|
||||
mork_change*
|
||||
NextSorting(morkEnv* ev, mork_column* outCol, morkSorting** outSorting)
|
||||
{ return this->Next(ev, outCol, outSorting); }
|
||||
|
||||
mork_change*
|
||||
HereSorting(morkEnv* ev, mork_column* outCol, morkSorting** outSorting)
|
||||
{ return this->Here(ev, outCol, outSorting); }
|
||||
|
||||
// cutting while iterating hash map might dirty the parent table:
|
||||
mork_change*
|
||||
CutHereSorting(morkEnv* ev, mork_column* outCol, morkSorting** outSorting)
|
||||
{ return this->CutHere(ev, outCol, outSorting); }
|
||||
};
|
||||
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
#endif /* _MORKSORTING_ */
|
@ -1,236 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _MDB_
|
||||
#include "mdb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORK_
|
||||
#include "mork.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKNODE_
|
||||
#include "morkNode.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKENV_
|
||||
#include "morkEnv.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKCURSOR_
|
||||
#include "morkCursor.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKSORTINGROWCURSOR_
|
||||
#include "morkSortingRowCursor.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINTABLEROWCURSOR_
|
||||
#include "orkinTableRowCursor.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKSTORE_
|
||||
#include "morkStore.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKTABLE_
|
||||
#include "morkTable.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKSORTING_
|
||||
#include "morkSorting.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKROW_
|
||||
#include "morkRow.h"
|
||||
#endif
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
// ````` ````` ````` ````` `````
|
||||
// { ===== begin morkNode interface =====
|
||||
|
||||
/*public virtual*/ void
|
||||
morkSortingRowCursor::CloseMorkNode(morkEnv* ev) // CloseSortingRowCursor() only if open
|
||||
{
|
||||
if ( this->IsOpenNode() )
|
||||
{
|
||||
this->MarkClosing();
|
||||
this->CloseSortingRowCursor(ev);
|
||||
this->MarkShut();
|
||||
}
|
||||
}
|
||||
|
||||
/*public virtual*/
|
||||
morkSortingRowCursor::~morkSortingRowCursor() // CloseSortingRowCursor() executed earlier
|
||||
{
|
||||
MORK_ASSERT(this->IsShutNode());
|
||||
}
|
||||
|
||||
/*public non-poly*/
|
||||
morkSortingRowCursor::morkSortingRowCursor(morkEnv* ev,
|
||||
const morkUsage& inUsage,
|
||||
nsIMdbHeap* ioHeap, morkTable* ioTable, mork_pos inRowPos,
|
||||
morkSorting* ioSorting)
|
||||
: morkTableRowCursor(ev, inUsage, ioHeap, ioTable, inRowPos)
|
||||
, mSortingRowCursor_Sorting( 0 )
|
||||
{
|
||||
if ( ev->Good() )
|
||||
{
|
||||
if ( ioSorting )
|
||||
{
|
||||
morkSorting::SlotWeakSorting(ioSorting, ev, &mSortingRowCursor_Sorting);
|
||||
if ( ev->Good() )
|
||||
{
|
||||
// mNode_Derived = morkDerived_kTableRowCursor;
|
||||
// mNode_Derived must stay equal to kTableRowCursor
|
||||
}
|
||||
}
|
||||
else
|
||||
ev->NilPointerError();
|
||||
}
|
||||
}
|
||||
|
||||
/*public non-poly*/ void
|
||||
morkSortingRowCursor::CloseSortingRowCursor(morkEnv* ev)
|
||||
{
|
||||
if ( this )
|
||||
{
|
||||
if ( this->IsNode() )
|
||||
{
|
||||
mCursor_Pos = -1;
|
||||
mCursor_Seed = 0;
|
||||
morkSorting::SlotWeakSorting((morkSorting*) 0, ev, &mSortingRowCursor_Sorting);
|
||||
this->CloseTableRowCursor(ev);
|
||||
this->MarkShut();
|
||||
}
|
||||
else
|
||||
this->NonNodeError(ev);
|
||||
}
|
||||
else
|
||||
ev->NilPointerError();
|
||||
}
|
||||
|
||||
// } ===== end morkNode methods =====
|
||||
// ````` ````` ````` ````` `````
|
||||
|
||||
/*static*/ void
|
||||
morkSortingRowCursor::NonSortingRowCursorTypeError(morkEnv* ev)
|
||||
{
|
||||
ev->NewError("non morkSortingRowCursor");
|
||||
}
|
||||
|
||||
orkinTableRowCursor*
|
||||
morkSortingRowCursor::AcquireUniqueRowCursorHandle(morkEnv* ev)
|
||||
{
|
||||
return this->AcquireTableRowCursorHandle(ev);
|
||||
}
|
||||
|
||||
mork_bool
|
||||
morkSortingRowCursor::CanHaveDupRowMembers(morkEnv* ev)
|
||||
{
|
||||
return morkBool_kFalse; // false is correct
|
||||
}
|
||||
|
||||
mork_count
|
||||
morkSortingRowCursor::GetMemberCount(morkEnv* ev)
|
||||
{
|
||||
morkTable* table = mTableRowCursor_Table;
|
||||
if ( table )
|
||||
return table->mTable_RowArray.mArray_Fill;
|
||||
else
|
||||
return 0;
|
||||
|
||||
// morkSorting* sorting = mSortingRowCursor_Sorting;
|
||||
// if ( sorting )
|
||||
// return sorting->mSorting_RowArray.mArray_Fill;
|
||||
// else
|
||||
// return 0;
|
||||
}
|
||||
|
||||
morkRow*
|
||||
morkSortingRowCursor::NextRow(morkEnv* ev, mdbOid* outOid, mdb_pos* outPos)
|
||||
{
|
||||
morkRow* outRow = 0;
|
||||
mork_pos pos = -1;
|
||||
|
||||
morkSorting* sorting = mSortingRowCursor_Sorting;
|
||||
if ( sorting )
|
||||
{
|
||||
if ( sorting->IsOpenNode() )
|
||||
{
|
||||
morkArray* array = &sorting->mSorting_RowArray;
|
||||
pos = mCursor_Pos;
|
||||
if ( pos < 0 )
|
||||
pos = 0;
|
||||
else
|
||||
++pos;
|
||||
|
||||
if ( pos < (mork_pos)(array->mArray_Fill))
|
||||
{
|
||||
mCursor_Pos = pos; // update for next time
|
||||
morkRow* row = (morkRow*) array->At(pos);
|
||||
if ( row )
|
||||
{
|
||||
if ( row->IsRow() )
|
||||
{
|
||||
outRow = row;
|
||||
*outOid = row->mRow_Oid;
|
||||
}
|
||||
else
|
||||
row->NonRowTypeError(ev);
|
||||
}
|
||||
else
|
||||
ev->NilPointerError();
|
||||
}
|
||||
else
|
||||
{
|
||||
outOid->mOid_Scope = 0;
|
||||
outOid->mOid_Id = morkId_kMinusOne;
|
||||
}
|
||||
}
|
||||
else
|
||||
sorting->NonOpenNodeError(ev);
|
||||
}
|
||||
else
|
||||
ev->NilPointerError();
|
||||
|
||||
*outPos = pos;
|
||||
return outRow;
|
||||
}
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
@ -1,137 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _MORKSORTINGROWCURSOR_
|
||||
#define _MORKSORTINGROWCURSOR_ 1
|
||||
|
||||
#ifndef _MORK_
|
||||
#include "mork.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKCURSOR_
|
||||
#include "morkCursor.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKSORTINGROWCURSOR_
|
||||
#include "morkSortingRowCursor.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKTABLEROWCURSOR_
|
||||
#include "morkTableRowCursor.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKMAP_
|
||||
#include "morkMap.h"
|
||||
#endif
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
class orkinSortingRowCursor;
|
||||
// define morkDerived_kSortingRowCursor /*i*/ 0x7343 /* ascii 'sC' */
|
||||
|
||||
class morkSortingRowCursor : public morkTableRowCursor { // row iterator
|
||||
|
||||
// public: // slots inherited from morkObject (meant to inform only)
|
||||
// nsIMdbHeap* mNode_Heap;
|
||||
// mork_able mNode_Mutable; // can this node be modified?
|
||||
// mork_load mNode_Load; // is this node clean or dirty?
|
||||
// mork_base mNode_Base; // must equal morkBase_kNode
|
||||
// mork_derived mNode_Derived; // depends on specific node subclass
|
||||
// mork_access mNode_Access; // kOpen, kClosing, kShut, or kDead
|
||||
// mork_usage mNode_Usage; // kHeap, kStack, kMember, kGlobal, kNone
|
||||
// mork_uses mNode_Uses; // refcount for strong refs
|
||||
// mork_refs mNode_Refs; // refcount for strong refs + weak refs
|
||||
|
||||
// morkFactory* mObject_Factory; // weak ref to suite factory
|
||||
|
||||
// mork_seed mCursor_Seed;
|
||||
// mork_pos mCursor_Pos;
|
||||
// mork_bool mCursor_DoFailOnSeedOutOfSync;
|
||||
// mork_u1 mCursor_Pad[ 3 ]; // explicitly pad to u4 alignment
|
||||
|
||||
// morkTable* mTableRowCursor_Table; // weak ref to table
|
||||
|
||||
public: // state is public because the entire Mork system is private
|
||||
|
||||
morkSorting* mSortingRowCursor_Sorting; // weak ref to sorting
|
||||
|
||||
// { ===== begin morkNode interface =====
|
||||
public: // morkNode virtual methods
|
||||
virtual void CloseMorkNode(morkEnv* ev); // CloseSortingRowCursor()
|
||||
virtual ~morkSortingRowCursor(); // assert that close executed earlier
|
||||
|
||||
public: // morkSortingRowCursor construction & destruction
|
||||
morkSortingRowCursor(morkEnv* ev, const morkUsage& inUsage,
|
||||
nsIMdbHeap* ioHeap, morkTable* ioTable, mork_pos inRowPos,
|
||||
morkSorting* ioSorting);
|
||||
void CloseSortingRowCursor(morkEnv* ev); // called by CloseMorkNode();
|
||||
|
||||
private: // copying is not allowed
|
||||
morkSortingRowCursor(const morkSortingRowCursor& other);
|
||||
morkSortingRowCursor& operator=(const morkSortingRowCursor& other);
|
||||
|
||||
public: // dynamic type identification
|
||||
// mork_bool IsSortingRowCursor() const
|
||||
// { return IsNode() && mNode_Derived == morkDerived_kSortingRowCursor; }
|
||||
// } ===== end morkNode methods =====
|
||||
|
||||
public: // typing
|
||||
static void NonSortingRowCursorTypeError(morkEnv* ev);
|
||||
|
||||
public: // other table row cursor methods
|
||||
|
||||
virtual mork_bool CanHaveDupRowMembers(morkEnv* ev);
|
||||
virtual mork_count GetMemberCount(morkEnv* ev);
|
||||
|
||||
virtual orkinTableRowCursor* AcquireUniqueRowCursorHandle(morkEnv* ev);
|
||||
|
||||
// virtual mdb_pos NextRowOid(morkEnv* ev, mdbOid* outOid);
|
||||
virtual morkRow* NextRow(morkEnv* ev, mdbOid* outOid, mdb_pos* outPos);
|
||||
|
||||
public: // typesafe refcounting inlines calling inherited morkNode methods
|
||||
static void SlotWeakSortingRowCursor(morkSortingRowCursor* me,
|
||||
morkEnv* ev, morkSortingRowCursor** ioSlot)
|
||||
{ morkNode::SlotWeakNode((morkNode*) me, ev, (morkNode**) ioSlot); }
|
||||
|
||||
static void SlotStrongSortingRowCursor(morkSortingRowCursor* me,
|
||||
morkEnv* ev, morkSortingRowCursor** ioSlot)
|
||||
{ morkNode::SlotStrongNode((morkNode*) me, ev, (morkNode**) ioSlot); }
|
||||
};
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
#endif /* _MORKSORTINGROWCURSOR_ */
|
@ -60,10 +60,6 @@
|
||||
#include "morkTableRowCursor.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINTABLEROWCURSOR_
|
||||
#include "orkinTableRowCursor.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKSTORE_
|
||||
#include "morkStore.h"
|
||||
#endif
|
||||
|
@ -55,10 +55,6 @@
|
||||
#include "morkThumb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINTHUMB_
|
||||
#include "orkinThumb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKSTORE_
|
||||
#include "morkStore.h"
|
||||
#endif
|
||||
|
@ -1,746 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _MDB_
|
||||
#include "mdb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORK_
|
||||
#include "mork.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKNODE_
|
||||
#include "morkNode.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKHANDLE_
|
||||
#include "morkHandle.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKCELL_
|
||||
#include "morkCell.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKCELLOBJECT_
|
||||
#include "morkCellObject.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKROWOBJECT_
|
||||
#include "morkRowObject.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINCELL_
|
||||
#include "orkinCell.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKENV_
|
||||
#include "morkEnv.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKPOOL_
|
||||
#include "morkPool.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKROW_
|
||||
#include "morkRow.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKATOM_
|
||||
#include "morkAtom.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKSPACE_
|
||||
#include "morkSpace.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKROWSPACE_
|
||||
#include "morkRowSpace.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKSTORE_
|
||||
#include "morkStore.h"
|
||||
#endif
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
/* public virtual*/
|
||||
orkinCell:: ~orkinCell() // morkHandle destructor does everything
|
||||
{
|
||||
}
|
||||
|
||||
/*protected non-poly construction*/
|
||||
orkinCell::orkinCell(morkEnv* ev, // morkUsage is morkUsage_kPool
|
||||
morkHandleFace* ioFace, // must not be nil, cookie for this handle
|
||||
morkCellObject* ioObject) // must not be nil, the object for this handle
|
||||
: morkHandle(ev, ioFace, ioObject, morkMagic_kCell)
|
||||
{
|
||||
// do not modify mNode_Derived; leave it equal to morkDerived_kHandle
|
||||
}
|
||||
|
||||
|
||||
/*static */ orkinCell*
|
||||
orkinCell::MakeCell(morkEnv* ev, morkCellObject* ioObject)
|
||||
{
|
||||
mork_bool isEnv = ev->IsEnv();
|
||||
MORK_ASSERT(isEnv);
|
||||
if ( isEnv )
|
||||
{
|
||||
morkHandleFace* face = ev->NewHandle(sizeof(orkinCell));
|
||||
if ( face )
|
||||
return new(face) orkinCell(ev, face, ioObject);
|
||||
else
|
||||
ev->OutOfMemoryError();
|
||||
}
|
||||
|
||||
return (orkinCell*) 0;
|
||||
}
|
||||
|
||||
// ResyncWithRow() moved to the morkCellObject class:
|
||||
// mork_bool
|
||||
// orkinCell::ResyncWithRow(morkEnv* ev)
|
||||
// {
|
||||
// morkCellObject* cellObj = (morkCellObject*) mHandle_Object;
|
||||
// morkRow* row = cellObj->mCellObject_Row;
|
||||
// mork_pos pos = 0;
|
||||
// morkCell* cell = row->GetCell(ev, cellObj->mCellObject_Col, &pos);
|
||||
// if ( cell )
|
||||
// {
|
||||
// cellObj->mCellObject_Pos = pos;
|
||||
// cellObj->mCellObject_Cell = cell;
|
||||
// cellObj->mCellObject_RowSeed = row->mRow_Seed;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// cellObj->mCellObject_Cell = 0;
|
||||
// cellObj->MissingRowColumnError(ev);
|
||||
// }
|
||||
// return ev->Good();
|
||||
// }
|
||||
|
||||
morkEnv*
|
||||
orkinCell::CanUseCell(nsIMdbEnv* mev, mork_bool inMutable,
|
||||
mdb_err* outErr, morkCell** outCell) const
|
||||
{
|
||||
morkEnv* outEnv = 0;
|
||||
morkCell* cell = 0;
|
||||
morkEnv* ev = morkEnv::FromMdbEnv(mev);
|
||||
if ( ev )
|
||||
{
|
||||
morkCellObject* cellObj = (morkCellObject*)
|
||||
this->GetGoodHandleObject(ev, inMutable, morkMagic_kCell,
|
||||
/*inClosedOkay*/ morkBool_kFalse);
|
||||
if ( cellObj )
|
||||
{
|
||||
if ( cellObj->IsCellObject() )
|
||||
{
|
||||
if ( cellObj->IsMutable() || !inMutable )
|
||||
{
|
||||
morkRowObject* rowObj = cellObj->mCellObject_RowObject;
|
||||
if ( rowObj )
|
||||
{
|
||||
morkRow* row = cellObj->mCellObject_Row;
|
||||
if ( row )
|
||||
{
|
||||
if ( rowObj->mRowObject_Row == row )
|
||||
{
|
||||
mork_u2 oldSeed = cellObj->mCellObject_RowSeed;
|
||||
if ( row->mRow_Seed == oldSeed || cellObj->ResyncWithRow(ev) )
|
||||
{
|
||||
cell = cellObj->mCellObject_Cell;
|
||||
if ( cell )
|
||||
{
|
||||
outEnv = ev;
|
||||
}
|
||||
else
|
||||
cellObj->NilCellError(ev);
|
||||
}
|
||||
}
|
||||
else
|
||||
cellObj->WrongRowObjectRowError(ev);
|
||||
}
|
||||
else
|
||||
cellObj->NilRowError(ev);
|
||||
}
|
||||
else
|
||||
cellObj->NilRowObjectError(ev);
|
||||
}
|
||||
else
|
||||
cellObj->NonMutableNodeError(ev);
|
||||
}
|
||||
else
|
||||
cellObj->NonCellObjectTypeError(ev);
|
||||
}
|
||||
*outErr = ev->AsErr();
|
||||
}
|
||||
MORK_ASSERT(outEnv);
|
||||
*outCell = cell;
|
||||
|
||||
return outEnv;
|
||||
}
|
||||
|
||||
// { ===== begin nsIMdbISupports methods =====
|
||||
NS_IMPL_QUERY_INTERFACE0(orkinCell)
|
||||
|
||||
/*virtual*/ nsrefcnt
|
||||
orkinCell::AddRef() // add strong ref with no
|
||||
{
|
||||
morkEnv* ev = mHandle_Env;
|
||||
if ( ev && ev->IsEnv() )
|
||||
return this->Handle_AddStrongRef(ev->AsMdbEnv());
|
||||
else
|
||||
return morkEnv_kNonEnvTypeError;
|
||||
}
|
||||
|
||||
/*virtual*/ nsrefcnt
|
||||
orkinCell::Release() // cut strong ref
|
||||
{
|
||||
morkEnv* ev = mHandle_Env;
|
||||
if ( ev && ev->IsEnv() )
|
||||
return this->Handle_CutStrongRef(ev->AsMdbEnv());
|
||||
else
|
||||
return morkEnv_kNonEnvTypeError;
|
||||
}
|
||||
// } ===== end nsIMdbISupports methods =====
|
||||
|
||||
// { ===== begin nsIMdbObject methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinCell::IsFrozenMdbObject(nsIMdbEnv* mev, mdb_bool* outIsReadonly)
|
||||
{
|
||||
return this->Handle_IsFrozenMdbObject(mev, outIsReadonly);
|
||||
}
|
||||
// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin factory methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinCell::GetMdbFactory(nsIMdbEnv* mev, nsIMdbFactory** acqFactory)
|
||||
{
|
||||
return this->Handle_GetMdbFactory(mev, acqFactory);
|
||||
}
|
||||
// } ----- end factory methods -----
|
||||
|
||||
// { ----- begin ref counting for well-behaved cyclic graphs -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinCell::GetWeakRefCount(nsIMdbEnv* mev, // weak refs
|
||||
mdb_count* outCount)
|
||||
{
|
||||
return this->Handle_GetWeakRefCount(mev, outCount);
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinCell::GetStrongRefCount(nsIMdbEnv* mev, // strong refs
|
||||
mdb_count* outCount)
|
||||
{
|
||||
return this->Handle_GetStrongRefCount(mev, outCount);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinCell::AddWeakRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_AddWeakRef(mev);
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinCell::AddStrongRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_AddStrongRef(mev);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinCell::CutWeakRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_CutWeakRef(mev);
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinCell::CutStrongRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_CutStrongRef(mev);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinCell::CloseMdbObject(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_CloseMdbObject(mev);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinCell::IsOpenMdbObject(nsIMdbEnv* mev, mdb_bool* outOpen)
|
||||
{
|
||||
return this->Handle_IsOpenMdbObject(mev, outOpen);
|
||||
}
|
||||
// } ----- end ref counting -----
|
||||
|
||||
// } ===== end nsIMdbObject methods =====
|
||||
|
||||
// { ===== begin nsIMdbBlob methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinCell::SetBlob(nsIMdbEnv* mev,
|
||||
nsIMdbBlob* ioBlob)
|
||||
{
|
||||
MORK_USED_1(ioBlob);
|
||||
mdb_err outErr = 0;
|
||||
morkCell* cell = 0;
|
||||
morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
|
||||
&outErr, &cell);
|
||||
if ( ev )
|
||||
{
|
||||
// remember row->MaybeDirtySpaceStoreAndRow();
|
||||
|
||||
ev->StubMethodOnlyError();
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
|
||||
return outErr;
|
||||
} // reads inBlob slots
|
||||
// when inBlob is in the same suite, this might be fastest cell-to-cell
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinCell::ClearBlob( // make empty (so content has zero length)
|
||||
nsIMdbEnv* mev)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkCell* cell = 0;
|
||||
morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
|
||||
&outErr, &cell);
|
||||
if ( ev )
|
||||
{
|
||||
// remember row->MaybeDirtySpaceStoreAndRow();
|
||||
|
||||
ev->StubMethodOnlyError();
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
|
||||
return outErr;
|
||||
}
|
||||
// clearing a yarn is like SetYarn() with empty yarn instance content
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinCell::GetBlobFill(nsIMdbEnv* mev,
|
||||
mdb_fill* outFill)
|
||||
// Same value that would be put into mYarn_Fill, if one called GetYarn()
|
||||
// with a yarn instance that had mYarn_Buf==nil and mYarn_Size==0.
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mdb_fill fill = 0;
|
||||
morkCell* cell = 0;
|
||||
morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
|
||||
&outErr, &cell);
|
||||
if ( ev )
|
||||
{
|
||||
ev->StubMethodOnlyError();
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( outFill )
|
||||
*outFill = fill;
|
||||
|
||||
return outErr;
|
||||
} // size of blob
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinCell::SetYarn(nsIMdbEnv* mev,
|
||||
const mdbYarn* inYarn)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkCell* cell = 0;
|
||||
morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
|
||||
&outErr, &cell);
|
||||
if ( ev )
|
||||
{
|
||||
morkCellObject* cellObj = (morkCellObject*) mHandle_Object;
|
||||
morkRow* row = cellObj->mCellObject_Row;
|
||||
if ( row )
|
||||
{
|
||||
morkStore* store = row->GetRowSpaceStore(ev);
|
||||
if ( store )
|
||||
{
|
||||
cell->SetYarn(ev, inYarn, store);
|
||||
if ( row->IsRowClean() && store->mStore_CanDirty )
|
||||
row->MaybeDirtySpaceStoreAndRow();
|
||||
}
|
||||
}
|
||||
else
|
||||
ev->NilPointerError();
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
|
||||
return outErr;
|
||||
} // reads from yarn slots
|
||||
// make this text object contain content from the yarn's buffer
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinCell::GetYarn(nsIMdbEnv* mev,
|
||||
mdbYarn* outYarn)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkCell* cell = 0;
|
||||
morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
|
||||
&outErr, &cell);
|
||||
if ( ev )
|
||||
{
|
||||
morkAtom* atom = cell->GetAtom();
|
||||
atom->GetYarn(outYarn);
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
|
||||
return outErr;
|
||||
} // writes some yarn slots
|
||||
// copy content into the yarn buffer, and update mYarn_Fill and mYarn_Form
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinCell::AliasYarn(nsIMdbEnv* mev,
|
||||
mdbYarn* outYarn)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkCell* cell = 0;
|
||||
morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
|
||||
&outErr, &cell);
|
||||
if ( ev )
|
||||
{
|
||||
morkAtom* atom = cell->GetAtom();
|
||||
atom->AliasYarn(outYarn);
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
|
||||
return outErr;
|
||||
} // writes ALL yarn slots
|
||||
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// } ===== end nsIMdbBlob methods =====
|
||||
|
||||
// { ===== begin nsIMdbCell methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinCell::SetColumn(nsIMdbEnv* mev, mdb_column inColumn)
|
||||
{
|
||||
MORK_USED_1(inColumn);
|
||||
mdb_err outErr = 0;
|
||||
morkCell* cell = 0;
|
||||
morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
|
||||
&outErr, &cell);
|
||||
if ( ev )
|
||||
{
|
||||
// remember row->MaybeDirtySpaceStoreAndRow();
|
||||
|
||||
morkCellObject* cellObj = (morkCellObject*) mHandle_Object;
|
||||
MORK_USED_1(cellObj);
|
||||
|
||||
ev->StubMethodOnlyError();
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinCell::GetColumn(nsIMdbEnv* mev, mdb_column* outColumn)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mdb_column col = 0;
|
||||
morkCell* cell = 0;
|
||||
morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
|
||||
&outErr, &cell);
|
||||
if ( ev )
|
||||
{
|
||||
morkCellObject* cellObj = (morkCellObject*) mHandle_Object;
|
||||
col = cellObj->mCellObject_Col;
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( outColumn )
|
||||
*outColumn = col;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinCell::GetCellInfo( // all cell metainfo except actual content
|
||||
nsIMdbEnv* mev,
|
||||
mdb_column* outColumn, // the column in the containing row
|
||||
mdb_fill* outBlobFill, // the size of text content in bytes
|
||||
mdbOid* outChildOid, // oid of possible row or table child
|
||||
mdb_bool* outIsRowChild) // nonzero if child, and a row child
|
||||
// Checking all cell metainfo is a good way to avoid forcing a large cell
|
||||
// in to memory when you don't actually want to use the content.
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mdb_bool isRowChild = morkBool_kFalse;
|
||||
mdbOid childOid;
|
||||
childOid.mOid_Scope = 0;
|
||||
childOid.mOid_Id = 0;
|
||||
mork_fill blobFill = 0;
|
||||
mdb_column column = 0;
|
||||
morkCell* cell = 0;
|
||||
morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
|
||||
&outErr, &cell);
|
||||
if ( ev )
|
||||
{
|
||||
morkCellObject* cellObj;
|
||||
cellObj = (morkCellObject*) mHandle_Object;
|
||||
ev->StubMethodOnlyError();
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( outIsRowChild )
|
||||
*outIsRowChild = isRowChild;
|
||||
if ( outChildOid )
|
||||
*outChildOid = childOid;
|
||||
if ( outBlobFill )
|
||||
*outBlobFill = blobFill;
|
||||
if ( outColumn )
|
||||
*outColumn = column;
|
||||
|
||||
return outErr;
|
||||
}
|
||||
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinCell::GetRow(nsIMdbEnv* mev, // parent row for this cell
|
||||
nsIMdbRow** acqRow)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbRow* outRow = 0;
|
||||
morkCell* cell = 0;
|
||||
morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
|
||||
&outErr, &cell);
|
||||
if ( ev )
|
||||
{
|
||||
morkCellObject* cellObj = (morkCellObject*) mHandle_Object;
|
||||
morkRowObject* rowObj = cellObj->mCellObject_RowObject;
|
||||
outRow = rowObj->AcquireRowHandle(ev);
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( acqRow )
|
||||
*acqRow = outRow;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinCell::GetPort(nsIMdbEnv* mev, // port containing cell
|
||||
nsIMdbPort** acqPort)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbPort* outPort = 0;
|
||||
morkCell* cell = 0;
|
||||
morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
|
||||
&outErr, &cell);
|
||||
if ( ev )
|
||||
{
|
||||
morkCellObject* cellObj = (morkCellObject*) mHandle_Object;
|
||||
morkRow* row = cellObj->mCellObject_Row;
|
||||
if ( row )
|
||||
{
|
||||
morkStore* store = row->GetRowSpaceStore(ev);
|
||||
if ( store )
|
||||
outPort = store->AcquireStoreHandle(ev);
|
||||
}
|
||||
else
|
||||
ev->NilPointerError();
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( acqPort )
|
||||
*acqPort = outPort;
|
||||
return outErr;
|
||||
}
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin children methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinCell::HasAnyChild( // does cell have a child instead of text?
|
||||
nsIMdbEnv* mev,
|
||||
mdbOid* outOid, // out id of row or table (or unbound if no child)
|
||||
mdb_bool* outIsRow) // nonzero if child is a row (rather than a table)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mdb_bool isRow = morkBool_kFalse;
|
||||
outOid->mOid_Scope = 0;
|
||||
outOid->mOid_Id = morkId_kMinusOne;
|
||||
morkCell* cell = 0;
|
||||
morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
|
||||
&outErr, &cell);
|
||||
if ( ev )
|
||||
{
|
||||
morkCellObject* cellObj = (morkCellObject*) mHandle_Object;
|
||||
morkAtom* atom = cellObj->GetCellAtom(ev);
|
||||
if ( atom )
|
||||
{
|
||||
isRow = atom->IsRowOid();
|
||||
if ( isRow || atom->IsTableOid() )
|
||||
*outOid = ((morkOidAtom*) atom)->mOidAtom_Oid;
|
||||
}
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( outIsRow )
|
||||
*outIsRow = isRow;
|
||||
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinCell::GetAnyChild( // access table of specific attribute
|
||||
nsIMdbEnv* mev, // context
|
||||
nsIMdbRow** acqRow, // child row (or null)
|
||||
nsIMdbTable** acqTable) // child table (or null)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbRow* outRow = 0;
|
||||
nsIMdbTable* outTable = 0;
|
||||
morkCell* cell = 0;
|
||||
morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
|
||||
&outErr, &cell);
|
||||
if ( ev )
|
||||
{
|
||||
morkCellObject* cellObj;
|
||||
cellObj = (morkCellObject*) mHandle_Object;
|
||||
ev->StubMethodOnlyError();
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
MORK_ASSERT(acqTable);
|
||||
if ( acqTable )
|
||||
*acqTable = outTable;
|
||||
MORK_ASSERT(acqRow);
|
||||
if ( acqRow )
|
||||
*acqRow = outRow;
|
||||
|
||||
return outErr;
|
||||
}
|
||||
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinCell::SetChildRow( // access table of specific attribute
|
||||
nsIMdbEnv* mev, // context
|
||||
nsIMdbRow* ioRow)
|
||||
{
|
||||
MORK_USED_1(ioRow);
|
||||
mdb_err outErr = 0;
|
||||
morkCell* cell = 0;
|
||||
morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
|
||||
&outErr, &cell);
|
||||
if ( ev )
|
||||
{
|
||||
// remember row->MaybeDirtySpaceStoreAndRow();
|
||||
|
||||
morkCellObject* cellObj = (morkCellObject*) mHandle_Object;
|
||||
MORK_USED_1(cellObj);
|
||||
|
||||
ev->StubMethodOnlyError();
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
|
||||
return outErr;
|
||||
} // inRow must be bound inside this same db port
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinCell::GetChildRow( // access row of specific attribute
|
||||
nsIMdbEnv* mev, // context
|
||||
nsIMdbRow** acqRow) // acquire child row (or nil if no child)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbRow* outRow = 0;
|
||||
morkCell* cell = 0;
|
||||
morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
|
||||
&outErr, &cell);
|
||||
if ( ev )
|
||||
{
|
||||
morkCellObject* cellObj;
|
||||
cellObj = (morkCellObject*) mHandle_Object;
|
||||
ev->StubMethodOnlyError();
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( acqRow )
|
||||
*acqRow = outRow;
|
||||
|
||||
return outErr;
|
||||
}
|
||||
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinCell::SetChildTable( // access table of specific attribute
|
||||
nsIMdbEnv* mev, // context
|
||||
nsIMdbTable* inTable) // table must be bound inside this same db port
|
||||
{
|
||||
MORK_USED_1(inTable);
|
||||
mdb_err outErr = 0;
|
||||
morkCell* cell = 0;
|
||||
morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
|
||||
&outErr, &cell);
|
||||
if ( ev )
|
||||
{
|
||||
// remember row->MaybeDirtySpaceStoreAndRow();
|
||||
|
||||
morkCellObject* cellObj = (morkCellObject*) mHandle_Object;
|
||||
MORK_USED_1(cellObj);
|
||||
|
||||
ev->StubMethodOnlyError();
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinCell::GetChildTable( // access table of specific attribute
|
||||
nsIMdbEnv* mev, // context
|
||||
nsIMdbTable** acqTable) // acquire child tabdle (or nil if no chil)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbTable* outTable = 0;
|
||||
morkCell* cell = 0;
|
||||
morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
|
||||
&outErr, &cell);
|
||||
if ( ev )
|
||||
{
|
||||
morkCellObject* cellObj;
|
||||
cellObj = (morkCellObject*) mHandle_Object;
|
||||
ev->StubMethodOnlyError();
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( acqTable )
|
||||
*acqTable = outTable;
|
||||
|
||||
return outErr;
|
||||
}
|
||||
// } ----- end children methods -----
|
||||
|
||||
// } ===== end nsIMdbCell methods =====
|
||||
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
@ -1,269 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _ORKINCELL_
|
||||
#define _ORKINCELL_ 1
|
||||
|
||||
#ifndef _MDB_
|
||||
#include "mdb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORK_
|
||||
#include "mork.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKNODE_
|
||||
#include "morkNode.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKHANDLE_
|
||||
#include "morkHandle.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKCELL_
|
||||
#include "morkCell.h"
|
||||
#endif
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
#define morkMagic_kCell 0x43656C6C /* ascii 'Cell' */
|
||||
|
||||
class orkinCell : public morkHandle, public nsIMdbCell { // nsIMdbBlob
|
||||
|
||||
// { ===== begin morkNode interface =====
|
||||
public: // morkNode virtual methods
|
||||
// virtual void CloseMorkNode(morkEnv* ev); // morkHandle is fine
|
||||
virtual ~orkinCell(); // morkHandle destructor does everything
|
||||
|
||||
protected: // construction is protected (use the static Make() method)
|
||||
orkinCell(morkEnv* ev, // note morkUsage is always morkUsage_kPool
|
||||
morkHandleFace* ioFace, // must not be nil, cookie for this handle
|
||||
morkCellObject* ioObject); // must not be nil, the object for this handle
|
||||
|
||||
// void CloseHandle(morkEnv* ev); // don't need to specialize closing
|
||||
|
||||
private: // copying is not allowed
|
||||
orkinCell(const morkHandle& other);
|
||||
orkinCell& operator=(const morkHandle& other);
|
||||
|
||||
// public: // dynamic type identification
|
||||
// mork_bool IsHandle() const //
|
||||
// { return IsNode() && mNode_Derived == morkDerived_kHandle; }
|
||||
// } ===== end morkNode methods =====
|
||||
|
||||
protected: // morkHandle memory management operators
|
||||
void* operator new(size_t inSize, morkPool& ioPool, morkZone& ioZone, morkEnv* ev) CPP_THROW_NEW
|
||||
{ return ioPool.NewHandle(ev, inSize, &ioZone); }
|
||||
|
||||
void* operator new(size_t inSize, morkPool& ioPool, morkEnv* ev) CPP_THROW_NEW
|
||||
{ return ioPool.NewHandle(ev, inSize, (morkZone*) 0); }
|
||||
|
||||
void* operator new(size_t inSize, morkHandleFace* ioFace) CPP_THROW_NEW
|
||||
{ MORK_USED_1(inSize); return ioFace; }
|
||||
|
||||
|
||||
public: // construction:
|
||||
|
||||
static orkinCell* MakeCell(morkEnv* ev, morkCellObject* ioObject);
|
||||
|
||||
public: // utilities:
|
||||
|
||||
// ResyncWithRow() moved to the morkCellObject class:
|
||||
// mork_bool ResyncWithRow(morkEnv* ev); // return ev->Good()
|
||||
|
||||
morkEnv* CanUseCell(nsIMdbEnv* ev, mork_bool inMutable,
|
||||
mdb_err* outErr, morkCell** outCell) const;
|
||||
|
||||
public: // type identification
|
||||
mork_bool IsOrkinCell() const
|
||||
{ return mHandle_Magic == morkMagic_kCell; }
|
||||
|
||||
mork_bool IsOrkinCellHandle() const
|
||||
{ return this->IsHandle() && this->IsOrkinCell(); }
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// { ===== begin nsIMdbObject methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
NS_IMETHOD IsFrozenMdbObject(nsIMdbEnv* ev, mdb_bool* outIsReadonly);
|
||||
// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin factory methods -----
|
||||
NS_IMETHOD GetMdbFactory(nsIMdbEnv* ev, nsIMdbFactory** acqFactory);
|
||||
// } ----- end factory methods -----
|
||||
|
||||
// { ----- begin ref counting for well-behaved cyclic graphs -----
|
||||
NS_IMETHOD GetWeakRefCount(nsIMdbEnv* ev, // weak refs
|
||||
mdb_count* outCount);
|
||||
NS_IMETHOD GetStrongRefCount(nsIMdbEnv* ev, // strong refs
|
||||
mdb_count* outCount);
|
||||
|
||||
NS_IMETHOD AddWeakRef(nsIMdbEnv* ev);
|
||||
NS_IMETHOD AddStrongRef(nsIMdbEnv* ev);
|
||||
|
||||
NS_IMETHOD CutWeakRef(nsIMdbEnv* ev);
|
||||
NS_IMETHOD CutStrongRef(nsIMdbEnv* ev);
|
||||
|
||||
NS_IMETHOD CloseMdbObject(nsIMdbEnv* ev); // called at strong refs zero
|
||||
NS_IMETHOD IsOpenMdbObject(nsIMdbEnv* ev, mdb_bool* outOpen);
|
||||
// } ----- end ref counting -----
|
||||
|
||||
// } ===== end nsIMdbObject methods =====
|
||||
|
||||
// { ===== begin nsIMdbBlob methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
NS_IMETHOD SetBlob(nsIMdbEnv* ev,
|
||||
nsIMdbBlob* ioBlob); // reads inBlob slots
|
||||
// when inBlob is in the same suite, this might be fastest cell-to-cell
|
||||
|
||||
NS_IMETHOD ClearBlob( // make empty (so content has zero length)
|
||||
nsIMdbEnv* ev);
|
||||
// clearing a yarn is like SetYarn() with empty yarn instance content
|
||||
|
||||
NS_IMETHOD GetBlobFill(nsIMdbEnv* ev,
|
||||
mdb_fill* outFill); // size of blob
|
||||
// Same value that would be put into mYarn_Fill, if one called GetYarn()
|
||||
// with a yarn instance that had mYarn_Buf==nil and mYarn_Size==0.
|
||||
|
||||
NS_IMETHOD SetYarn(nsIMdbEnv* ev,
|
||||
const mdbYarn* inYarn); // reads from yarn slots
|
||||
// make this text object contain content from the yarn's buffer
|
||||
|
||||
NS_IMETHOD GetYarn(nsIMdbEnv* ev,
|
||||
mdbYarn* outYarn); // writes some yarn slots
|
||||
// copy content into the yarn buffer, and update mYarn_Fill and mYarn_Form
|
||||
|
||||
NS_IMETHOD AliasYarn(nsIMdbEnv* ev,
|
||||
mdbYarn* outYarn); // writes ALL yarn slots
|
||||
// AliasYarn() reveals sensitive internal text buffer state to the caller
|
||||
// by setting mYarn_Buf to point into the guts of this text implementation.
|
||||
//
|
||||
// The caller must take great care to avoid writing on this space, and to
|
||||
// avoid calling any method that would cause the state of this text object
|
||||
// to change (say by directly or indirectly setting the text to hold more
|
||||
// content that might grow the size of the buffer and free the old buffer).
|
||||
// In particular, callers should scrupulously avoid making calls into the
|
||||
// mdb interface to write any content while using the buffer pointer found
|
||||
// in the returned yarn instance. Best safe usage involves copying content
|
||||
// into some other kind of external content representation beyond mdb.
|
||||
//
|
||||
// (The original design of this method a week earlier included the concept
|
||||
// of very fast and efficient cooperative locking via a pointer to some lock
|
||||
// member slot. But let's ignore that complexity in the current design.)
|
||||
//
|
||||
// AliasYarn() is specifically intended as the first step in transferring
|
||||
// content from nsIMdbBlob to a nsString representation, without forcing extra
|
||||
// allocations and/or memory copies. (A standard nsIMdbBlob_AsString() utility
|
||||
// will use AliasYarn() as the first step in setting a nsString instance.)
|
||||
//
|
||||
// This is an alternative to the GetYarn() method, which has copy semantics
|
||||
// only; AliasYarn() relaxes a robust safety principle only for performance
|
||||
// reasons, to accomodate the need for callers to transform text content to
|
||||
// some other canonical representation that would necessitate an additional
|
||||
// copy and transformation when such is incompatible with the mdbYarn format.
|
||||
//
|
||||
// The implementation of AliasYarn() should have extremely little overhead
|
||||
// besides the virtual dispatch to the method implementation, and the code
|
||||
// necessary to populate all the mdbYarn member slots with internal buffer
|
||||
// address and metainformation that describes the buffer content. Note that
|
||||
// mYarn_Grow must always be set to nil to indicate no resizing is allowed.
|
||||
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// } ===== end nsIMdbBlob methods =====
|
||||
|
||||
// { ===== begin nsIMdbCell methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
NS_IMETHOD SetColumn(nsIMdbEnv* ev, mdb_column inColumn);
|
||||
NS_IMETHOD GetColumn(nsIMdbEnv* ev, mdb_column* outColumn);
|
||||
|
||||
NS_IMETHOD GetCellInfo( // all cell metainfo except actual content
|
||||
nsIMdbEnv* ev,
|
||||
mdb_column* outColumn, // the column in the containing row
|
||||
mdb_fill* outBlobFill, // the size of text content in bytes
|
||||
mdbOid* outChildOid, // oid of possible row or table child
|
||||
mdb_bool* outIsRowChild); // nonzero if child, and a row child
|
||||
|
||||
// Checking all cell metainfo is a good way to avoid forcing a large cell
|
||||
// in to memory when you don't actually want to use the content.
|
||||
|
||||
NS_IMETHOD GetRow(nsIMdbEnv* ev, // parent row for this cell
|
||||
nsIMdbRow** acqRow);
|
||||
NS_IMETHOD GetPort(nsIMdbEnv* ev, // port containing cell
|
||||
nsIMdbPort** acqPort);
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin children methods -----
|
||||
NS_IMETHOD HasAnyChild( // does cell have a child instead of text?
|
||||
nsIMdbEnv* ev,
|
||||
mdbOid* outOid, // out id of row or table (or unbound if no child)
|
||||
mdb_bool* outIsRow); // nonzero if child is a row (rather than a table)
|
||||
|
||||
NS_IMETHOD GetAnyChild( // access table of specific attribute
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbRow** acqRow, // child row (or null)
|
||||
nsIMdbTable** acqTable); // child table (or null)
|
||||
|
||||
|
||||
NS_IMETHOD SetChildRow( // access table of specific attribute
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbRow* ioRow); // inRow must be bound inside this same db port
|
||||
|
||||
NS_IMETHOD GetChildRow( // access row of specific attribute
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbRow** acqRow); // acquire child row (or nil if no child)
|
||||
|
||||
|
||||
NS_IMETHOD SetChildTable( // access table of specific attribute
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbTable* inTable); // table must be bound inside this same db port
|
||||
|
||||
NS_IMETHOD GetChildTable( // access table of specific attribute
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbTable** acqTable); // acquire child table (or nil if no child)
|
||||
// } ----- end children methods -----
|
||||
|
||||
// } ===== end nsIMdbCell methods =====
|
||||
};
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
#endif /* _ORKINCELL_ */
|
@ -1,147 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _MDB_
|
||||
#include "mdb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORK_
|
||||
#include "mork.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINCOMPARE_
|
||||
#include "orkinCompare.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKENV_
|
||||
#include "morkEnv.h"
|
||||
#endif
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
|
||||
orkinCompare::orkinCompare() // does nothing
|
||||
{
|
||||
}
|
||||
|
||||
/*virtual*/
|
||||
orkinCompare::~orkinCompare() // does nothing
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
mdb_order // standard yarn comparison for nsIMdbCompare::Order()
|
||||
mdbYarn_Order(const mdbYarn* inSelf, morkEnv* ev, const mdbYarn* inYarn)
|
||||
{
|
||||
// This code is a close copy of public domain Mithril's AgYarn_CompareLen().
|
||||
// Note all comments are from the original public domain Mithril code.
|
||||
|
||||
mork_u1* self = (mork_u1*) inSelf->mYarn_Buf;
|
||||
mork_u1* yarn = (mork_u1*) inYarn->mYarn_Buf;
|
||||
|
||||
mdb_fill selfFill = inSelf->mYarn_Fill;
|
||||
mdb_fill yarnFill = inYarn->mYarn_Fill;
|
||||
|
||||
if ( selfFill && yarnFill ) /* neither yarn is empty? */
|
||||
{
|
||||
register int a; /* a byte from self */
|
||||
register int b; /* a byte from yarn */
|
||||
|
||||
/* predecrement is normally used in loop tests to minimize instructions: */
|
||||
++selfFill; /* prepare for predecrement */
|
||||
++yarnFill; /* prepare for predecrement */
|
||||
/* we check only self len at loop top, but yarn len check must follow: */
|
||||
|
||||
while ( --selfFill ) /* another byte in self? */
|
||||
{
|
||||
if ( !--yarnFill ) /* yarn runs out first? self is greater (pos)? */
|
||||
return 1;
|
||||
|
||||
b = (mork_u1) *yarn++; /* next byte in other yarn */
|
||||
a = (mork_u1) *self++; /* next byte in self yarn */
|
||||
|
||||
if ( a != b ) /* found first different byte? */
|
||||
return ( a - b ); /* return relative order */
|
||||
}
|
||||
/* if remaining yarn len is exactly 1, it runs out at same time as self: */
|
||||
return ( yarnFill == 1 )? 0 : -1; /* yarn is same len? or self is less? */
|
||||
}
|
||||
else
|
||||
return ((mdb_order) selfFill) - ((mdb_order) yarnFill);
|
||||
}
|
||||
|
||||
// { ===== begin nsIMdbCompare methods =====
|
||||
/*virtual*/ mdb_err
|
||||
orkinCompare::Order(nsIMdbEnv* mev, // compare first to second yarn
|
||||
const mdbYarn* inFirst, // first yarn in comparison
|
||||
const mdbYarn* inSecond, // second yarn in comparison
|
||||
mdb_order* outOrder) // negative="<", zero="=", positive=">"
|
||||
{
|
||||
mdb_err outErr = 1; // nonzero means FAILURE
|
||||
|
||||
morkEnv* ev = morkEnv::FromMdbEnv(mev);
|
||||
if ( ev )
|
||||
{
|
||||
if ( inFirst && inSecond && outOrder )
|
||||
{
|
||||
*outOrder = mdbYarn_Order(inFirst, ev, inSecond);
|
||||
}
|
||||
else
|
||||
ev->NilPointerError();
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinCompare::AddStrongRef(nsIMdbEnv* ev) // does nothing
|
||||
{
|
||||
MORK_USED_1(ev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinCompare::CutStrongRef(nsIMdbEnv* ev) // does nothing
|
||||
{
|
||||
MORK_USED_1(ev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// } ===== end nsIMdbCompare methods =====
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
@ -1,82 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _ORKINCOMPARE_
|
||||
#define _ORKINCOMPARE_ 1
|
||||
|
||||
#ifndef _MDB_
|
||||
#include "mdb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORK_
|
||||
#include "mork.h"
|
||||
#endif
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
/*| orkinCompare:
|
||||
|*/
|
||||
class orkinCompare : public nsIMdbCompare { //
|
||||
|
||||
public:
|
||||
orkinCompare(); // does nothing
|
||||
virtual ~orkinCompare(); // does nothing
|
||||
|
||||
private: // copying is not allowed
|
||||
orkinCompare(const orkinCompare& other);
|
||||
orkinCompare& operator=(const orkinCompare& other);
|
||||
|
||||
public:
|
||||
|
||||
// { ===== begin nsIMdbCompare methods =====
|
||||
NS_IMETHOD Order(nsIMdbEnv* ev, // compare first to second yarn
|
||||
const mdbYarn* inFirst, // first yarn in comparison
|
||||
const mdbYarn* inSecond, // second yarn in comparison
|
||||
mdb_order* outOrder); // negative="<", zero="=", positive=">"
|
||||
|
||||
NS_IMETHOD AddStrongRef(nsIMdbEnv* ev); // does nothing
|
||||
NS_IMETHOD CutStrongRef(nsIMdbEnv* ev); // does nothing
|
||||
// } ===== end nsIMdbCompare methods =====
|
||||
|
||||
};
|
||||
|
||||
extern mdb_order // standard yarn comparison for nsIMdbCompare::ORder()
|
||||
mdbYarn_Order(const mdbYarn* inSelf, morkEnv* ev, const mdbYarn* inSecond);
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
#endif /* _ORKINCOMPARE_ */
|
@ -1,488 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _MDB_
|
||||
#include "mdb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORK_
|
||||
#include "mork.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKNODE_
|
||||
#include "morkNode.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKHANDLE_
|
||||
#include "morkHandle.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKENV_
|
||||
#include "morkEnv.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINENV_
|
||||
#include "orkinEnv.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINHEAP_
|
||||
#include "orkinHeap.h"
|
||||
#endif
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
/* public virtual*/
|
||||
orkinEnv:: ~orkinEnv() // morkHandle destructor does everything
|
||||
{
|
||||
}
|
||||
|
||||
void orkinEnv::CloseMorkNode(morkEnv* ev) // override to clean up mork env
|
||||
{
|
||||
morkEnv* mev = (morkEnv*) this->mHandle_Object;
|
||||
|
||||
if ( mev->IsOpenNode() )
|
||||
{
|
||||
mev->MarkClosing();
|
||||
mev->CloseEnv(ev);
|
||||
mev->MarkShut();
|
||||
}
|
||||
morkHandle::CloseMorkNode(ev);
|
||||
}
|
||||
|
||||
/*protected non-poly construction*/
|
||||
orkinEnv::orkinEnv(morkEnv* ev, // morkUsage is morkUsage_kPool
|
||||
morkHandleFace* ioFace, // must not be nil, cookie for this handle
|
||||
morkEnv* ioObject) // must not be nil, the object for this handle
|
||||
: morkHandle(ev, ioFace, ioObject, morkMagic_kEnv)
|
||||
{
|
||||
// do not modify mNode_Derived; leave it equal to morkDerived_kHandle
|
||||
}
|
||||
|
||||
|
||||
/*static */ orkinEnv*
|
||||
orkinEnv::MakeEnv(morkEnv* ev, morkEnv* ioObject)
|
||||
{
|
||||
mork_bool isEnv = ev->IsEnv();
|
||||
MORK_ASSERT(isEnv);
|
||||
if ( isEnv )
|
||||
{
|
||||
morkHandleFace* face = ev->NewHandle(sizeof(orkinEnv));
|
||||
if ( face )
|
||||
return new(face) orkinEnv(ev, face, ioObject);
|
||||
else
|
||||
ev->OutOfMemoryError();
|
||||
}
|
||||
|
||||
return (orkinEnv*) 0;
|
||||
}
|
||||
|
||||
morkEnv*
|
||||
orkinEnv::CanUseEnv(mork_bool inMutable, mdb_err* outErr) const
|
||||
{
|
||||
MORK_USED_1(inMutable);
|
||||
morkEnv* outEnv = 0;
|
||||
mdb_err err = morkEnv_kBadEnvError;
|
||||
if ( this->IsHandle() )
|
||||
{
|
||||
if ( this->IsOpenNode() )
|
||||
{
|
||||
morkEnv* ev = (morkEnv*) this->mHandle_Object;
|
||||
if ( ev && ev->IsEnv() )
|
||||
{
|
||||
outEnv = ev;
|
||||
err = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
err = morkEnv_kNonEnvTypeError;
|
||||
MORK_ASSERT(outEnv);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
err = morkEnv_kNonOpenNodeError;
|
||||
MORK_ASSERT(outEnv);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
err = morkEnv_kNonHandleTypeError;
|
||||
MORK_ASSERT(outEnv);
|
||||
}
|
||||
*outErr = err;
|
||||
return outEnv;
|
||||
}
|
||||
|
||||
|
||||
// { ===== begin nsIMdbISupports methods =====
|
||||
NS_IMPL_QUERY_INTERFACE0(orkinEnv)
|
||||
|
||||
/*virtual*/ nsrefcnt
|
||||
orkinEnv::AddRef() // add strong ref with no
|
||||
{
|
||||
morkEnv* ev = mHandle_Env;
|
||||
if ( ev && ev->IsEnv() )
|
||||
return this->Handle_AddStrongRef(ev->AsMdbEnv());
|
||||
else
|
||||
return morkEnv_kNonEnvTypeError;
|
||||
}
|
||||
|
||||
/*virtual*/ nsrefcnt
|
||||
orkinEnv::Release() // cut strong ref
|
||||
{
|
||||
morkEnv* ev = mHandle_Env;
|
||||
if ( ev && ev->IsEnv() )
|
||||
return this->Handle_CutStrongRef(ev->AsMdbEnv());
|
||||
else
|
||||
return morkEnv_kNonEnvTypeError;
|
||||
}
|
||||
// } ===== end nsIMdbObject methods =====
|
||||
|
||||
// { ===== begin nsIMdbObject methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinEnv::IsFrozenMdbObject(nsIMdbEnv* mev, mdb_bool* outIsReadonly)
|
||||
{
|
||||
return this->Handle_IsFrozenMdbObject(mev, outIsReadonly);
|
||||
}
|
||||
// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin factory methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinEnv::GetMdbFactory(nsIMdbEnv* mev, nsIMdbFactory** acqFactory)
|
||||
{
|
||||
return this->Handle_GetMdbFactory(mev, acqFactory);
|
||||
}
|
||||
// } ----- end factory methods -----
|
||||
|
||||
// { ----- begin ref counting for well-behaved cyclic graphs -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinEnv::GetWeakRefCount(nsIMdbEnv* mev, // weak refs
|
||||
mdb_count* outCount)
|
||||
{
|
||||
return this->Handle_GetWeakRefCount(mev, outCount);
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinEnv::GetStrongRefCount(nsIMdbEnv* mev, // strong refs
|
||||
mdb_count* outCount)
|
||||
{
|
||||
return this->Handle_GetStrongRefCount(mev, outCount);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinEnv::AddWeakRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_AddWeakRef(mev);
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinEnv::AddStrongRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_AddStrongRef(mev);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinEnv::CutWeakRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_CutWeakRef(mev);
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinEnv::CutStrongRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_CutStrongRef(mev);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinEnv::CloseMdbObject(nsIMdbEnv* mev)
|
||||
{
|
||||
morkEnv* ev = (morkEnv*) this->mHandle_Object;
|
||||
mdb_err ret = this->Handle_CloseMdbObject(mev);
|
||||
if (ev && ev->mEnv_Heap)
|
||||
{
|
||||
mork_bool ownsHeap = ev->mEnv_OwnsHeap;
|
||||
nsIMdbHeap*saveHeap = ev->mEnv_Heap;
|
||||
|
||||
ev->mEnv_Heap->Free(this, ev);
|
||||
if (ownsHeap)
|
||||
{
|
||||
#ifdef MORK_DEBUG_HEAP_STATS
|
||||
printf("%d blocks remaining \n", ((orkinHeap *) saveHeap)->HeapBlockCount());
|
||||
#endif // MORK_DEBUG_HEAP_STATS
|
||||
delete saveHeap;
|
||||
}
|
||||
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinEnv::IsOpenMdbObject(nsIMdbEnv* mev, mdb_bool* outOpen)
|
||||
{
|
||||
return this->Handle_IsOpenMdbObject(mev, outOpen);
|
||||
}
|
||||
// } ----- end ref counting -----
|
||||
|
||||
// } ===== end nsIMdbObject methods =====
|
||||
|
||||
// { ===== begin nsIMdbEnv methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinEnv::GetErrorCount(mdb_count* outCount,
|
||||
mdb_bool* outShouldAbort)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mdb_count count = 1;
|
||||
mork_bool shouldAbort = morkBool_kFalse;
|
||||
morkEnv* ev = this->CanUseEnv(/*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
count = (mdb_count) ev->mEnv_ErrorCount;
|
||||
shouldAbort = ev->mEnv_ShouldAbort;
|
||||
}
|
||||
if ( outCount )
|
||||
*outCount = count;
|
||||
if ( outShouldAbort )
|
||||
*outShouldAbort = shouldAbort;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinEnv::GetWarningCount(mdb_count* outCount,
|
||||
mdb_bool* outShouldAbort)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mdb_count count = 1;
|
||||
mork_bool shouldAbort = morkBool_kFalse;
|
||||
morkEnv* ev = this->CanUseEnv(/*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
count = (mdb_count) ev->mEnv_WarningCount;
|
||||
shouldAbort = ev->mEnv_ShouldAbort;
|
||||
}
|
||||
if ( outCount )
|
||||
*outCount = count;
|
||||
if ( outShouldAbort )
|
||||
*outShouldAbort = shouldAbort;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinEnv::GetEnvBeVerbose(mdb_bool* outBeVerbose)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mork_bool beVerbose = morkBool_kFalse;
|
||||
morkEnv* ev = this->CanUseEnv(/*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
beVerbose = ev->mEnv_BeVerbose;
|
||||
}
|
||||
if ( outBeVerbose )
|
||||
*outBeVerbose = beVerbose;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinEnv::SetEnvBeVerbose(mdb_bool inBeVerbose)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkEnv* ev = this->CanUseEnv(/*inMutable*/ morkBool_kTrue, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
ev->mEnv_BeVerbose = inBeVerbose;
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinEnv::GetDoTrace(mdb_bool* outDoTrace)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mork_bool doTrace = morkBool_kFalse;
|
||||
morkEnv* ev = this->CanUseEnv(/*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
doTrace = ev->mEnv_DoTrace;
|
||||
}
|
||||
if ( outDoTrace )
|
||||
*outDoTrace = doTrace;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinEnv::SetDoTrace(mdb_bool inDoTrace)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkEnv* ev = this->CanUseEnv(/*inMutable*/ morkBool_kTrue, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
ev->mEnv_DoTrace = inDoTrace;
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinEnv::GetAutoClear(mdb_bool* outAutoClear)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mork_bool autoClear = morkBool_kFalse;
|
||||
morkEnv* ev = this->CanUseEnv(/*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
autoClear = ev->DoAutoClear();
|
||||
}
|
||||
if ( outAutoClear )
|
||||
*outAutoClear = autoClear;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinEnv::SetAutoClear(mdb_bool inAutoClear)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkEnv* ev = this->CanUseEnv(/*inMutable*/ morkBool_kTrue, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
if ( inAutoClear )
|
||||
ev->EnableAutoClear();
|
||||
else
|
||||
ev->DisableAutoClear();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinEnv::GetErrorHook(nsIMdbErrorHook** acqErrorHook)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbErrorHook* outErrorHook = 0;
|
||||
morkEnv* ev = this->CanUseEnv(/*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
outErrorHook = ev->mEnv_ErrorHook;
|
||||
}
|
||||
if ( acqErrorHook )
|
||||
*acqErrorHook = outErrorHook;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinEnv::SetErrorHook(
|
||||
nsIMdbErrorHook* ioErrorHook) // becomes referenced
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkEnv* ev = this->CanUseEnv(/*inMutable*/ morkBool_kTrue, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
ev->mEnv_ErrorHook = ioErrorHook;
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinEnv::GetHeap(nsIMdbHeap** acqHeap)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbHeap* outHeap = 0;
|
||||
morkEnv* ev = this->CanUseEnv(/*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
nsIMdbHeap* heap = ev->mEnv_Heap;
|
||||
if ( heap && heap->HeapAddStrongRef(this) == 0 )
|
||||
outHeap = heap;
|
||||
}
|
||||
if ( acqHeap )
|
||||
*acqHeap = outHeap;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinEnv::SetHeap(
|
||||
nsIMdbHeap* ioHeap) // becomes referenced
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkEnv* ev = this->CanUseEnv(/*inMutable*/ morkBool_kTrue, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
nsIMdbHeap_SlotStrongHeap(ioHeap, ev, &ev->mEnv_Heap);
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinEnv::ClearErrors() // clear errors beore re-entering db API
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkEnv* ev = this->CanUseEnv(/*inMutable*/ morkBool_kTrue, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
ev->mEnv_ErrorCount = 0;
|
||||
ev->mEnv_ErrorCode = 0;
|
||||
ev->mEnv_ShouldAbort = morkBool_kFalse;
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinEnv::ClearWarnings() // clear warning
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkEnv* ev = this->CanUseEnv(/*inMutable*/ morkBool_kTrue, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
ev->mEnv_WarningCount = 0;
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinEnv::ClearErrorsAndWarnings() // clear both errors & warnings
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkEnv* ev = this->CanUseEnv(/*inMutable*/ morkBool_kTrue, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
ev->ClearMorkErrorsAndWarnings();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
// } ===== end nsIMdbEnv methods =====
|
||||
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
@ -1,182 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _ORKINENV_
|
||||
#define _ORKINENV_ 1
|
||||
|
||||
#ifndef _MDB_
|
||||
#include "mdb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORK_
|
||||
#include "mork.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKNODE_
|
||||
#include "morkNode.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKHANDLE_
|
||||
#include "morkHandle.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKEnv_
|
||||
#include "morkEnv.h"
|
||||
#endif
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
#define morkMagic_kEnv 0x456E7669 /* ascii 'Envi' */
|
||||
|
||||
/*| orkinEnv:
|
||||
|*/
|
||||
class orkinEnv : public morkHandle, public nsIMdbEnv { // nsIMdbObject
|
||||
|
||||
// { ===== begin morkNode interface =====
|
||||
public: // morkNode virtual methods
|
||||
virtual void CloseMorkNode(morkEnv* ev); // override to clean up mork env
|
||||
virtual ~orkinEnv(); // morkHandle destructor does everything
|
||||
|
||||
protected: // construction is protected (use the static Make() method)
|
||||
orkinEnv(morkEnv* ev, // note morkUsage is always morkUsage_kPool
|
||||
morkHandleFace* ioFace, // must not be nil, cookie for this handle
|
||||
morkEnv* ioObject); // must not be nil, the object for this handle
|
||||
|
||||
// void CloseHandle(morkEnv* ev); // don't need to specialize closing
|
||||
|
||||
private: // copying is not allowed
|
||||
orkinEnv(const morkHandle& other);
|
||||
orkinEnv& operator=(const morkHandle& other);
|
||||
|
||||
// public: // dynamic type identification
|
||||
// mork_bool IsHandle() const //
|
||||
// { return IsNode() && mNode_Derived == morkDerived_kHandle; }
|
||||
// } ===== end morkNode methods =====
|
||||
|
||||
protected: // morkHandle memory management operators
|
||||
void* operator new(size_t inSize, morkPool& ioPool, morkZone& ioZone, morkEnv* ev) CPP_THROW_NEW
|
||||
{ return ioPool.NewHandle(ev, inSize, &ioZone); }
|
||||
|
||||
void* operator new(size_t inSize, morkPool& ioPool, morkEnv* ev) CPP_THROW_NEW
|
||||
{ return ioPool.NewHandle(ev, inSize, (morkZone*) 0); }
|
||||
|
||||
void* operator new(size_t inSize, morkHandleFace* ioFace) CPP_THROW_NEW
|
||||
{ MORK_USED_1(inSize); return ioFace; }
|
||||
|
||||
|
||||
public: // construction:
|
||||
|
||||
static orkinEnv* MakeEnv(morkEnv* ev, morkEnv* ioObject);
|
||||
|
||||
public: // utilities:
|
||||
|
||||
morkEnv* CanUseEnv(mork_bool inMutable, mdb_err* outErr) const;
|
||||
|
||||
public: // type identification
|
||||
mork_bool IsOrkinEnv() const
|
||||
{ return mHandle_Magic == morkMagic_kEnv; }
|
||||
|
||||
mork_bool IsOrkinEnvHandle() const
|
||||
{ return this->IsHandle() && this->IsOrkinEnv(); }
|
||||
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
// { ===== begin nsIMdbObject methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
NS_IMETHOD IsFrozenMdbObject(nsIMdbEnv* ev, mdb_bool* outIsReadonly);
|
||||
// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin factory methods -----
|
||||
NS_IMETHOD GetMdbFactory(nsIMdbEnv* ev, nsIMdbFactory** acqFactory);
|
||||
// } ----- end factory methods -----
|
||||
|
||||
// { ----- begin ref counting for well-behaved cyclic graphs -----
|
||||
NS_IMETHOD GetWeakRefCount(nsIMdbEnv* ev, // weak refs
|
||||
mdb_count* outCount);
|
||||
NS_IMETHOD GetStrongRefCount(nsIMdbEnv* ev, // strong refs
|
||||
mdb_count* outCount);
|
||||
|
||||
NS_IMETHOD AddWeakRef(nsIMdbEnv* ev);
|
||||
NS_IMETHOD AddStrongRef(nsIMdbEnv* ev);
|
||||
|
||||
NS_IMETHOD CutWeakRef(nsIMdbEnv* ev);
|
||||
NS_IMETHOD CutStrongRef(nsIMdbEnv* ev);
|
||||
|
||||
NS_IMETHOD CloseMdbObject(nsIMdbEnv* ev); // called at strong refs zero
|
||||
NS_IMETHOD IsOpenMdbObject(nsIMdbEnv* ev, mdb_bool* outOpen);
|
||||
// } ----- end ref counting -----
|
||||
|
||||
// } ===== end nsIMdbObject methods =====
|
||||
|
||||
// { ===== begin nsIMdbEnv methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
NS_IMETHOD GetErrorCount(mdb_count* outCount,
|
||||
mdb_bool* outShouldAbort);
|
||||
NS_IMETHOD GetWarningCount(mdb_count* outCount,
|
||||
mdb_bool* outShouldAbort);
|
||||
|
||||
NS_IMETHOD GetEnvBeVerbose(mdb_bool* outBeVerbose);
|
||||
NS_IMETHOD SetEnvBeVerbose(mdb_bool inBeVerbose);
|
||||
|
||||
NS_IMETHOD GetDoTrace(mdb_bool* outDoTrace);
|
||||
NS_IMETHOD SetDoTrace(mdb_bool inDoTrace);
|
||||
|
||||
NS_IMETHOD GetAutoClear(mdb_bool* outAutoClear);
|
||||
NS_IMETHOD SetAutoClear(mdb_bool inAutoClear);
|
||||
|
||||
NS_IMETHOD GetErrorHook(nsIMdbErrorHook** acqErrorHook);
|
||||
NS_IMETHOD SetErrorHook(
|
||||
nsIMdbErrorHook* ioErrorHook); // becomes referenced
|
||||
|
||||
NS_IMETHOD GetHeap(nsIMdbHeap** acqHeap);
|
||||
NS_IMETHOD SetHeap(
|
||||
nsIMdbHeap* ioHeap); // becomes referenced
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
NS_IMETHOD ClearErrors(); // clear errors beore re-entering db API
|
||||
NS_IMETHOD ClearWarnings(); // clear warnings
|
||||
NS_IMETHOD ClearErrorsAndWarnings(); // clear both errors & warnings
|
||||
// } ===== end nsIMdbEnv methods =====
|
||||
};
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
#endif /* _ORKINENV_ */
|
@ -1,110 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _MDB_
|
||||
#include "mdb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORK_
|
||||
#include "mork.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINERRORHOOK_
|
||||
#include "orkinErrorHook.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKENV_
|
||||
#include "morkEnv.h"
|
||||
#endif
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
|
||||
orkinHeap::orkinHeap() // does nothing
|
||||
{
|
||||
}
|
||||
|
||||
/*virtual*/
|
||||
orkinHeap::~orkinHeap() // does nothing
|
||||
{
|
||||
}
|
||||
|
||||
// { ===== begin nsIMdbHeap methods =====
|
||||
/*virtual*/ mdb_err
|
||||
orkinHeap::Alloc(nsIMdbEnv* ev, // allocate a piece of memory
|
||||
mdb_size inSize, // requested size of new memory block
|
||||
void** outBlock) // memory block of inSize bytes, or nil
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
void* block = new char[ inSize ];
|
||||
if ( !block )
|
||||
outErr = morkEnv_kOutOfMemoryError;
|
||||
|
||||
MORK_ASSERT(outBlock);
|
||||
if ( outBlock )
|
||||
*outBlock = block;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinHeap::Free(nsIMdbEnv* ev, // free block allocated earlier by Alloc()
|
||||
void* inBlock)
|
||||
{
|
||||
MORK_ASSERT(inBlock);
|
||||
if ( inBlock )
|
||||
delete [] inBlock;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinHeap::AddStrongRef(nsIMdbEnv* ev) // does nothing
|
||||
{
|
||||
MORK_USED_1(ev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinHeap::CutStrongRef(nsIMdbEnv* ev) // does nothing
|
||||
{
|
||||
MORK_USED_1(ev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// } ===== end nsIMdbHeap methods =====
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
@ -1,81 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _ORKINERRORHOOK_
|
||||
#define _ORKINERRORHOOK_ 1
|
||||
|
||||
#ifndef _MDB_
|
||||
#include "mdb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORK_
|
||||
#include "mork.h"
|
||||
#endif
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
/*| orkinErrorHook:
|
||||
|*/
|
||||
class orkinErrorHook : public nsIMdbErrorHook { //
|
||||
|
||||
public:
|
||||
orkinErrorHook(); // does nothing
|
||||
virtual ~orkinErrorHook(); // does nothing
|
||||
|
||||
private: // copying is not allowed
|
||||
orkinErrorHook(const orkinErrorHook& other);
|
||||
orkinErrorHook& operator=(const orkinErrorHook& other);
|
||||
|
||||
public:
|
||||
|
||||
// { ===== begin nsIMdbHeap methods =====
|
||||
virtual mdb_err Alloc(nsIMdbEnv* ev, // allocate a piece of memory
|
||||
mdb_size inSize, // requested size of new memory block
|
||||
void** outBlock); // memory block of inSize bytes, or nil
|
||||
|
||||
virtual mdb_err Free(nsIMdbEnv* ev, // free block allocated earlier by Alloc()
|
||||
void* inBlock);
|
||||
|
||||
virtual mdb_err AddStrongRef(nsIMdbEnv* ev); // does nothing
|
||||
virtual mdb_err CutStrongRef(nsIMdbEnv* ev); // does nothing
|
||||
// } ===== end nsIMdbHeap methods =====
|
||||
|
||||
};
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
#endif /* _ORKINERRORHOOK_ */
|
@ -1,802 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _MDB_
|
||||
#include "mdb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORK_
|
||||
#include "mork.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKNODE_
|
||||
#include "morkNode.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKHANDLE_
|
||||
#include "morkHandle.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKENV_
|
||||
#include "morkEnv.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKFACTORY_
|
||||
#include "morkFactory.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINFACTORY_
|
||||
#include "orkinFactory.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINENV_
|
||||
#include "orkinEnv.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKROW_
|
||||
#include "morkRow.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINROW_
|
||||
#include "orkinRow.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKFILE_
|
||||
#include "morkFile.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKWRITER_
|
||||
#include "morkWriter.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKSTORE_
|
||||
#include "morkStore.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINSTORE_
|
||||
#include "orkinStore.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINTHUMB_
|
||||
#include "orkinThumb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKTHUMB_
|
||||
#include "morkThumb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINHEAP_
|
||||
#include "orkinHeap.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINCOMPARE_
|
||||
#include "orkinCompare.h"
|
||||
#endif
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
/* public virtual*/
|
||||
orkinFactory:: ~orkinFactory() // morkHandle destructor does everything
|
||||
{
|
||||
}
|
||||
|
||||
/*protected non-poly construction*/
|
||||
orkinFactory::orkinFactory(morkEnv* ev, // morkUsage is morkUsage_kPool
|
||||
morkHandleFace* ioFace, // must not be nil, cookie for this handle
|
||||
morkFactory* ioObject) // must not be nil, object for this handle
|
||||
: morkHandle(ev, ioFace, ioObject, morkMagic_kFactory)
|
||||
{
|
||||
// do not modify mNode_Derived; leave it equal to morkDerived_kHandle
|
||||
}
|
||||
|
||||
extern "C" nsIMdbFactory* MakeMdbFactory()
|
||||
{
|
||||
return orkinFactory::MakeGlobalFactory();
|
||||
}
|
||||
|
||||
/*static */ orkinFactory*
|
||||
orkinFactory::MakeGlobalFactory()
|
||||
// instantiate objects using almost no context information.
|
||||
{
|
||||
morkFactory* factory = new morkFactory(new orkinHeap());
|
||||
MORK_ASSERT(factory);
|
||||
if ( factory )
|
||||
return orkinFactory::MakeFactory(&factory->mFactory_Env, factory);
|
||||
else
|
||||
return (orkinFactory*) 0;
|
||||
}
|
||||
|
||||
/*static */ orkinFactory*
|
||||
orkinFactory::MakeFactory(morkEnv* ev, morkFactory* ioObject)
|
||||
{
|
||||
mork_bool isEnv = ev->IsEnv();
|
||||
MORK_ASSERT(isEnv);
|
||||
if ( isEnv )
|
||||
{
|
||||
morkHandleFace* face = ev->NewHandle(sizeof(orkinFactory));
|
||||
if ( face )
|
||||
{
|
||||
orkinFactory* f = new(face) orkinFactory(ev, face, ioObject);
|
||||
if ( f )
|
||||
f->mNode_Refs += morkFactory_kWeakRefCountBonus;
|
||||
return f;
|
||||
}
|
||||
else
|
||||
ev->OutOfMemoryError();
|
||||
}
|
||||
|
||||
return (orkinFactory*) 0;
|
||||
}
|
||||
|
||||
morkEnv*
|
||||
orkinFactory::CanUseFactory(nsIMdbEnv* mev, mork_bool inMutable,
|
||||
mdb_err* outErr) const
|
||||
{
|
||||
morkEnv* outEnv = 0;
|
||||
morkEnv* ev = morkEnv::FromMdbEnv(mev);
|
||||
if ( ev )
|
||||
{
|
||||
morkFactory* factory = (morkFactory*)
|
||||
this->GetGoodHandleObject(ev, inMutable, morkMagic_kFactory,
|
||||
/*inClosedOkay*/ morkBool_kFalse);
|
||||
if ( factory )
|
||||
{
|
||||
if ( factory->IsFactory() )
|
||||
outEnv = ev;
|
||||
else
|
||||
factory->NonFactoryTypeError(ev);
|
||||
}
|
||||
*outErr = ev->AsErr();
|
||||
}
|
||||
MORK_ASSERT(outEnv);
|
||||
return outEnv;
|
||||
}
|
||||
|
||||
morkEnv* orkinFactory::GetInternalFactoryEnv(mdb_err* outErr)
|
||||
{
|
||||
morkEnv* outEnv = 0;
|
||||
morkFactory* f = (morkFactory*) this->mHandle_Object;
|
||||
if ( f && f->IsNode() && f->IsOpenNode() && f->IsFactory() )
|
||||
{
|
||||
morkEnv* fenv = &f->mFactory_Env;
|
||||
if ( fenv && fenv->IsNode() && fenv->IsOpenNode() && fenv->IsEnv() )
|
||||
{
|
||||
fenv->ClearMorkErrorsAndWarnings(); // drop any earlier errors
|
||||
outEnv = fenv;
|
||||
}
|
||||
else
|
||||
*outErr = morkEnv_kBadFactoryEnvError;
|
||||
}
|
||||
else
|
||||
*outErr = morkEnv_kBadFactoryError;
|
||||
|
||||
return outEnv;
|
||||
}
|
||||
|
||||
// { ===== begin nsIMdbISupports methods =====
|
||||
NS_IMPL_QUERY_INTERFACE0(orkinFactory)
|
||||
|
||||
/*virtual*/ nsrefcnt
|
||||
orkinFactory::AddRef() // add strong ref with no
|
||||
{
|
||||
morkEnv* ev = mHandle_Env;
|
||||
if ( ev && ev->IsEnv() )
|
||||
return this->Handle_AddStrongRef(ev->AsMdbEnv());
|
||||
else
|
||||
return morkEnv_kNonEnvTypeError;
|
||||
}
|
||||
|
||||
/*virtual*/ nsrefcnt
|
||||
orkinFactory::Release() // cut strong ref
|
||||
{
|
||||
morkEnv* ev = mHandle_Env;
|
||||
if ( ev && ev->IsEnv() )
|
||||
return this->Handle_CutStrongRef(ev->AsMdbEnv());
|
||||
else
|
||||
return morkEnv_kNonEnvTypeError;
|
||||
}
|
||||
// } ===== end nsIMdbObject methods =====
|
||||
|
||||
|
||||
// { ===== begin nsIMdbObject methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinFactory::IsFrozenMdbObject(nsIMdbEnv* mev, mdb_bool* outIsReadonly)
|
||||
{
|
||||
return this->Handle_IsFrozenMdbObject(mev, outIsReadonly);
|
||||
}
|
||||
// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin factory methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinFactory::GetMdbFactory(nsIMdbEnv* mev, nsIMdbFactory** acqFactory)
|
||||
{
|
||||
return this->Handle_GetMdbFactory(mev, acqFactory);
|
||||
}
|
||||
// } ----- end factory methods -----
|
||||
|
||||
// { ----- begin ref counting for well-behaved cyclic graphs -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinFactory::GetWeakRefCount(nsIMdbEnv* mev, // weak refs
|
||||
mdb_count* outCount)
|
||||
{
|
||||
return this->Handle_GetWeakRefCount(mev, outCount);
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinFactory::GetStrongRefCount(nsIMdbEnv* mev, // strong refs
|
||||
mdb_count* outCount)
|
||||
{
|
||||
return this->Handle_GetStrongRefCount(mev, outCount);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinFactory::AddWeakRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_AddWeakRef(mev);
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinFactory::AddStrongRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_AddStrongRef(mev);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinFactory::CutWeakRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_CutWeakRef(mev);
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinFactory::CutStrongRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_CutStrongRef(mev);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinFactory::CloseMdbObject(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_CloseMdbObject(mev);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinFactory::IsOpenMdbObject(nsIMdbEnv* mev, mdb_bool* outOpen)
|
||||
{
|
||||
return this->Handle_IsOpenMdbObject(mev, outOpen);
|
||||
}
|
||||
// } ----- end ref counting -----
|
||||
|
||||
// } ===== end nsIMdbObject methods =====
|
||||
|
||||
// { ===== begin nsIMdbFactory methods =====
|
||||
|
||||
// { ----- begin file methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinFactory::OpenOldFile(nsIMdbEnv* mev, nsIMdbHeap* ioHeap,
|
||||
const char* inFilePath,
|
||||
mork_bool inFrozen, nsIMdbFile** acqFile)
|
||||
// Choose some subclass of nsIMdbFile to instantiate, in order to read
|
||||
// (and write if not frozen) the file known by inFilePath. The file
|
||||
// returned should be open and ready for use, and presumably positioned
|
||||
// at the first byte position of the file. The exact manner in which
|
||||
// files must be opened is considered a subclass specific detail, and
|
||||
// other portions or Mork source code don't want to know how it's done.
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbFile* outFile = 0;
|
||||
morkEnv* ev = this->CanUseFactory(mev,
|
||||
/*inMutable*/ morkBool_kFalse, &outErr);
|
||||
morkFile* file = nsnull;
|
||||
if ( ev )
|
||||
{
|
||||
morkFactory* factory = (morkFactory*) this->mHandle_Object;
|
||||
if ( !ioHeap )
|
||||
ioHeap = &factory->mFactory_Heap;
|
||||
|
||||
file = morkFile::OpenOldFile(ev, ioHeap, inFilePath, inFrozen);
|
||||
NS_IF_ADDREF( file );
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( acqFile )
|
||||
*acqFile = file;
|
||||
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinFactory::CreateNewFile(nsIMdbEnv* mev, nsIMdbHeap* ioHeap,
|
||||
const char* inFilePath, nsIMdbFile** acqFile)
|
||||
// Choose some subclass of nsIMdbFile to instantiate, in order to read
|
||||
// (and write if not frozen) the file known by inFilePath. The file
|
||||
// returned should be created and ready for use, and presumably positioned
|
||||
// at the first byte position of the file. The exact manner in which
|
||||
// files must be opened is considered a subclass specific detail, and
|
||||
// other portions or Mork source code don't want to know how it's done.
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbFile* outFile = 0;
|
||||
morkEnv* ev = this->CanUseFactory(mev,
|
||||
/*inMutable*/ morkBool_kFalse, &outErr);
|
||||
morkFile* file = nsnull;
|
||||
if ( ev )
|
||||
{
|
||||
morkFactory* factory = (morkFactory*) this->mHandle_Object;
|
||||
if ( !ioHeap )
|
||||
ioHeap = &factory->mFactory_Heap;
|
||||
|
||||
file = morkFile::CreateNewFile(ev, ioHeap, inFilePath);
|
||||
if ( file )
|
||||
NS_ADDREF(file);
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( acqFile )
|
||||
*acqFile = file;
|
||||
|
||||
return outErr;
|
||||
}
|
||||
// } ----- end file methods -----
|
||||
|
||||
// { ----- begin env methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinFactory::MakeEnv(nsIMdbHeap* ioHeap, nsIMdbEnv** acqEnv)
|
||||
// ioHeap can be nil, causing a MakeHeap() style heap instance to be used
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbEnv* outEnv = 0;
|
||||
mork_bool ownsHeap = (ioHeap == 0);
|
||||
if ( !ioHeap )
|
||||
ioHeap = new orkinHeap();
|
||||
|
||||
if ( acqEnv && ioHeap )
|
||||
{
|
||||
morkEnv* fenv = this->GetInternalFactoryEnv(&outErr);
|
||||
if ( fenv )
|
||||
{
|
||||
morkFactory* factory = (morkFactory*) this->mHandle_Object;
|
||||
morkEnv* newEnv = new(*ioHeap, fenv)
|
||||
morkEnv(morkUsage::kHeap, ioHeap, factory, ioHeap);
|
||||
|
||||
if ( newEnv )
|
||||
{
|
||||
newEnv->mEnv_OwnsHeap = ownsHeap;
|
||||
newEnv->mNode_Refs += morkEnv_kWeakRefCountEnvBonus;
|
||||
NS_ADDREF(newEnv);
|
||||
newEnv->mEnv_SelfAsMdbEnv = newEnv;
|
||||
outEnv = newEnv;
|
||||
}
|
||||
else
|
||||
outErr = morkEnv_kOutOfMemoryError;
|
||||
}
|
||||
|
||||
*acqEnv = outEnv;
|
||||
}
|
||||
else
|
||||
outErr = morkEnv_kNilPointerError;
|
||||
|
||||
return outErr;
|
||||
}
|
||||
// } ----- end env methods -----
|
||||
|
||||
// { ----- begin heap methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinFactory::MakeHeap(nsIMdbEnv* mev, nsIMdbHeap** acqHeap)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbHeap* outHeap = 0;
|
||||
morkEnv* ev = this->CanUseFactory(mev,
|
||||
/*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
outHeap = new orkinHeap();
|
||||
if ( !outHeap )
|
||||
ev->OutOfMemoryError();
|
||||
}
|
||||
MORK_ASSERT(acqHeap);
|
||||
if ( acqHeap )
|
||||
*acqHeap = outHeap;
|
||||
return outErr;
|
||||
}
|
||||
// } ----- end heap methods -----
|
||||
|
||||
// { ----- begin compare methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinFactory::MakeCompare(nsIMdbEnv* mev, nsIMdbCompare** acqCompare)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbCompare* outCompare = 0;
|
||||
morkEnv* ev = this->CanUseFactory(mev,
|
||||
/*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
NS_ASSERTION(PR_FALSE, "not implemented");
|
||||
outErr = NS_ERROR_NOT_IMPLEMENTED;
|
||||
// outCompare = new orkinCompare();
|
||||
if ( !outCompare )
|
||||
ev->OutOfMemoryError();
|
||||
}
|
||||
if ( acqCompare )
|
||||
*acqCompare = outCompare;
|
||||
return outErr;
|
||||
}
|
||||
// } ----- end compare methods -----
|
||||
|
||||
// { ----- begin row methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinFactory::MakeRow(nsIMdbEnv* mev, nsIMdbHeap* ioHeap,
|
||||
nsIMdbRow** acqRow)
|
||||
{
|
||||
MORK_USED_1(ioHeap);
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbRow* outRow = 0;
|
||||
morkEnv* ev = this->CanUseFactory(mev,
|
||||
/*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
ev->StubMethodOnlyError();
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( acqRow )
|
||||
*acqRow = outRow;
|
||||
|
||||
return outErr;
|
||||
}
|
||||
// ioHeap can be nil, causing the heap associated with ev to be used
|
||||
// } ----- end row methods -----
|
||||
|
||||
// { ----- begin port methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinFactory::CanOpenFilePort(
|
||||
nsIMdbEnv* mev, // context
|
||||
// const char* inFilePath, // the file to investigate
|
||||
// const mdbYarn* inFirst512Bytes,
|
||||
nsIMdbFile* ioFile, // db abstract file interface
|
||||
mdb_bool* outCanOpen, // whether OpenFilePort() might succeed
|
||||
mdbYarn* outFormatVersion)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
if ( outFormatVersion )
|
||||
{
|
||||
outFormatVersion->mYarn_Fill = 0;
|
||||
}
|
||||
mdb_bool canOpenAsPort = morkBool_kFalse;
|
||||
morkEnv* ev = this->CanUseFactory(mev,
|
||||
/*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
if ( ioFile && outCanOpen )
|
||||
{
|
||||
canOpenAsPort = this->CanOpenMorkTextFile(ev, ioFile);
|
||||
}
|
||||
else
|
||||
ev->NilPointerError();
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
|
||||
if ( outCanOpen )
|
||||
*outCanOpen = canOpenAsPort;
|
||||
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinFactory::OpenFilePort(
|
||||
nsIMdbEnv* mev, // context
|
||||
nsIMdbHeap* ioHeap, // can be nil to cause ev's heap attribute to be used
|
||||
// const char* inFilePath, // the file to open for readonly import
|
||||
nsIMdbFile* ioFile, // db abstract file interface
|
||||
const mdbOpenPolicy* inOpenPolicy, // runtime policies for using db
|
||||
nsIMdbThumb** acqThumb)
|
||||
{
|
||||
MORK_USED_1(ioHeap);
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbThumb* outThumb = 0;
|
||||
morkEnv* ev = this->CanUseFactory(mev,
|
||||
/*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
if ( ioFile && inOpenPolicy && acqThumb )
|
||||
{
|
||||
}
|
||||
else
|
||||
ev->NilPointerError();
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( acqThumb )
|
||||
*acqThumb = outThumb;
|
||||
return outErr;
|
||||
}
|
||||
// Call nsIMdbThumb::DoMore() until done, or until the thumb is broken, and
|
||||
// then call nsIMdbFactory::ThumbToOpenPort() to get the port instance.
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinFactory::ThumbToOpenPort( // redeeming a completed thumb from OpenFilePort()
|
||||
nsIMdbEnv* mev, // context
|
||||
nsIMdbThumb* ioThumb, // thumb from OpenFilePort() with done status
|
||||
nsIMdbPort** acqPort)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbPort* outPort = 0;
|
||||
morkEnv* ev = this->CanUseFactory(mev,
|
||||
/*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
if ( ioThumb && acqPort )
|
||||
{
|
||||
morkThumb* thumb = (morkThumb*) ioThumb;
|
||||
morkStore* store = thumb->ThumbToOpenStore(ev);
|
||||
if ( store )
|
||||
{
|
||||
store->mStore_CanAutoAssignAtomIdentity = morkBool_kTrue;
|
||||
store->mStore_CanDirty = morkBool_kTrue;
|
||||
store->SetStoreAndAllSpacesCanDirty(ev, morkBool_kTrue);
|
||||
|
||||
NS_ADDREF(store);
|
||||
outPort = store;
|
||||
}
|
||||
}
|
||||
else
|
||||
ev->NilPointerError();
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( acqPort )
|
||||
*acqPort = outPort;
|
||||
return outErr;
|
||||
}
|
||||
// } ----- end port methods -----
|
||||
|
||||
mork_bool
|
||||
orkinFactory::CanOpenMorkTextFile(morkEnv* ev,
|
||||
// const mdbYarn* inFirst512Bytes,
|
||||
nsIMdbFile* ioFile)
|
||||
{
|
||||
MORK_USED_1(ev);
|
||||
mork_bool outBool = morkBool_kFalse;
|
||||
mork_size headSize = MORK_STRLEN(morkWriter_kFileHeader);
|
||||
|
||||
char localBuf[ 256 + 4 ]; // for extra for sloppy safety
|
||||
mdbYarn localYarn;
|
||||
mdbYarn* y = &localYarn;
|
||||
y->mYarn_Buf = localBuf; // space to hold content
|
||||
y->mYarn_Fill = 0; // no logical content yet
|
||||
y->mYarn_Size = 256; // physical capacity is 256 bytes
|
||||
y->mYarn_More = 0;
|
||||
y->mYarn_Form = 0;
|
||||
y->mYarn_Grow = 0;
|
||||
|
||||
if ( ioFile )
|
||||
{
|
||||
nsIMdbEnv* menv = ev->AsMdbEnv();
|
||||
mdb_size actualSize = 0;
|
||||
ioFile->Get(menv, y->mYarn_Buf, y->mYarn_Size, /*pos*/ 0, &actualSize);
|
||||
y->mYarn_Fill = actualSize;
|
||||
|
||||
if ( y->mYarn_Buf && actualSize >= headSize && ev->Good() )
|
||||
{
|
||||
mork_u1* buf = (mork_u1*) y->mYarn_Buf;
|
||||
outBool = ( MORK_MEMCMP(morkWriter_kFileHeader, buf, headSize) == 0 );
|
||||
}
|
||||
}
|
||||
else
|
||||
ev->NilPointerError();
|
||||
|
||||
return outBool;
|
||||
}
|
||||
|
||||
// { ----- begin store methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinFactory::CanOpenFileStore(
|
||||
nsIMdbEnv* mev, // context
|
||||
// const char* inFilePath, // the file to investigate
|
||||
// const mdbYarn* inFirst512Bytes,
|
||||
nsIMdbFile* ioFile, // db abstract file interface
|
||||
mdb_bool* outCanOpenAsStore, // whether OpenFileStore() might succeed
|
||||
mdb_bool* outCanOpenAsPort, // whether OpenFilePort() might succeed
|
||||
mdbYarn* outFormatVersion)
|
||||
{
|
||||
mdb_bool canOpenAsStore = morkBool_kFalse;
|
||||
mdb_bool canOpenAsPort = morkBool_kFalse;
|
||||
if ( outFormatVersion )
|
||||
{
|
||||
outFormatVersion->mYarn_Fill = 0;
|
||||
}
|
||||
mdb_err outErr = 0;
|
||||
morkEnv* ev = this->CanUseFactory(mev,
|
||||
/*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
if ( ioFile && outCanOpenAsStore )
|
||||
{
|
||||
// right now always say true; later we should look for magic patterns
|
||||
canOpenAsStore = this->CanOpenMorkTextFile(ev, ioFile);
|
||||
canOpenAsPort = canOpenAsStore;
|
||||
}
|
||||
else
|
||||
ev->NilPointerError();
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( outCanOpenAsStore )
|
||||
*outCanOpenAsStore = canOpenAsStore;
|
||||
|
||||
if ( outCanOpenAsPort )
|
||||
*outCanOpenAsPort = canOpenAsPort;
|
||||
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinFactory::OpenFileStore( // open an existing database
|
||||
nsIMdbEnv* mev, // context
|
||||
nsIMdbHeap* ioHeap, // can be nil to cause ev's heap attribute to be used
|
||||
// const char* inFilePath, // the file to open for general db usage
|
||||
nsIMdbFile* ioFile, // db abstract file interface
|
||||
const mdbOpenPolicy* inOpenPolicy, // runtime policies for using db
|
||||
nsIMdbThumb** acqThumb)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbThumb* outThumb = 0;
|
||||
morkEnv* ev = this->CanUseFactory(mev,
|
||||
/*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
if ( !ioHeap ) // need to use heap from env?
|
||||
ioHeap = ev->mEnv_Heap;
|
||||
|
||||
if ( ioFile && inOpenPolicy && acqThumb )
|
||||
{
|
||||
morkFactory* factory = (morkFactory*) this->mHandle_Object;
|
||||
morkStore* store = new(*ioHeap, ev)
|
||||
morkStore(ev, morkUsage::kHeap, ioHeap, factory, ioHeap);
|
||||
|
||||
if ( store )
|
||||
{
|
||||
mork_bool frozen = morkBool_kFalse; // open store mutable access
|
||||
if ( store->OpenStoreFile(ev, frozen, ioFile, inOpenPolicy) )
|
||||
{
|
||||
morkThumb* thumb = morkThumb::Make_OpenFileStore(ev, ioHeap, store);
|
||||
if ( thumb )
|
||||
{
|
||||
outThumb = thumb;
|
||||
thumb->AddRef();
|
||||
}
|
||||
}
|
||||
// store->CutStrongRef(mev); // always cut ref (handle has its own ref)
|
||||
}
|
||||
}
|
||||
else
|
||||
ev->NilPointerError();
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( acqThumb )
|
||||
*acqThumb = outThumb;
|
||||
return outErr;
|
||||
}
|
||||
// Call nsIMdbThumb::DoMore() until done, or until the thumb is broken, and
|
||||
// then call nsIMdbFactory::ThumbToOpenStore() to get the store instance.
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinFactory::ThumbToOpenStore( // redeem completed thumb from OpenFileStore()
|
||||
nsIMdbEnv* mev, // context
|
||||
nsIMdbThumb* ioThumb, // thumb from OpenFileStore() with done status
|
||||
nsIMdbStore** acqStore)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbStore* outStore = 0;
|
||||
morkEnv* ev = this->CanUseFactory(mev,
|
||||
/*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
if ( ioThumb && acqStore )
|
||||
{
|
||||
morkThumb* thumb = (morkThumb*) ioThumb;
|
||||
morkStore* store = thumb->ThumbToOpenStore(ev);
|
||||
if ( store )
|
||||
{
|
||||
store->mStore_CanAutoAssignAtomIdentity = morkBool_kTrue;
|
||||
store->mStore_CanDirty = morkBool_kTrue;
|
||||
store->SetStoreAndAllSpacesCanDirty(ev, morkBool_kTrue);
|
||||
|
||||
outStore = store;
|
||||
NS_ADDREF(store);
|
||||
}
|
||||
}
|
||||
else
|
||||
ev->NilPointerError();
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( acqStore )
|
||||
*acqStore = outStore;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinFactory::CreateNewFileStore( // create a new db with minimal content
|
||||
nsIMdbEnv* mev, // context
|
||||
nsIMdbHeap* ioHeap, // can be nil to cause ev's heap attribute to be used
|
||||
// const char* inFilePath, // name of file which should not yet exist
|
||||
nsIMdbFile* ioFile, // db abstract file interface
|
||||
const mdbOpenPolicy* inOpenPolicy, // runtime policies for using db
|
||||
nsIMdbStore** acqStore)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbStore* outStore = 0;
|
||||
morkEnv* ev = this->CanUseFactory(mev,
|
||||
/*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
if ( !ioHeap ) // need to use heap from env?
|
||||
ioHeap = ev->mEnv_Heap;
|
||||
|
||||
if ( ioFile && inOpenPolicy && acqStore && ioHeap )
|
||||
{
|
||||
morkFactory* factory = (morkFactory*) this->mHandle_Object;
|
||||
morkStore* store = new(*ioHeap, ev)
|
||||
morkStore(ev, morkUsage::kHeap, ioHeap, factory, ioHeap);
|
||||
|
||||
if ( store )
|
||||
{
|
||||
store->mStore_CanAutoAssignAtomIdentity = morkBool_kTrue;
|
||||
store->mStore_CanDirty = morkBool_kTrue;
|
||||
store->SetStoreAndAllSpacesCanDirty(ev, morkBool_kTrue);
|
||||
|
||||
if ( store->CreateStoreFile(ev, ioFile, inOpenPolicy) )
|
||||
outStore = store;
|
||||
NS_ADDREF(store);
|
||||
}
|
||||
}
|
||||
else
|
||||
ev->NilPointerError();
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( acqStore )
|
||||
*acqStore = outStore;
|
||||
return outErr;
|
||||
}
|
||||
// } ----- end store methods -----
|
||||
|
||||
// } ===== end nsIMdbFactory methods =====
|
||||
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
@ -1,266 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _ORKINFACTORY_
|
||||
#define _ORKINFACTORY_ 1
|
||||
|
||||
#ifndef _MDB_
|
||||
#include "mdb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORK_
|
||||
#include "mork.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKNODE_
|
||||
#include "morkNode.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKHANDLE_
|
||||
#include "morkHandle.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKFACTORY_
|
||||
#include "morkFactory.h"
|
||||
#endif
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
#define morkMagic_kFactory 0x46616374 /* ascii 'Fact' */
|
||||
|
||||
/*| orkinFactory:
|
||||
|*/
|
||||
class orkinFactory : public morkHandle, public nsIMdbFactory { // nsIMdbObject
|
||||
|
||||
// { ===== begin morkNode interface =====
|
||||
public: // morkNode virtual methods
|
||||
// virtual void CloseMorkNode(morkEnv* ev); // morkHandle is fine
|
||||
virtual ~orkinFactory(); // morkHandle destructor does everything
|
||||
|
||||
protected: // construction is protected (use the static Make() method)
|
||||
orkinFactory(morkEnv* ev, // note morkUsage is always morkUsage_kPool
|
||||
morkHandleFace* ioFace, // must not be nil, cookie for this handle
|
||||
morkFactory* ioObject); // must not be nil, the object for this handle
|
||||
|
||||
// void CloseHandle(morkEnv* ev); // don't need to specialize closing
|
||||
|
||||
private: // copying is not allowed
|
||||
orkinFactory(const morkHandle& other);
|
||||
orkinFactory& operator=(const morkHandle& other);
|
||||
|
||||
// public: // dynamic type identification
|
||||
// mork_bool IsHandle() const //
|
||||
// { return IsNode() && mNode_Derived == morkDerived_kHandle; }
|
||||
// } ===== end morkNode methods =====
|
||||
|
||||
protected: // morkHandle memory management operators
|
||||
void* operator new(size_t inSize, morkPool& ioPool, morkZone& ioZone, morkEnv* ev) CPP_THROW_NEW
|
||||
{ return ioPool.NewHandle(ev, inSize, &ioZone); }
|
||||
|
||||
void* operator new(size_t inSize, morkPool& ioPool, morkEnv* ev) CPP_THROW_NEW
|
||||
{ return ioPool.NewHandle(ev, inSize, (morkZone*) 0); }
|
||||
|
||||
void* operator new(size_t inSize, morkHandleFace* ioFace) CPP_THROW_NEW
|
||||
{ MORK_USED_1(inSize); return ioFace; }
|
||||
|
||||
|
||||
public: // construction:
|
||||
|
||||
static orkinFactory* MakeGlobalFactory();
|
||||
// instantiate objects using almost no context information.
|
||||
|
||||
static orkinFactory* MakeFactory(morkEnv* ev, morkFactory* ioObject);
|
||||
|
||||
public: // utilities:
|
||||
|
||||
morkEnv* CanUseFactory(nsIMdbEnv* mev, mork_bool inMutable,
|
||||
mdb_err* outErr) const;
|
||||
|
||||
morkEnv* GetInternalFactoryEnv(mdb_err* outErr);
|
||||
|
||||
mork_bool CanOpenMorkTextFile(morkEnv* ev,
|
||||
// const mdbYarn* inFirst512Bytes,
|
||||
nsIMdbFile* ioFile);
|
||||
|
||||
public: // type identification
|
||||
mork_bool IsOrkinFactory() const
|
||||
{ return mHandle_Magic == morkMagic_kFactory; }
|
||||
|
||||
mork_bool IsOrkinFactoryHandle() const
|
||||
{ return this->IsHandle() && this->IsOrkinFactory(); }
|
||||
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// { ===== begin nsIMdbObject methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
NS_IMETHOD IsFrozenMdbObject(nsIMdbEnv* ev, mdb_bool* outIsReadonly);
|
||||
// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin factory methods -----
|
||||
NS_IMETHOD GetMdbFactory(nsIMdbEnv* ev, nsIMdbFactory** acqFactory);
|
||||
// } ----- end factory methods -----
|
||||
|
||||
// { ----- begin ref counting for well-behaved cyclic graphs -----
|
||||
NS_IMETHOD GetWeakRefCount(nsIMdbEnv* ev, // weak refs
|
||||
mdb_count* outCount);
|
||||
NS_IMETHOD GetStrongRefCount(nsIMdbEnv* ev, // strong refs
|
||||
mdb_count* outCount);
|
||||
|
||||
NS_IMETHOD AddWeakRef(nsIMdbEnv* ev);
|
||||
NS_IMETHOD AddStrongRef(nsIMdbEnv* ev);
|
||||
|
||||
NS_IMETHOD CutWeakRef(nsIMdbEnv* ev);
|
||||
NS_IMETHOD CutStrongRef(nsIMdbEnv* ev);
|
||||
|
||||
NS_IMETHOD CloseMdbObject(nsIMdbEnv* ev); // called at strong refs zero
|
||||
NS_IMETHOD IsOpenMdbObject(nsIMdbEnv* ev, mdb_bool* outOpen);
|
||||
// } ----- end ref counting -----
|
||||
|
||||
// } ===== end nsIMdbObject methods =====
|
||||
|
||||
// { ===== begin nsIMdbFactory methods =====
|
||||
|
||||
// { ----- begin file methods -----
|
||||
NS_IMETHOD OpenOldFile(nsIMdbEnv* ev, nsIMdbHeap* ioHeap,
|
||||
const char* inFilePath,
|
||||
mdb_bool inFrozen, nsIMdbFile** acqFile);
|
||||
// Choose some subclass of nsIMdbFile to instantiate, in order to read
|
||||
// (and write if not frozen) the file known by inFilePath. The file
|
||||
// returned should be open and ready for use, and presumably positioned
|
||||
// at the first byte position of the file. The exact manner in which
|
||||
// files must be opened is considered a subclass specific detail, and
|
||||
// other portions or Mork source code don't want to know how it's done.
|
||||
|
||||
NS_IMETHOD CreateNewFile(nsIMdbEnv* ev, nsIMdbHeap* ioHeap,
|
||||
const char* inFilePath,
|
||||
nsIMdbFile** acqFile);
|
||||
// Choose some subclass of nsIMdbFile to instantiate, in order to read
|
||||
// (and write if not frozen) the file known by inFilePath. The file
|
||||
// returned should be created and ready for use, and presumably positioned
|
||||
// at the first byte position of the file. The exact manner in which
|
||||
// files must be opened is considered a subclass specific detail, and
|
||||
// other portions or Mork source code don't want to know how it's done.
|
||||
// } ----- end file methods -----
|
||||
|
||||
// { ----- begin env methods -----
|
||||
NS_IMETHOD MakeEnv(nsIMdbHeap* ioHeap, nsIMdbEnv** acqEnv); // new env
|
||||
// ioHeap can be nil, causing a MakeHeap() style heap instance to be used
|
||||
// } ----- end env methods -----
|
||||
|
||||
// { ----- begin heap methods -----
|
||||
NS_IMETHOD MakeHeap(nsIMdbEnv* ev, nsIMdbHeap** acqHeap); // new heap
|
||||
// } ----- end heap methods -----
|
||||
|
||||
// { ----- begin compare methods -----
|
||||
NS_IMETHOD MakeCompare(nsIMdbEnv* ev, nsIMdbCompare** acqCompare); // ASCII
|
||||
// } ----- end compare methods -----
|
||||
|
||||
// { ----- begin row methods -----
|
||||
NS_IMETHOD MakeRow(nsIMdbEnv* ev, nsIMdbHeap* ioHeap, nsIMdbRow** acqRow); // new row
|
||||
// ioHeap can be nil, causing the heap associated with ev to be used
|
||||
// } ----- end row methods -----
|
||||
|
||||
// { ----- begin port methods -----
|
||||
NS_IMETHOD CanOpenFilePort(
|
||||
nsIMdbEnv* ev, // context
|
||||
// const char* inFilePath, // the file to investigate
|
||||
// const mdbYarn* inFirst512Bytes,
|
||||
nsIMdbFile* ioFile, // db abstract file interface
|
||||
mdb_bool* outCanOpen, // whether OpenFilePort() might succeed
|
||||
mdbYarn* outFormatVersion); // informal file format description
|
||||
|
||||
NS_IMETHOD OpenFilePort(
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbHeap* ioHeap, // can be nil to cause ev's heap attribute to be used
|
||||
// const char* inFilePath, // the file to open for readonly import
|
||||
nsIMdbFile* ioFile, // db abstract file interface
|
||||
const mdbOpenPolicy* inOpenPolicy, // runtime policies for using db
|
||||
nsIMdbThumb** acqThumb); // acquire thumb for incremental port open
|
||||
// Call nsIMdbThumb::DoMore() until done, or until the thumb is broken, and
|
||||
// then call nsIMdbFactory::ThumbToOpenPort() to get the port instance.
|
||||
|
||||
NS_IMETHOD ThumbToOpenPort( // redeeming a completed thumb from OpenFilePort()
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbThumb* ioThumb, // thumb from OpenFilePort() with done status
|
||||
nsIMdbPort** acqPort); // acquire new port object
|
||||
// } ----- end port methods -----
|
||||
|
||||
// { ----- begin store methods -----
|
||||
NS_IMETHOD CanOpenFileStore(
|
||||
nsIMdbEnv* ev, // context
|
||||
// const char* inFilePath, // the file to investigate
|
||||
// const mdbYarn* inFirst512Bytes,
|
||||
nsIMdbFile* ioFile, // db abstract file interface
|
||||
mdb_bool* outCanOpenAsStore, // whether OpenFileStore() might succeed
|
||||
mdb_bool* outCanOpenAsPort, // whether OpenFilePort() might succeed
|
||||
mdbYarn* outFormatVersion); // informal file format description
|
||||
|
||||
NS_IMETHOD OpenFileStore( // open an existing database
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbHeap* ioHeap, // can be nil to cause ev's heap attribute to be used
|
||||
// const char* inFilePath, // the file to open for general db usage
|
||||
nsIMdbFile* ioFile, // db abstract file interface
|
||||
const mdbOpenPolicy* inOpenPolicy, // runtime policies for using db
|
||||
nsIMdbThumb** acqThumb); // acquire thumb for incremental store open
|
||||
// Call nsIMdbThumb::DoMore() until done, or until the thumb is broken, and
|
||||
// then call nsIMdbFactory::ThumbToOpenStore() to get the store instance.
|
||||
|
||||
NS_IMETHOD
|
||||
ThumbToOpenStore( // redeem completed thumb from OpenFileStore()
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbThumb* ioThumb, // thumb from OpenFileStore() with done status
|
||||
nsIMdbStore** acqStore); // acquire new db store object
|
||||
|
||||
NS_IMETHOD CreateNewFileStore( // create a new db with minimal content
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbHeap* ioHeap, // can be nil to cause ev's heap attribute to be used
|
||||
// const char* inFilePath, // name of file which should not yet exist
|
||||
nsIMdbFile* ioFile, // db abstract file interface
|
||||
const mdbOpenPolicy* inOpenPolicy, // runtime policies for using db
|
||||
nsIMdbStore** acqStore); // acquire new db store object
|
||||
// } ----- end store methods -----
|
||||
|
||||
// } ===== end nsIMdbFactory methods =====
|
||||
};
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
#endif /* _ORKINFACTORY_ */
|
@ -1,500 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _MDB_
|
||||
#include "mdb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORK_
|
||||
#include "mork.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKNODE_
|
||||
#include "morkNode.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKHANDLE_
|
||||
#include "morkHandle.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKFILE_
|
||||
#include "morkFile.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKENV_
|
||||
#include "morkEnv.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINFILE_
|
||||
#include "orkinFile.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKFILE_
|
||||
#include "morkFile.h"
|
||||
#endif
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
/* public virtual*/
|
||||
orkinFile:: ~orkinFile() // morkHandle destructor does everything
|
||||
{
|
||||
}
|
||||
|
||||
/*protected non-poly construction*/
|
||||
orkinFile::orkinFile(morkEnv* ev, // morkUsage is morkUsage_kPool
|
||||
morkHandleFace* ioFace, // must not be nil, cookie for this handle
|
||||
morkFile* ioObject) // must not be nil, the object for this handle
|
||||
: morkHandle(ev, ioFace, ioObject, morkMagic_kFile)
|
||||
{
|
||||
// do not modify mNode_Derived; leave it equal to morkDerived_kHandle
|
||||
}
|
||||
|
||||
|
||||
/*static */ orkinFile*
|
||||
orkinFile::MakeFile(morkEnv* ev, morkFile* ioObject)
|
||||
{
|
||||
mork_bool isEnv = ev->IsEnv();
|
||||
MORK_ASSERT(isEnv);
|
||||
if ( isEnv )
|
||||
{
|
||||
morkHandleFace* face = ev->NewHandle(sizeof(orkinFile));
|
||||
if ( face )
|
||||
return new(face) orkinFile(ev, face, ioObject);
|
||||
else
|
||||
ev->OutOfMemoryError();
|
||||
}
|
||||
|
||||
return (orkinFile*) 0;
|
||||
}
|
||||
|
||||
morkEnv*
|
||||
orkinFile::CanUseFile(nsIMdbEnv* mev,
|
||||
mork_bool inMutable, mdb_err* outErr) const
|
||||
{
|
||||
morkEnv* outEnv = 0;
|
||||
morkEnv* ev = morkEnv::FromMdbEnv(mev);
|
||||
if ( ev )
|
||||
{
|
||||
morkFile* self = (morkFile*)
|
||||
this->GetGoodHandleObject(ev, inMutable, morkMagic_kFile,
|
||||
/*inClosedOkay*/ morkBool_kFalse);
|
||||
if ( self )
|
||||
{
|
||||
if ( self->IsFile() )
|
||||
outEnv = ev;
|
||||
else
|
||||
self->NonFileTypeError(ev);
|
||||
}
|
||||
*outErr = ev->AsErr();
|
||||
}
|
||||
MORK_ASSERT(outEnv);
|
||||
return outEnv;
|
||||
}
|
||||
|
||||
|
||||
// { ===== begin nsIMdbISupports methods =====
|
||||
NS_IMPL_QUERY_INTERFACE1(orkinFile, nsIMdbFile)
|
||||
|
||||
/*virtual*/ nsrefcnt
|
||||
orkinFile::AddRef() // add strong ref with no
|
||||
{
|
||||
morkEnv* ev = mHandle_Env;
|
||||
if ( ev && ev->IsEnv() )
|
||||
return this->Handle_AddStrongRef(ev->AsMdbEnv());
|
||||
else
|
||||
return morkEnv_kNonEnvTypeError;
|
||||
}
|
||||
|
||||
/*virtual*/ nsrefcnt
|
||||
orkinFile::Release() // cut strong ref
|
||||
{
|
||||
morkEnv* ev = mHandle_Env;
|
||||
if ( ev && ev->IsEnv() )
|
||||
return this->Handle_CutStrongRef(ev->AsMdbEnv());
|
||||
else
|
||||
return morkEnv_kNonEnvTypeError;
|
||||
}
|
||||
// } ===== end nsIMdbISupports methods =====
|
||||
|
||||
// { ===== begin nsIMdbObject methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinFile::IsFrozenMdbObject(nsIMdbEnv* mev, mdb_bool* outIsReadonly)
|
||||
{
|
||||
return this->Handle_IsFrozenMdbObject(mev, outIsReadonly);
|
||||
}
|
||||
// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin factory methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinFile::GetMdbFactory(nsIMdbEnv* mev, nsIMdbFactory** acqFactory)
|
||||
{
|
||||
return this->Handle_GetMdbFactory(mev, acqFactory);
|
||||
}
|
||||
// } ----- end factory methods -----
|
||||
|
||||
// { ----- begin ref counting for well-behaved cyclic graphs -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinFile::GetWeakRefCount(nsIMdbEnv* mev, // weak refs
|
||||
mdb_count* outCount)
|
||||
{
|
||||
return this->Handle_GetWeakRefCount(mev, outCount);
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinFile::GetStrongRefCount(nsIMdbEnv* mev, // strong refs
|
||||
mdb_count* outCount)
|
||||
{
|
||||
return this->Handle_GetStrongRefCount(mev, outCount);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinFile::AddWeakRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_AddWeakRef(mev);
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinFile::AddStrongRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_AddStrongRef(mev);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinFile::CutWeakRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_CutWeakRef(mev);
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinFile::CutStrongRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_CutStrongRef(mev);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinFile::CloseMdbObject(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_CloseMdbObject(mev);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinFile::IsOpenMdbObject(nsIMdbEnv* mev, mdb_bool* outOpen)
|
||||
{
|
||||
return this->Handle_IsOpenMdbObject(mev, outOpen);
|
||||
}
|
||||
// } ----- end ref counting -----
|
||||
|
||||
// } ===== end nsIMdbObject methods =====
|
||||
|
||||
// { ===== begin nsIMdbFile methods =====
|
||||
|
||||
// { ----- begin pos methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinFile::Tell(nsIMdbEnv* mev, mdb_pos* outPos)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mdb_pos pos = -1;
|
||||
morkEnv* ev = this->CanUseFile(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkFile* file = (morkFile*) mHandle_Object;
|
||||
pos = file->Tell(ev);
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( outPos )
|
||||
*outPos = pos;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinFile::Seek(nsIMdbEnv* mev, mdb_pos inPos)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkEnv* ev = this->CanUseFile(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkFile* file = (morkFile*) mHandle_Object;
|
||||
file->Seek(ev, inPos);
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinFile::Eof(nsIMdbEnv* mev, mdb_pos* outPos)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mdb_pos pos = -1;
|
||||
morkEnv* ev = this->CanUseFile(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkFile* file = (morkFile*) mHandle_Object;
|
||||
pos = file->Length(ev);
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( outPos )
|
||||
*outPos = pos;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
// } ----- end pos methods -----
|
||||
|
||||
// { ----- begin read methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinFile::Read(nsIMdbEnv* mev, void* outBuf, mdb_size inSize,
|
||||
mdb_size* outActualSize)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mdb_size actualSize = 0;
|
||||
morkEnv* ev = this->CanUseFile(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkFile* file = (morkFile*) mHandle_Object;
|
||||
actualSize = file->Read(ev, outBuf, inSize);
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( outActualSize )
|
||||
*outActualSize = actualSize;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinFile::Get(nsIMdbEnv* mev, void* outBuf, mdb_size inSize,
|
||||
mdb_pos inPos, mdb_size* outActualSize)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mdb_size actualSize = 0;
|
||||
morkEnv* ev = this->CanUseFile(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkFile* file = (morkFile*) mHandle_Object;
|
||||
file->Seek(ev, inPos);
|
||||
if ( ev->Good() )
|
||||
actualSize = file->Read(ev, outBuf, inSize);
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( outActualSize )
|
||||
*outActualSize = actualSize;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
// } ----- end read methods -----
|
||||
|
||||
// { ----- begin write methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinFile::Write(nsIMdbEnv* mev, const void* inBuf, mdb_size inSize,
|
||||
mdb_size* outActualSize)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mdb_size actualSize = 0;
|
||||
morkEnv* ev = this->CanUseFile(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkFile* file = (morkFile*) mHandle_Object;
|
||||
actualSize = file->Write(ev, inBuf, inSize);
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( outActualSize )
|
||||
*outActualSize = actualSize;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinFile::Put(nsIMdbEnv* mev, const void* inBuf, mdb_size inSize,
|
||||
mdb_pos inPos, mdb_size* outActualSize)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mdb_size actualSize = 0;
|
||||
morkEnv* ev = this->CanUseFile(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkFile* file = (morkFile*) mHandle_Object;
|
||||
file->Seek(ev, inPos);
|
||||
if ( ev->Good() )
|
||||
actualSize = file->Write(ev, inBuf, inSize);
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( outActualSize )
|
||||
*outActualSize = actualSize;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinFile::Flush(nsIMdbEnv* mev)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkEnv* ev = this->CanUseFile(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkFile* file = (morkFile*) mHandle_Object;
|
||||
file->Flush(ev);
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin path methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinFile::Path(nsIMdbEnv* mev, mdbYarn* outFilePath)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
if ( outFilePath )
|
||||
outFilePath->mYarn_Fill = 0;
|
||||
morkEnv* ev = this->CanUseFile(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkFile* file = (morkFile*) mHandle_Object;
|
||||
ev->StringToYarn(file->GetFileNameString(), outFilePath);
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
// } ----- end path methods -----
|
||||
|
||||
// { ----- begin replacement methods -----
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinFile::Steal(nsIMdbEnv* mev, nsIMdbFile* ioThief)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkEnv* ev = this->CanUseFile(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
if ( ioThief )
|
||||
{
|
||||
// orkinFile* thief = (orkinFile*) ioThief; // unsafe cast -- must type check:
|
||||
// thief->CanUseFile(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
|
||||
morkFile* file = (morkFile*) mHandle_Object;
|
||||
file->Steal(ev, ioThief);
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
else
|
||||
ev->NilPointerError();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinFile::Thief(nsIMdbEnv* mev, nsIMdbFile** acqThief)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbFile* outThief = 0;
|
||||
morkEnv* ev = this->CanUseFile(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkFile* file = (morkFile*) mHandle_Object;
|
||||
outThief = file->GetThief();
|
||||
if ( outThief )
|
||||
outThief->AddStrongRef(ev->AsMdbEnv());
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( acqThief )
|
||||
*acqThief = outThief;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
// } ----- end replacement methods -----
|
||||
|
||||
// { ----- begin versioning methods -----
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinFile::BecomeTrunk(nsIMdbEnv* mev)
|
||||
// If this file is a file version branch created by calling AcquireBud(),
|
||||
// BecomeTrunk() causes this file's content to replace the original
|
||||
// file's content, typically by assuming the original file's identity.
|
||||
// This default implementation of BecomeTrunk() does nothing, and this
|
||||
// is appropriate behavior for files which are not branches, and is
|
||||
// also the right behavior for files returned from AcquireBud() which are
|
||||
// in fact the original file that has been truncated down to zero length.
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkEnv* ev = this->CanUseFile(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkFile* file = (morkFile*) mHandle_Object;
|
||||
file->BecomeTrunk(ev);
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinFile::AcquireBud(nsIMdbEnv* mev, nsIMdbHeap* ioHeap,
|
||||
nsIMdbFile** acqBud) // acquired file for new version of content
|
||||
// AcquireBud() starts a new "branch" version of the file, empty of content,
|
||||
// so that a new version of the file can be written. This new file
|
||||
// can later be told to BecomeTrunk() the original file, so the branch
|
||||
// created by budding the file will replace the original file. Some
|
||||
// file subclasses might initially take the unsafe but expedient
|
||||
// approach of simply truncating this file down to zero length, and
|
||||
// then returning the same morkFile pointer as this, with an extra
|
||||
// reference count increment. Note that the caller of AcquireBud() is
|
||||
// expected to eventually call CutStrongRef() on the returned file
|
||||
// in order to release the strong reference. High quality versions
|
||||
// of morkFile subclasses will create entirely new files which later
|
||||
// are renamed to become the old file, so that better transactional
|
||||
// behavior is exhibited by the file, so crashes protect old files.
|
||||
// Note that AcquireBud() is an illegal operation on readonly files.
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbFile* outBud = 0;
|
||||
morkEnv* ev = this->CanUseFile(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkFile* file = (morkFile*) mHandle_Object;
|
||||
morkFile* bud = file->AcquireBud(ev, ioHeap);
|
||||
if ( bud )
|
||||
{
|
||||
outBud = bud->AcquireFileHandle(ev);
|
||||
bud->CutStrongRef(mev);
|
||||
}
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( acqBud )
|
||||
*acqBud = outBud;
|
||||
return outErr;
|
||||
}
|
||||
// } ----- end versioning methods -----
|
||||
|
||||
// } ===== end nsIMdbFile methods =====
|
||||
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
@ -1,212 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _ORKINTABLE_
|
||||
#define _ORKINTABLE_ 1
|
||||
|
||||
#ifndef _MDB_
|
||||
#include "mdb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORK_
|
||||
#include "mork.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKNODE_
|
||||
#include "morkNode.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKHANDLE_
|
||||
#include "morkHandle.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKFILE_
|
||||
#include "morkFile.h"
|
||||
#endif
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
#define morkMagic_kFile 0x46696C65 /* ascii 'File' */
|
||||
|
||||
/*| orkinFile:
|
||||
|*/
|
||||
class orkinFile : public morkHandle, public nsIMdbFile { // nsIMdbFile
|
||||
|
||||
// { ===== begin morkNode interface =====
|
||||
public: // morkNode virtual methods
|
||||
// virtual void CloseMorkNode(morkEnv* ev); // morkHandle is fine
|
||||
virtual ~orkinFile(); // morkHandle destructor does everything
|
||||
|
||||
protected: // construction is protected (use the static Make() method)
|
||||
orkinFile(morkEnv* ev, // note morkUsage is always morkUsage_kPool
|
||||
morkHandleFace* ioFace, // must not be nil, cookie for this handle
|
||||
morkFile* ioObject); // must not be nil, the object for this handle
|
||||
|
||||
// void CloseHandle(morkEnv* ev); // don't need to specialize closing
|
||||
|
||||
private: // copying is not allowed
|
||||
orkinFile(const morkHandle& other);
|
||||
orkinFile& operator=(const morkHandle& other);
|
||||
|
||||
// public: // dynamic type identification
|
||||
// mork_bool IsHandle() const //
|
||||
// { return IsNode() && mNode_Derived == morkDerived_kHandle; }
|
||||
// } ===== end morkNode methods =====
|
||||
|
||||
protected: // morkHandle memory management operators
|
||||
void* operator new(size_t inSize, morkPool& ioPool, morkZone& ioZone, morkEnv* ev) CPP_THROW_NEW
|
||||
{ return ioPool.NewHandle(ev, inSize, &ioZone); }
|
||||
|
||||
void* operator new(size_t inSize, morkPool& ioPool, morkEnv* ev) CPP_THROW_NEW
|
||||
{ return ioPool.NewHandle(ev, inSize, (morkZone*) 0); }
|
||||
|
||||
void* operator new(size_t inSize, morkHandleFace* ioFace) CPP_THROW_NEW
|
||||
{ MORK_USED_1(inSize); return ioFace; }
|
||||
|
||||
|
||||
public: // construction:
|
||||
|
||||
static orkinFile* MakeFile(morkEnv* ev, morkFile* ioObject);
|
||||
|
||||
public: // utilities:
|
||||
|
||||
morkEnv* CanUseFile(nsIMdbEnv* mev, mork_bool inMutable,
|
||||
mdb_err* outErr) const;
|
||||
|
||||
public: // type identification
|
||||
mork_bool IsOrkinFile() const
|
||||
{ return mHandle_Magic == morkMagic_kFile; }
|
||||
|
||||
mork_bool IsOrkinFileHandle() const
|
||||
{ return this->IsHandle() && this->IsOrkinFile(); }
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
// { ===== begin nsIMdbObject methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
NS_IMETHOD IsFrozenMdbObject(nsIMdbEnv* ev, mdb_bool* outIsReadonly);
|
||||
// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin factory methods -----
|
||||
NS_IMETHOD GetMdbFactory(nsIMdbEnv* ev, nsIMdbFactory** acqFactory);
|
||||
// } ----- end factory methods -----
|
||||
|
||||
// { ----- begin ref counting for well-behaved cyclic graphs -----
|
||||
NS_IMETHOD GetWeakRefCount(nsIMdbEnv* ev, // weak refs
|
||||
mdb_count* outCount);
|
||||
NS_IMETHOD GetStrongRefCount(nsIMdbEnv* ev, // strong refs
|
||||
mdb_count* outCount);
|
||||
|
||||
NS_IMETHOD AddWeakRef(nsIMdbEnv* ev);
|
||||
NS_IMETHOD AddStrongRef(nsIMdbEnv* ev);
|
||||
|
||||
NS_IMETHOD CutWeakRef(nsIMdbEnv* ev);
|
||||
NS_IMETHOD CutStrongRef(nsIMdbEnv* ev);
|
||||
|
||||
NS_IMETHOD CloseMdbObject(nsIMdbEnv* ev); // called at strong refs zero
|
||||
NS_IMETHOD IsOpenMdbObject(nsIMdbEnv* ev, mdb_bool* outOpen);
|
||||
// } ----- end ref counting -----
|
||||
|
||||
// } ===== end nsIMdbObject methods =====
|
||||
|
||||
// { ===== begin nsIMdbFile methods =====
|
||||
|
||||
// { ----- begin pos methods -----
|
||||
NS_IMETHOD Tell(nsIMdbEnv* ev, mdb_pos* outPos);
|
||||
NS_IMETHOD Seek(nsIMdbEnv* ev, mdb_pos inPos);
|
||||
NS_IMETHOD Eof(nsIMdbEnv* ev, mdb_pos* outPos);
|
||||
// } ----- end pos methods -----
|
||||
|
||||
// { ----- begin read methods -----
|
||||
NS_IMETHOD Read(nsIMdbEnv* ev, void* outBuf, mdb_size inSize,
|
||||
mdb_size* outActualSize);
|
||||
NS_IMETHOD Get(nsIMdbEnv* ev, void* outBuf, mdb_size inSize,
|
||||
mdb_pos inPos, mdb_size* outActualSize);
|
||||
// } ----- end read methods -----
|
||||
|
||||
// { ----- begin write methods -----
|
||||
NS_IMETHOD Write(nsIMdbEnv* ev, const void* inBuf, mdb_size inSize,
|
||||
mdb_size* outActualSize);
|
||||
NS_IMETHOD Put(nsIMdbEnv* ev, const void* inBuf, mdb_size inSize,
|
||||
mdb_pos inPos, mdb_size* outActualSize);
|
||||
NS_IMETHOD Flush(nsIMdbEnv* ev);
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin path methods -----
|
||||
NS_IMETHOD Path(nsIMdbEnv* ev, mdbYarn* outFilePath);
|
||||
// } ----- end path methods -----
|
||||
|
||||
// { ----- begin replacement methods -----
|
||||
NS_IMETHOD Steal(nsIMdbEnv* ev, nsIMdbFile* ioThief);
|
||||
NS_IMETHOD Thief(nsIMdbEnv* ev, nsIMdbFile** acqThief);
|
||||
// } ----- end replacement methods -----
|
||||
|
||||
// { ----- begin versioning methods -----
|
||||
NS_IMETHOD BecomeTrunk(nsIMdbEnv* ev);
|
||||
// If this file is a file version branch created by calling AcquireBud(),
|
||||
// BecomeTrunk() causes this file's content to replace the original
|
||||
// file's content, typically by assuming the original file's identity.
|
||||
// This default implementation of BecomeTrunk() does nothing, and this
|
||||
// is appropriate behavior for files which are not branches, and is
|
||||
// also the right behavior for files returned from AcquireBud() which are
|
||||
// in fact the original file that has been truncated down to zero length.
|
||||
|
||||
NS_IMETHOD AcquireBud(nsIMdbEnv* ev, nsIMdbHeap* ioHeap,
|
||||
nsIMdbFile** acqBud); // acquired file for new version of content
|
||||
// AcquireBud() starts a new "branch" version of the file, empty of content,
|
||||
// so that a new version of the file can be written. This new file
|
||||
// can later be told to BecomeTrunk() the original file, so the branch
|
||||
// created by budding the file will replace the original file. Some
|
||||
// file subclasses might initially take the unsafe but expedient
|
||||
// approach of simply truncating this file down to zero length, and
|
||||
// then returning the same morkFile pointer as this, with an extra
|
||||
// reference count increment. Note that the caller of AcquireBud() is
|
||||
// expected to eventually call CutStrongRef() on the returned file
|
||||
// in order to release the strong reference. High quality versions
|
||||
// of morkFile subclasses will create entirely new files which later
|
||||
// are renamed to become the old file, so that better transactional
|
||||
// behavior is exhibited by the file, so crashes protect old files.
|
||||
// Note that AcquireBud() is an illegal operation on readonly files.
|
||||
// } ----- end versioning methods -----
|
||||
|
||||
// } ===== end nsIMdbFile methods =====
|
||||
};
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
#endif /* _ORKINTABLE_ */
|
@ -1,473 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _MDB_
|
||||
#include "mdb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORK_
|
||||
#include "mork.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKNODE_
|
||||
#include "morkNode.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKHANDLE_
|
||||
#include "morkHandle.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKENV_
|
||||
#include "morkEnv.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKSTORE_
|
||||
#include "morkStore.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINSTORE_
|
||||
#include "orkinStore.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKPORTTABLECURSOR_
|
||||
#include "morkPortTableCursor.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINPORTTABLECURSOR_
|
||||
#include "orkinPortTableCursor.h"
|
||||
#endif
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
/* public virtual*/
|
||||
orkinPortTableCursor:: ~orkinPortTableCursor() // morkHandle destructor does everything
|
||||
{
|
||||
}
|
||||
|
||||
/*protected non-poly construction*/
|
||||
orkinPortTableCursor::orkinPortTableCursor(morkEnv* ev, // morkUsage is morkUsage_kPool
|
||||
morkHandleFace* ioFace, // must not be nil, cookie for this handle
|
||||
morkPortTableCursor* ioObject) // must not be nil, object for this handle
|
||||
: morkHandle(ev, ioFace, ioObject,
|
||||
morkMagic_kPortTableCursor)
|
||||
{
|
||||
// do not modify mNode_Derived; leave it equal to morkDerived_kHandle
|
||||
}
|
||||
|
||||
|
||||
/*static */ orkinPortTableCursor*
|
||||
orkinPortTableCursor::MakePortTableCursor(morkEnv* ev,
|
||||
morkPortTableCursor* ioObject)
|
||||
{
|
||||
mork_bool isEnv = ev->IsEnv();
|
||||
MORK_ASSERT(isEnv);
|
||||
if ( isEnv )
|
||||
{
|
||||
morkHandleFace* face = ev->NewHandle(sizeof(orkinPortTableCursor));
|
||||
if ( face )
|
||||
return new(face) orkinPortTableCursor(ev, face, ioObject);
|
||||
else
|
||||
ev->OutOfMemoryError();
|
||||
}
|
||||
|
||||
return (orkinPortTableCursor*) 0;
|
||||
}
|
||||
|
||||
morkEnv*
|
||||
orkinPortTableCursor::CanUsePortTableCursor(nsIMdbEnv* mev,
|
||||
mork_bool inMutable, mdb_err* outErr) const
|
||||
{
|
||||
morkEnv* outEnv = 0;
|
||||
morkEnv* ev = morkEnv::FromMdbEnv(mev);
|
||||
if ( ev )
|
||||
{
|
||||
morkPortTableCursor* self = (morkPortTableCursor*)
|
||||
this->GetGoodHandleObject(ev, inMutable, morkMagic_kPortTableCursor,
|
||||
/*inClosedOkay*/ morkBool_kFalse);
|
||||
if ( self )
|
||||
{
|
||||
if ( self->IsPortTableCursor() )
|
||||
outEnv = ev;
|
||||
else
|
||||
self->NonPortTableCursorTypeError(ev);
|
||||
}
|
||||
*outErr = ev->AsErr();
|
||||
}
|
||||
MORK_ASSERT(outEnv);
|
||||
return outEnv;
|
||||
}
|
||||
|
||||
// { ===== begin nsIMdbISupports methods =====
|
||||
NS_IMPL_QUERY_INTERFACE0(orkinPortTableCursor)
|
||||
|
||||
/*virtual*/ nsrefcnt
|
||||
orkinPortTableCursor::AddRef() // add strong ref with no
|
||||
{
|
||||
morkEnv* ev = mHandle_Env;
|
||||
if ( ev && ev->IsEnv() )
|
||||
return this->Handle_AddStrongRef(ev->AsMdbEnv());
|
||||
else
|
||||
return morkEnv_kNonEnvTypeError;
|
||||
}
|
||||
|
||||
/*virtual*/ nsrefcnt
|
||||
orkinPortTableCursor::Release() // cut strong ref
|
||||
{
|
||||
morkEnv* ev = mHandle_Env;
|
||||
if ( ev && ev->IsEnv() )
|
||||
return this->Handle_CutStrongRef(ev->AsMdbEnv());
|
||||
else
|
||||
return morkEnv_kNonEnvTypeError;
|
||||
}
|
||||
// } ===== end nsIMdbObject methods =====
|
||||
|
||||
|
||||
// { ===== begin nsIMdbObject methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinPortTableCursor::IsFrozenMdbObject(nsIMdbEnv* mev, mdb_bool* outIsReadonly)
|
||||
{
|
||||
return this->Handle_IsFrozenMdbObject(mev, outIsReadonly);
|
||||
}
|
||||
// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin factory methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinPortTableCursor::GetMdbFactory(nsIMdbEnv* mev, nsIMdbFactory** acqFactory)
|
||||
{
|
||||
return this->Handle_GetMdbFactory(mev, acqFactory);
|
||||
}
|
||||
// } ----- end factory methods -----
|
||||
|
||||
// { ----- begin ref counting for well-behaved cyclic graphs -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinPortTableCursor::GetWeakRefCount(nsIMdbEnv* mev, // weak refs
|
||||
mdb_count* outCount)
|
||||
{
|
||||
return this->Handle_GetWeakRefCount(mev, outCount);
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinPortTableCursor::GetStrongRefCount(nsIMdbEnv* mev, // strong refs
|
||||
mdb_count* outCount)
|
||||
{
|
||||
return this->Handle_GetStrongRefCount(mev, outCount);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinPortTableCursor::AddWeakRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_AddWeakRef(mev);
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinPortTableCursor::AddStrongRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_AddStrongRef(mev);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinPortTableCursor::CutWeakRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_CutWeakRef(mev);
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinPortTableCursor::CutStrongRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_CutStrongRef(mev);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinPortTableCursor::CloseMdbObject(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_CloseMdbObject(mev);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinPortTableCursor::IsOpenMdbObject(nsIMdbEnv* mev, mdb_bool* outOpen)
|
||||
{
|
||||
return this->Handle_IsOpenMdbObject(mev, outOpen);
|
||||
}
|
||||
// } ----- end ref counting -----
|
||||
|
||||
// } ===== end nsIMdbObject methods =====
|
||||
|
||||
// { ===== begin nsIMdbCursor methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinPortTableCursor::GetCount(nsIMdbEnv* mev, mdb_count* outCount)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mdb_count count = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUsePortTableCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
ev->StubMethodOnlyError();
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( outCount )
|
||||
*outCount = count;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinPortTableCursor::GetSeed(nsIMdbEnv* mev, mdb_seed* outSeed)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mdb_seed seed = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUsePortTableCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
ev->StubMethodOnlyError();
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( outSeed )
|
||||
*outSeed = seed;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinPortTableCursor::SetPos(nsIMdbEnv* mev, mdb_pos inPos)
|
||||
{
|
||||
MORK_USED_1(inPos);
|
||||
mdb_err outErr = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUsePortTableCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
ev->StubMethodOnlyError();
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinPortTableCursor::GetPos(nsIMdbEnv* mev, mdb_pos* outPos)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mdb_pos pos = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUsePortTableCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
ev->StubMethodOnlyError();
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( outPos )
|
||||
*outPos = pos;
|
||||
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinPortTableCursor::SetDoFailOnSeedOutOfSync(nsIMdbEnv* mev, mdb_bool inFail)
|
||||
{
|
||||
MORK_USED_1(inFail);
|
||||
mdb_err outErr = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUsePortTableCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
ev->StubMethodOnlyError();
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinPortTableCursor::GetDoFailOnSeedOutOfSync(nsIMdbEnv* mev, mdb_bool* outFail)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mdb_bool fail = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUsePortTableCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
ev->StubMethodOnlyError();
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( outFail )
|
||||
*outFail = fail;
|
||||
return outErr;
|
||||
}
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// } ===== end nsIMdbCursor methods =====
|
||||
|
||||
// { ===== begin nsIMdbPortTableCursor methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinPortTableCursor::SetPort(nsIMdbEnv* mev, nsIMdbPort* ioPort)
|
||||
{
|
||||
MORK_USED_1(ioPort);
|
||||
mdb_err outErr = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUsePortTableCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
ev->StubMethodOnlyError();
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinPortTableCursor::GetPort(nsIMdbEnv* mev, nsIMdbPort** acqPort)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbPort* outPort = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUsePortTableCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkPortTableCursor* cursor = (morkPortTableCursor*) mHandle_Object;
|
||||
morkStore* store = cursor->mPortTableCursor_Store;
|
||||
if ( store )
|
||||
outPort = store->AcquireStoreHandle(ev);
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( acqPort )
|
||||
*acqPort = outPort;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinPortTableCursor::SetRowScope(nsIMdbEnv* mev, // sets pos to -1
|
||||
mdb_scope inRowScope)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUsePortTableCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkPortTableCursor* cursor = (morkPortTableCursor*) mHandle_Object;
|
||||
cursor->mCursor_Pos = -1;
|
||||
|
||||
cursor->SetRowScope(ev, inRowScope);
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinPortTableCursor::GetRowScope(nsIMdbEnv* mev, mdb_scope* outRowScope)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mdb_scope rowScope = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUsePortTableCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkPortTableCursor* cursor = (morkPortTableCursor*) mHandle_Object;
|
||||
rowScope = cursor->mPortTableCursor_RowScope;
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
*outRowScope = rowScope;
|
||||
return outErr;
|
||||
}
|
||||
// setting row scope to zero iterates over all row scopes in port
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinPortTableCursor::SetTableKind(nsIMdbEnv* mev, // sets pos to -1
|
||||
mdb_kind inTableKind)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUsePortTableCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkPortTableCursor* cursor = (morkPortTableCursor*) mHandle_Object;
|
||||
cursor->mCursor_Pos = -1;
|
||||
|
||||
cursor->SetTableKind(ev, inTableKind);
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinPortTableCursor::GetTableKind(nsIMdbEnv* mev, mdb_kind* outTableKind)
|
||||
// setting table kind to zero iterates over all table kinds in row scope
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mdb_kind tableKind = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUsePortTableCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkPortTableCursor* cursor = (morkPortTableCursor*) mHandle_Object;
|
||||
tableKind = cursor->mPortTableCursor_TableKind;
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
*outTableKind = tableKind;
|
||||
return outErr;
|
||||
}
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin table iteration methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinPortTableCursor::NextTable( // get table at next position in the db
|
||||
nsIMdbEnv* mev, // context
|
||||
nsIMdbTable** acqTable)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbTable* outTable = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUsePortTableCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkPortTableCursor* cursor = (morkPortTableCursor*) mHandle_Object;
|
||||
morkTable* table = cursor->NextTable(ev);
|
||||
if ( table && ev->Good() )
|
||||
outTable = table->AcquireTableHandle(ev);
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( acqTable )
|
||||
*acqTable = outTable;
|
||||
return outErr;
|
||||
}
|
||||
// } ----- end table iteration methods -----
|
||||
|
||||
// } ===== end nsIMdbPortTableCursor methods =====
|
||||
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
@ -1,198 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _ORKINPORTTABLECURSOR_
|
||||
#define _ORKINPORTTABLECURSOR_ 1
|
||||
|
||||
#ifndef _MDB_
|
||||
#include "mdb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORK_
|
||||
#include "mork.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKNODE_
|
||||
#include "morkNode.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKHANDLE_
|
||||
#include "morkHandle.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKPORTTABLECURSOR_
|
||||
#include "morkPortTableCursor.h"
|
||||
#endif
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
class morkPortTableCursor;
|
||||
#define morkMagic_kPortTableCursor 0x50744375 /* ascii 'PtCu' */
|
||||
|
||||
/*| orkinPortTableCursor: cursor class for iterating port tables
|
||||
**|
|
||||
**|| port: the cursor is associated with a specific port, which can be
|
||||
**| set to a different port (which resets the position to -1 so the
|
||||
**| next table acquired is the first in the port.
|
||||
**|
|
||||
|*/
|
||||
class orkinPortTableCursor :
|
||||
public morkHandle, public nsIMdbPortTableCursor { // nsIMdbCursor
|
||||
|
||||
// { ===== begin morkNode interface =====
|
||||
public: // morkNode virtual methods
|
||||
// virtual void CloseMorkNode(morkEnv* ev); // morkHandle is fine
|
||||
virtual ~orkinPortTableCursor(); // morkHandle destructor does everything
|
||||
|
||||
protected: // construction is protected (use the static Make() method)
|
||||
orkinPortTableCursor(morkEnv* ev, // note morkUsage is always morkUsage_kPool
|
||||
morkHandleFace* ioFace, // must not be nil, cookie for this handle
|
||||
morkPortTableCursor* ioObject); // must not be nil, the object for this handle
|
||||
|
||||
// void CloseHandle(morkEnv* ev); // don't need to specialize closing
|
||||
|
||||
private: // copying is not allowed
|
||||
orkinPortTableCursor(const morkHandle& other);
|
||||
orkinPortTableCursor& operator=(const morkHandle& other);
|
||||
|
||||
// public: // dynamic type identification
|
||||
// mork_bool IsHandle() const //
|
||||
// { return IsNode() && mNode_Derived == morkDerived_kHandle; }
|
||||
// } ===== end morkNode methods =====
|
||||
|
||||
protected: // morkHandle memory management operators
|
||||
void* operator new(size_t inSize, morkPool& ioPool, morkZone& ioZone, morkEnv* ev) CPP_THROW_NEW
|
||||
{ return ioPool.NewHandle(ev, inSize, &ioZone); }
|
||||
|
||||
void* operator new(size_t inSize, morkPool& ioPool, morkEnv* ev) CPP_THROW_NEW
|
||||
{ return ioPool.NewHandle(ev, inSize, (morkZone*) 0); }
|
||||
|
||||
void* operator new(size_t inSize, morkHandleFace* ioFace) CPP_THROW_NEW
|
||||
{ MORK_USED_1(inSize); return ioFace; }
|
||||
|
||||
|
||||
public: // construction:
|
||||
|
||||
static orkinPortTableCursor* MakePortTableCursor(morkEnv* ev,
|
||||
morkPortTableCursor* ioObject);
|
||||
|
||||
public: // utilities:
|
||||
|
||||
morkEnv* CanUsePortTableCursor(nsIMdbEnv* mev, mork_bool inMutable,
|
||||
mdb_err* outErr) const;
|
||||
|
||||
public: // type identification
|
||||
mork_bool IsOrkinPortTableCursor() const
|
||||
{ return mHandle_Magic == morkMagic_kPortTableCursor; }
|
||||
|
||||
mork_bool IsOrkinPortTableCursorHandle() const
|
||||
{ return this->IsHandle() && this->IsOrkinPortTableCursor(); }
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
// { ===== begin nsIMdbObject methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
NS_IMETHOD IsFrozenMdbObject(nsIMdbEnv* ev, mdb_bool* outIsReadonly);
|
||||
// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin factory methods -----
|
||||
NS_IMETHOD GetMdbFactory(nsIMdbEnv* ev, nsIMdbFactory** acqFactory);
|
||||
// } ----- end factory methods -----
|
||||
|
||||
// { ----- begin ref counting for well-behaved cyclic graphs -----
|
||||
NS_IMETHOD GetWeakRefCount(nsIMdbEnv* ev, // weak refs
|
||||
mdb_count* outCount);
|
||||
NS_IMETHOD GetStrongRefCount(nsIMdbEnv* ev, // strong refs
|
||||
mdb_count* outCount);
|
||||
|
||||
NS_IMETHOD AddWeakRef(nsIMdbEnv* ev);
|
||||
NS_IMETHOD AddStrongRef(nsIMdbEnv* ev);
|
||||
|
||||
NS_IMETHOD CutWeakRef(nsIMdbEnv* ev);
|
||||
NS_IMETHOD CutStrongRef(nsIMdbEnv* ev);
|
||||
|
||||
NS_IMETHOD CloseMdbObject(nsIMdbEnv* ev); // called at strong refs zero
|
||||
NS_IMETHOD IsOpenMdbObject(nsIMdbEnv* ev, mdb_bool* outOpen);
|
||||
// } ----- end ref counting -----
|
||||
|
||||
// } ===== end nsIMdbObject methods =====
|
||||
|
||||
// { ===== begin nsIMdbCursor methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
NS_IMETHOD GetCount(nsIMdbEnv* ev, mdb_count* outCount); // readonly
|
||||
NS_IMETHOD GetSeed(nsIMdbEnv* ev, mdb_seed* outSeed); // readonly
|
||||
|
||||
NS_IMETHOD SetPos(nsIMdbEnv* ev, mdb_pos inPos); // mutable
|
||||
NS_IMETHOD GetPos(nsIMdbEnv* ev, mdb_pos* outPos);
|
||||
|
||||
NS_IMETHOD SetDoFailOnSeedOutOfSync(nsIMdbEnv* ev, mdb_bool inFail);
|
||||
NS_IMETHOD GetDoFailOnSeedOutOfSync(nsIMdbEnv* ev, mdb_bool* outFail);
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// } ===== end nsIMdbCursor methods =====
|
||||
|
||||
// { ===== begin nsIMdbPortTableCursor methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
NS_IMETHOD SetPort(nsIMdbEnv* ev, nsIMdbPort* ioPort); // sets pos to -1
|
||||
NS_IMETHOD GetPort(nsIMdbEnv* ev, nsIMdbPort** acqPort);
|
||||
|
||||
NS_IMETHOD SetRowScope(nsIMdbEnv* ev, // sets pos to -1
|
||||
mdb_scope inRowScope);
|
||||
NS_IMETHOD GetRowScope(nsIMdbEnv* ev, mdb_scope* outRowScope);
|
||||
// setting row scope to zero iterates over all row scopes in port
|
||||
|
||||
NS_IMETHOD SetTableKind(nsIMdbEnv* ev, // sets pos to -1
|
||||
mdb_kind inTableKind);
|
||||
NS_IMETHOD GetTableKind(nsIMdbEnv* ev, mdb_kind* outTableKind);
|
||||
// setting table kind to zero iterates over all table kinds in row scope
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin table iteration methods -----
|
||||
NS_IMETHOD NextTable( // get table at next position in the db
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbTable** acqTable); // the next table in the iteration
|
||||
// } ----- end table iteration methods -----
|
||||
|
||||
// } ===== end nsIMdbPortTableCursor methods =====
|
||||
};
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
#endif /* _ORKINPORTTABLECURSOR_ */
|
@ -1,849 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _MDB_
|
||||
#include "mdb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORK_
|
||||
#include "mork.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKNODE_
|
||||
#include "morkNode.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKHANDLE_
|
||||
#include "morkHandle.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKATOM_
|
||||
#include "morkAtom.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKROW_
|
||||
#include "morkRow.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINROW_
|
||||
#include "orkinRow.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKENV_
|
||||
#include "morkEnv.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKROWOBJECT_
|
||||
#include "morkRowObject.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKCELLOBJECT_
|
||||
#include "morkCellObject.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKSTORE_
|
||||
#include "morkStore.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINSTORE_
|
||||
#include "orkinStore.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKROWSPACE_
|
||||
#include "morkRowSpace.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKROWCELLCURSOR_
|
||||
#include "morkRowCellCursor.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINROWCELLCURSOR_
|
||||
#include "orkinRowCellCursor.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINCELL_
|
||||
#include "orkinCell.h"
|
||||
#endif
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
/* public virtual*/
|
||||
orkinRow:: ~orkinRow() // morkHandle destructor does everything
|
||||
{
|
||||
}
|
||||
|
||||
/*protected non-poly construction*/
|
||||
orkinRow::orkinRow(morkEnv* ev, // morkUsage is morkUsage_kPool
|
||||
morkHandleFace* ioFace, // must not be nil, cookie for this handle
|
||||
morkRowObject* ioObject) // must not be nil, the object for this handle
|
||||
: morkHandle(ev, ioFace, ioObject, morkMagic_kRow)
|
||||
{
|
||||
// do not modify mNode_Derived; leave it equal to morkDerived_kHandle
|
||||
}
|
||||
|
||||
|
||||
/*static */ orkinRow*
|
||||
orkinRow::MakeRow(morkEnv* ev, morkRowObject* ioObject)
|
||||
{
|
||||
mork_bool isEnv = ev->IsEnv();
|
||||
MORK_ASSERT(isEnv);
|
||||
if ( isEnv )
|
||||
{
|
||||
morkHandleFace* face = ev->NewHandle(sizeof(orkinRow));
|
||||
if ( face )
|
||||
return new(face) orkinRow(ev, face, ioObject);
|
||||
else
|
||||
ev->OutOfMemoryError();
|
||||
}
|
||||
|
||||
return (orkinRow*) 0;
|
||||
}
|
||||
|
||||
morkEnv*
|
||||
orkinRow::CanUseRow(nsIMdbEnv* mev, mork_bool inMutable,
|
||||
mdb_err* outErr, morkRow** outRow) const
|
||||
{
|
||||
morkEnv* outEnv = 0;
|
||||
morkRow* innerRow = 0;
|
||||
morkEnv* ev = morkEnv::FromMdbEnv(mev);
|
||||
if ( ev )
|
||||
{
|
||||
morkRowObject* rowObj = (morkRowObject*)
|
||||
this->GetGoodHandleObject(ev, inMutable, morkMagic_kRow,
|
||||
/*inClosedOkay*/ morkBool_kFalse);
|
||||
if ( rowObj )
|
||||
{
|
||||
if ( rowObj->IsRowObject() )
|
||||
{
|
||||
morkRow* row = rowObj->mRowObject_Row;
|
||||
if ( row )
|
||||
{
|
||||
if ( row->IsRow() )
|
||||
{
|
||||
if ( row->mRow_Object == rowObj )
|
||||
{
|
||||
outEnv = ev;
|
||||
innerRow = row;
|
||||
}
|
||||
else
|
||||
rowObj->RowObjectRowNotSelfError(ev);
|
||||
}
|
||||
else
|
||||
row->NonRowTypeError(ev);
|
||||
}
|
||||
else
|
||||
rowObj->NilRowError(ev);
|
||||
}
|
||||
else
|
||||
rowObj->NonRowObjectTypeError(ev);
|
||||
}
|
||||
*outErr = ev->AsErr();
|
||||
}
|
||||
if ( outRow )
|
||||
*outRow = innerRow;
|
||||
MORK_ASSERT(outEnv);
|
||||
return outEnv;
|
||||
}
|
||||
|
||||
morkStore*
|
||||
orkinRow::CanUseRowStore(morkEnv* ev) const
|
||||
{
|
||||
morkStore* outStore = 0;
|
||||
morkRowObject* rowObj = (morkRowObject*) mHandle_Object;
|
||||
if ( rowObj && rowObj->IsRowObject() )
|
||||
{
|
||||
morkStore* store = rowObj->mRowObject_Store;
|
||||
if ( store )
|
||||
{
|
||||
if ( store->IsStore() )
|
||||
{
|
||||
outStore = store;
|
||||
}
|
||||
else
|
||||
store->NonStoreTypeError(ev);
|
||||
}
|
||||
else
|
||||
rowObj->NilStoreError(ev);
|
||||
}
|
||||
return outStore;
|
||||
}
|
||||
|
||||
|
||||
// { ===== begin nsISupports methods =====
|
||||
NS_IMPL_QUERY_INTERFACE1(orkinRow, nsIMdbRow)
|
||||
|
||||
/*virtual*/ nsrefcnt
|
||||
orkinRow::AddRef() // add strong ref with no
|
||||
{
|
||||
morkEnv* ev = mHandle_Env;
|
||||
if ( ev && ev->IsEnv() )
|
||||
return this->Handle_AddStrongRef(ev->AsMdbEnv());
|
||||
else
|
||||
return morkEnv_kNonEnvTypeError;
|
||||
}
|
||||
|
||||
/*virtual*/ nsrefcnt
|
||||
orkinRow::Release() // cut strong ref
|
||||
{
|
||||
morkEnv* ev = mHandle_Env;
|
||||
if ( ev && ev->IsEnv() )
|
||||
return this->Handle_CutStrongRef(ev->AsMdbEnv());
|
||||
else
|
||||
return morkEnv_kNonEnvTypeError;
|
||||
}
|
||||
// } ===== end nsIMdbObject methods =====
|
||||
|
||||
|
||||
// { ===== begin nsIMdbObject methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::IsFrozenMdbObject(nsIMdbEnv* mev, mdb_bool* outIsReadonly)
|
||||
{
|
||||
return this->Handle_IsFrozenMdbObject(mev, outIsReadonly);
|
||||
}
|
||||
// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin factory methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::GetMdbFactory(nsIMdbEnv* mev, nsIMdbFactory** acqFactory)
|
||||
{
|
||||
return this->Handle_GetMdbFactory(mev, acqFactory);
|
||||
}
|
||||
// } ----- end factory methods -----
|
||||
|
||||
// { ----- begin ref counting for well-behaved cyclic graphs -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::GetWeakRefCount(nsIMdbEnv* mev, // weak refs
|
||||
mdb_count* outCount)
|
||||
{
|
||||
return this->Handle_GetWeakRefCount(mev, outCount);
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::GetStrongRefCount(nsIMdbEnv* mev, // strong refs
|
||||
mdb_count* outCount)
|
||||
{
|
||||
return this->Handle_GetStrongRefCount(mev, outCount);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::AddWeakRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_AddWeakRef(mev);
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::AddStrongRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_AddStrongRef(mev);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::CutWeakRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_CutWeakRef(mev);
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::CutStrongRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_CutStrongRef(mev);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::CloseMdbObject(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_CloseMdbObject(mev);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::IsOpenMdbObject(nsIMdbEnv* mev, mdb_bool* outOpen)
|
||||
{
|
||||
return this->Handle_IsOpenMdbObject(mev, outOpen);
|
||||
}
|
||||
// } ----- end ref counting -----
|
||||
|
||||
// } ===== end nsIMdbObject methods =====
|
||||
|
||||
|
||||
// { ===== begin nsIMdbCollection methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::GetSeed(nsIMdbEnv* mev,
|
||||
mdb_seed* outSeed)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
|
||||
&outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
*outSeed = (mdb_seed) row->mRow_Seed;
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::GetCount(nsIMdbEnv* mev,
|
||||
mdb_count* outCount)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
|
||||
&outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
*outCount = (mdb_count) row->mRow_Length;
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::GetPort(nsIMdbEnv* mev,
|
||||
nsIMdbPort** acqPort)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbPort* outPort = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
|
||||
&outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
morkRowSpace* rowSpace = row->mRow_Space;
|
||||
if ( rowSpace && rowSpace->mSpace_Store )
|
||||
{
|
||||
morkStore* store = row->GetRowSpaceStore(ev);
|
||||
if ( store )
|
||||
outPort = store->AcquireStoreHandle(ev);
|
||||
}
|
||||
else
|
||||
ev->NilPointerError();
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( acqPort )
|
||||
*acqPort = outPort;
|
||||
|
||||
return outErr;
|
||||
}
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin cursor methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::GetCursor( // make a cursor starting iter at inMemberPos
|
||||
nsIMdbEnv* mev, // context
|
||||
mdb_pos inMemberPos, // zero-based ordinal pos of member in collection
|
||||
nsIMdbCursor** acqCursor)
|
||||
{
|
||||
return this->GetRowCellCursor(mev, inMemberPos,
|
||||
(nsIMdbRowCellCursor**) acqCursor);
|
||||
}
|
||||
// } ----- end cursor methods -----
|
||||
|
||||
// { ----- begin ID methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::GetOid(nsIMdbEnv* mev,
|
||||
mdbOid* outOid)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
|
||||
&outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
*outOid = row->mRow_Oid;
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::BecomeContent(nsIMdbEnv* mev,
|
||||
const mdbOid* inOid)
|
||||
{
|
||||
MORK_USED_1(inOid);
|
||||
mdb_err outErr = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
|
||||
&outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
// remember row->MaybeDirtySpaceStoreAndRow();
|
||||
|
||||
ev->StubMethodOnlyError();
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
// } ----- end ID methods -----
|
||||
|
||||
// { ----- begin activity dropping methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::DropActivity( // tell collection usage no longer expected
|
||||
nsIMdbEnv* mev)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
|
||||
&outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
// ev->StubMethodOnlyError(); // do nothing
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
// } ----- end activity dropping methods -----
|
||||
|
||||
// } ===== end nsIMdbCollection methods =====
|
||||
|
||||
// { ===== begin nsIMdbRow methods =====
|
||||
|
||||
// { ----- begin cursor methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::GetRowCellCursor( // make a cursor starting iteration at inRowPos
|
||||
nsIMdbEnv* mev, // context
|
||||
mdb_pos inPos, // zero-based ordinal position of row in table
|
||||
nsIMdbRowCellCursor** acqCursor)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbRowCellCursor* outCursor = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
|
||||
&outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
morkRowCellCursor* cursor = row->NewRowCellCursor(ev, inPos);
|
||||
if ( cursor )
|
||||
{
|
||||
if ( ev->Good() )
|
||||
{
|
||||
cursor->mCursor_Seed = (mork_seed) inPos;
|
||||
outCursor = cursor->AcquireRowCellCursorHandle(ev);
|
||||
}
|
||||
else
|
||||
cursor->CutStrongRef(mev);
|
||||
}
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( acqCursor )
|
||||
*acqCursor = outCursor;
|
||||
return outErr;
|
||||
}
|
||||
// } ----- end cursor methods -----
|
||||
|
||||
// { ----- begin column methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::AddColumn( // make sure a particular column is inside row
|
||||
nsIMdbEnv* mev, // context
|
||||
mdb_column inColumn, // column to add
|
||||
const mdbYarn* inYarn)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
|
||||
&outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
morkStore* store = this->CanUseRowStore(ev);
|
||||
if ( store )
|
||||
row->AddColumn(ev, inColumn, inYarn, store);
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::CutColumn( // make sure a column is absent from the row
|
||||
nsIMdbEnv* mev, // context
|
||||
mdb_column inColumn)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
|
||||
&outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
row->CutColumn(ev, inColumn);
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::CutAllColumns( // remove all columns from the row
|
||||
nsIMdbEnv* mev)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
|
||||
&outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
row->CutAllColumns(ev);
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
// } ----- end column methods -----
|
||||
|
||||
// { ----- begin cell methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::NewCell( // get cell for specified column, or add new one
|
||||
nsIMdbEnv* mev, // context
|
||||
mdb_column inColumn, // column to add
|
||||
nsIMdbCell** acqCell)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbCell* outCell = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
|
||||
&outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
mork_pos pos = 0;
|
||||
morkCell* cell = row->GetCell(ev, inColumn, &pos);
|
||||
if ( !cell )
|
||||
{
|
||||
morkStore* store = this->CanUseRowStore(ev);
|
||||
if ( store )
|
||||
{
|
||||
mdbYarn yarn; // to pass empty yarn into morkRow::AddColumn()
|
||||
yarn.mYarn_Buf = 0;
|
||||
yarn.mYarn_Fill = 0;
|
||||
yarn.mYarn_Size = 0;
|
||||
yarn.mYarn_More = 0;
|
||||
yarn.mYarn_Form = 0;
|
||||
yarn.mYarn_Grow = 0;
|
||||
row->AddColumn(ev, inColumn, &yarn, store);
|
||||
cell = row->GetCell(ev, inColumn, &pos);
|
||||
}
|
||||
}
|
||||
if ( cell )
|
||||
outCell = row->AcquireCellHandle(ev, cell, inColumn, pos);
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( acqCell )
|
||||
*acqCell = outCell;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::AddCell( // copy a cell from another row to this row
|
||||
nsIMdbEnv* mev, // context
|
||||
const nsIMdbCell* inCell)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
|
||||
&outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
morkCell* cell = 0;
|
||||
morkCellObject* cellObj = (morkCellObject*) inCell;
|
||||
if ( cellObj->CanUseCell(mev, morkBool_kFalse, &outErr, &cell) )
|
||||
{
|
||||
|
||||
morkRow* cellRow = cellObj->mCellObject_Row;
|
||||
if ( cellRow )
|
||||
{
|
||||
if ( row != cellRow )
|
||||
{
|
||||
morkStore* store = row->GetRowSpaceStore(ev);
|
||||
morkStore* cellStore = cellRow->GetRowSpaceStore(ev);
|
||||
if ( store && cellStore )
|
||||
{
|
||||
mork_column col = cell->GetColumn();
|
||||
morkAtom* atom = cell->mCell_Atom;
|
||||
mdbYarn yarn;
|
||||
atom->AliasYarn(&yarn); // works even when atom is nil
|
||||
|
||||
if ( store != cellStore )
|
||||
col = store->CopyToken(ev, col, cellStore);
|
||||
if ( ev->Good() )
|
||||
row->AddColumn(ev, col, &yarn, store);
|
||||
}
|
||||
else
|
||||
ev->NilPointerError();
|
||||
}
|
||||
}
|
||||
else
|
||||
ev->NilPointerError();
|
||||
}
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::GetCell( // find a cell in this row
|
||||
nsIMdbEnv* mev, // context
|
||||
mdb_column inColumn, // column to find
|
||||
nsIMdbCell** acqCell)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbCell* outCell = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
|
||||
&outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
if ( inColumn )
|
||||
{
|
||||
mork_pos pos = 0;
|
||||
morkCell* cell = row->GetCell(ev, inColumn, &pos);
|
||||
if ( cell )
|
||||
{
|
||||
outCell = row->AcquireCellHandle(ev, cell, inColumn, pos);
|
||||
}
|
||||
}
|
||||
else
|
||||
row->ZeroColumnError(ev);
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( acqCell )
|
||||
*acqCell = outCell;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::EmptyAllCells( // make all cells in row empty of content
|
||||
nsIMdbEnv* mev)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
|
||||
&outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
row->EmptyAllCells(ev);
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
// } ----- end cell methods -----
|
||||
|
||||
// { ----- begin row methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::AddRow( // add all cells in another row to this one
|
||||
nsIMdbEnv* mev, // context
|
||||
nsIMdbRow* ioSourceRow)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
|
||||
&outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
morkRow* source = 0;
|
||||
orkinRow* unsafeSource = (orkinRow*) ioSourceRow; // unsafe cast
|
||||
if ( unsafeSource->CanUseRow(mev, morkBool_kFalse, &outErr, &source) )
|
||||
{
|
||||
row->AddRow(ev, source);
|
||||
}
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::SetRow( // make exact duplicate of another row
|
||||
nsIMdbEnv* mev, // context
|
||||
nsIMdbRow* ioSourceRow)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
|
||||
&outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
morkRow* source = 0;
|
||||
orkinRow* unsafeSource = (orkinRow*) ioSourceRow; // unsafe cast
|
||||
if ( unsafeSource->CanUseRow(mev, morkBool_kFalse, &outErr, &source) )
|
||||
{
|
||||
row->SetRow(ev, source);
|
||||
}
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
// } ----- end row methods -----
|
||||
|
||||
// { ----- begin blob methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::SetCellYarn( // synonym for AddColumn()
|
||||
nsIMdbEnv* mev, // context
|
||||
mdb_column inColumn, // column to add
|
||||
const mdbYarn* inYarn)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
|
||||
&outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
morkStore* store = this->CanUseRowStore(ev);
|
||||
if ( store )
|
||||
row->AddColumn(ev, inColumn, inYarn, store);
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::GetCellYarn(
|
||||
nsIMdbEnv* mev, // context
|
||||
mdb_column inColumn, // column to read
|
||||
mdbYarn* outYarn) // writes some yarn slots
|
||||
// copy content into the yarn buffer, and update mYarn_Fill and mYarn_Form
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
|
||||
&outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
morkStore* store = this->CanUseRowStore(ev);
|
||||
if ( store )
|
||||
{
|
||||
morkAtom* atom = row->GetColumnAtom(ev, inColumn);
|
||||
atom->GetYarn(outYarn);
|
||||
// note nil atom works and sets yarn correctly
|
||||
}
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::AliasCellYarn(
|
||||
nsIMdbEnv* mev, // context
|
||||
mdb_column inColumn, // column to alias
|
||||
mdbYarn* outYarn) // writes ALL yarn slots
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
|
||||
&outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
morkStore* store = this->CanUseRowStore(ev);
|
||||
if ( store )
|
||||
{
|
||||
morkAtom* atom = row->GetColumnAtom(ev, inColumn);
|
||||
atom->AliasYarn(outYarn);
|
||||
// note nil atom works and sets yarn correctly
|
||||
}
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::NextCellYarn(nsIMdbEnv* mev, // iterative version of GetCellYarn()
|
||||
mdb_column* ioColumn, // next column to read
|
||||
mdbYarn* outYarn) // writes some yarn slots
|
||||
// copy content into the yarn buffer, and update mYarn_Fill and mYarn_Form
|
||||
//
|
||||
// The ioColumn argument is an inout parameter which initially contains the
|
||||
// last column accessed and returns the next column corresponding to the
|
||||
// content read into the yarn. Callers should start with a zero column
|
||||
// value to say 'no previous column', which causes the first column to be
|
||||
// read. Then the value returned in ioColumn is perfect for the next call
|
||||
// to NextCellYarn(), since it will then be the previous column accessed.
|
||||
// Callers need only examine the column token returned to see which cell
|
||||
// in the row is being read into the yarn. When no more columns remain,
|
||||
// and the iteration has ended, ioColumn will return a zero token again.
|
||||
// So iterating over cells starts and ends with a zero column token.
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
|
||||
&outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
morkStore* store = this->CanUseRowStore(ev);
|
||||
if ( store )
|
||||
row->NextColumn(ev, ioColumn, outYarn);
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinRow::SeekCellYarn( // resembles nsIMdbRowCellCursor::SeekCell()
|
||||
nsIMdbEnv* mev, // context
|
||||
mdb_pos inPos, // position of cell in row sequence
|
||||
mdb_column* outColumn, // column for this particular cell
|
||||
mdbYarn* outYarn) // writes some yarn slots
|
||||
// copy content into the yarn buffer, and update mYarn_Fill and mYarn_Form
|
||||
// Callers can pass nil for outYarn to indicate no interest in content, so
|
||||
// only the outColumn value is returned. NOTE to subclasses: you must be
|
||||
// able to ignore outYarn when the pointer is nil; please do not crash.
|
||||
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
|
||||
&outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
morkStore* store = this->CanUseRowStore(ev);
|
||||
if ( store )
|
||||
row->SeekColumn(ev, inPos, outColumn, outYarn);
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
// } ----- end blob methods -----
|
||||
|
||||
|
||||
// } ===== end nsIMdbRow methods =====
|
||||
|
||||
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
@ -1,284 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _ORKINROW_
|
||||
#define _ORKINROW_ 1
|
||||
|
||||
#ifndef _MDB_
|
||||
#include "mdb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORK_
|
||||
#include "mork.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKNODE_
|
||||
#include "morkNode.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKHANDLE_
|
||||
#include "morkHandle.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKROW_
|
||||
#include "morkRow.h"
|
||||
#endif
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
#define morkMagic_kRow 0x526F774D /* ascii 'RowM' */
|
||||
|
||||
/*| orkinRow: a collection of cells
|
||||
**|
|
||||
|*/
|
||||
class orkinRow : public morkHandle, public nsIMdbRow { // nsIMdbCollection
|
||||
|
||||
// { ===== begin morkNode interface =====
|
||||
public: // morkNode virtual methods
|
||||
// virtual void CloseMorkNode(morkEnv* ev); // morkHandle is fine
|
||||
virtual ~orkinRow(); // morkHandle destructor does everything
|
||||
|
||||
protected: // construction is protected (use the static Make() method)
|
||||
orkinRow(morkEnv* ev, // note morkUsage is always morkUsage_kPool
|
||||
morkHandleFace* ioFace, // must not be nil, cookie for this handle
|
||||
morkRowObject* ioObject); // must not be nil, the object for this handle
|
||||
|
||||
// void CloseHandle(morkEnv* ev); // don't need to specialize closing
|
||||
|
||||
private: // copying is not allowed
|
||||
orkinRow(const morkHandle& other);
|
||||
orkinRow& operator=(const morkHandle& other);
|
||||
|
||||
// public: // dynamic type identification
|
||||
// mork_bool IsHandle() const //
|
||||
// { return IsNode() && mNode_Derived == morkDerived_kHandle; }
|
||||
// } ===== end morkNode methods =====
|
||||
|
||||
protected: // morkHandle memory management operators
|
||||
void* operator new(size_t inSize, morkPool& ioPool, morkZone& ioZone, morkEnv* ev) CPP_THROW_NEW
|
||||
{ return ioPool.NewHandle(ev, inSize, &ioZone); }
|
||||
|
||||
void* operator new(size_t inSize, morkPool& ioPool, morkEnv* ev) CPP_THROW_NEW
|
||||
{ return ioPool.NewHandle(ev, inSize, (morkZone*) 0); }
|
||||
|
||||
void* operator new(size_t inSize, morkHandleFace* ioFace) CPP_THROW_NEW
|
||||
{ MORK_USED_1(inSize); return ioFace; }
|
||||
|
||||
|
||||
public: // construction:
|
||||
|
||||
static orkinRow* MakeRow(morkEnv* ev, morkRowObject* ioObject);
|
||||
|
||||
public: // utilities:
|
||||
|
||||
morkEnv* CanUseRow(nsIMdbEnv* mev, mork_bool inMutable,
|
||||
mdb_err* outErr, morkRow** outRow) const;
|
||||
|
||||
morkStore* CanUseRowStore(morkEnv* ev) const;
|
||||
|
||||
public: // type identification
|
||||
mork_bool IsOrkinRow() const
|
||||
{ return mHandle_Magic == morkMagic_kRow; }
|
||||
|
||||
mork_bool IsOrkinRowHandle() const
|
||||
{ return this->IsHandle() && this->IsOrkinRow(); }
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
// { ===== begin nsIMdbObject methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
NS_IMETHOD IsFrozenMdbObject(nsIMdbEnv* ev, mdb_bool* outIsReadonly);
|
||||
// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin factory methods -----
|
||||
NS_IMETHOD GetMdbFactory(nsIMdbEnv* ev, nsIMdbFactory** acqFactory);
|
||||
// } ----- end factory methods -----
|
||||
|
||||
// { ----- begin ref counting for well-behaved cyclic graphs -----
|
||||
NS_IMETHOD GetWeakRefCount(nsIMdbEnv* ev, // weak refs
|
||||
mdb_count* outCount);
|
||||
NS_IMETHOD GetStrongRefCount(nsIMdbEnv* ev, // strong refs
|
||||
mdb_count* outCount);
|
||||
|
||||
NS_IMETHOD AddWeakRef(nsIMdbEnv* ev);
|
||||
NS_IMETHOD AddStrongRef(nsIMdbEnv* ev);
|
||||
|
||||
NS_IMETHOD CutWeakRef(nsIMdbEnv* ev);
|
||||
NS_IMETHOD CutStrongRef(nsIMdbEnv* ev);
|
||||
|
||||
NS_IMETHOD CloseMdbObject(nsIMdbEnv* ev); // called at strong refs zero
|
||||
NS_IMETHOD IsOpenMdbObject(nsIMdbEnv* ev, mdb_bool* outOpen);
|
||||
// } ----- end ref counting -----
|
||||
|
||||
// } ===== end nsIMdbObject methods =====
|
||||
|
||||
// { ===== begin nsIMdbCollection methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
NS_IMETHOD GetSeed(nsIMdbEnv* ev,
|
||||
mdb_seed* outSeed); // member change count
|
||||
NS_IMETHOD GetCount(nsIMdbEnv* ev,
|
||||
mdb_count* outCount); // member count
|
||||
|
||||
NS_IMETHOD GetPort(nsIMdbEnv* ev,
|
||||
nsIMdbPort** acqPort); // collection container
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin cursor methods -----
|
||||
NS_IMETHOD GetCursor( // make a cursor starting iter at inMemberPos
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_pos inMemberPos, // zero-based ordinal pos of member in collection
|
||||
nsIMdbCursor** acqCursor); // acquire new cursor instance
|
||||
// } ----- end cursor methods -----
|
||||
|
||||
// { ----- begin ID methods -----
|
||||
NS_IMETHOD GetOid(nsIMdbEnv* ev,
|
||||
mdbOid* outOid); // read object identity
|
||||
NS_IMETHOD BecomeContent(nsIMdbEnv* ev,
|
||||
const mdbOid* inOid); // exchange content
|
||||
// } ----- end ID methods -----
|
||||
|
||||
// { ----- begin activity dropping methods -----
|
||||
NS_IMETHOD DropActivity( // tell collection usage no longer expected
|
||||
nsIMdbEnv* ev);
|
||||
// } ----- end activity dropping methods -----
|
||||
|
||||
// } ===== end nsIMdbCollection methods =====
|
||||
|
||||
// { ===== begin nsIMdbRow methods =====
|
||||
|
||||
// { ----- begin cursor methods -----
|
||||
NS_IMETHOD GetRowCellCursor( // make a cursor starting iteration at inRowPos
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_pos inRowPos, // zero-based ordinal position of row in table
|
||||
nsIMdbRowCellCursor** acqCursor); // acquire new cursor instance
|
||||
// } ----- end cursor methods -----
|
||||
|
||||
// { ----- begin column methods -----
|
||||
NS_IMETHOD AddColumn( // make sure a particular column is inside row
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_column inColumn, // column to add
|
||||
const mdbYarn* inYarn); // cell value to install
|
||||
|
||||
NS_IMETHOD CutColumn( // make sure a column is absent from the row
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_column inColumn); // column to ensure absent from row
|
||||
|
||||
NS_IMETHOD CutAllColumns( // remove all columns from the row
|
||||
nsIMdbEnv* ev); // context
|
||||
// } ----- end column methods -----
|
||||
|
||||
// { ----- begin cell methods -----
|
||||
NS_IMETHOD NewCell( // get cell for specified column, or add new one
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_column inColumn, // column to add
|
||||
nsIMdbCell** acqCell); // cell column and value
|
||||
|
||||
NS_IMETHOD AddCell( // copy a cell from another row to this row
|
||||
nsIMdbEnv* ev, // context
|
||||
const nsIMdbCell* inCell); // cell column and value
|
||||
|
||||
NS_IMETHOD GetCell( // find a cell in this row
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_column inColumn, // column to find
|
||||
nsIMdbCell** acqCell); // cell for specified column, or null
|
||||
|
||||
NS_IMETHOD EmptyAllCells( // make all cells in row empty of content
|
||||
nsIMdbEnv* ev); // context
|
||||
// } ----- end cell methods -----
|
||||
|
||||
// { ----- begin row methods -----
|
||||
NS_IMETHOD AddRow( // add all cells in another row to this one
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbRow* ioSourceRow); // row to union with
|
||||
|
||||
NS_IMETHOD SetRow( // make exact duplicate of another row
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbRow* ioSourceRow); // row to duplicate
|
||||
// } ----- end row methods -----
|
||||
|
||||
// { ----- begin blob methods -----
|
||||
NS_IMETHOD SetCellYarn(nsIMdbEnv* ev, // synonym for AddColumn()
|
||||
mdb_column inColumn, // column to write
|
||||
const mdbYarn* inYarn); // reads from yarn slots
|
||||
// make this text object contain content from the yarn's buffer
|
||||
|
||||
NS_IMETHOD GetCellYarn(nsIMdbEnv* ev,
|
||||
mdb_column inColumn, // column to read
|
||||
mdbYarn* outYarn); // writes some yarn slots
|
||||
// copy content into the yarn buffer, and update mYarn_Fill and mYarn_Form
|
||||
|
||||
NS_IMETHOD AliasCellYarn(nsIMdbEnv* ev,
|
||||
mdb_column inColumn, // column to alias
|
||||
mdbYarn* outYarn); // writes ALL yarn slots
|
||||
|
||||
NS_IMETHOD NextCellYarn(nsIMdbEnv* ev, // iterative version of GetCellYarn()
|
||||
mdb_column* ioColumn, // next column to read
|
||||
mdbYarn* outYarn); // writes some yarn slots
|
||||
// copy content into the yarn buffer, and update mYarn_Fill and mYarn_Form
|
||||
//
|
||||
// The ioColumn argument is an inout parameter which initially contains the
|
||||
// last column accessed and returns the next column corresponding to the
|
||||
// content read into the yarn. Callers should start with a zero column
|
||||
// value to say 'no previous column', which causes the first column to be
|
||||
// read. Then the value returned in ioColumn is perfect for the next call
|
||||
// to NextCellYarn(), since it will then be the previous column accessed.
|
||||
// Callers need only examine the column token returned to see which cell
|
||||
// in the row is being read into the yarn. When no more columns remain,
|
||||
// and the iteration has ended, ioColumn will return a zero token again.
|
||||
// So iterating over cells starts and ends with a zero column token.
|
||||
|
||||
NS_IMETHOD SeekCellYarn( // resembles nsIMdbRowCellCursor::SeekCell()
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_pos inPos, // position of cell in row sequence
|
||||
mdb_column* outColumn, // column for this particular cell
|
||||
mdbYarn* outYarn); // writes some yarn slots
|
||||
// copy content into the yarn buffer, and update mYarn_Fill and mYarn_Form
|
||||
// Callers can pass nil for outYarn to indicate no interest in content, so
|
||||
// only the outColumn value is returned. NOTE to subclasses: you must be
|
||||
// able to ignore outYarn when the pointer is nil; please do not crash.
|
||||
|
||||
// } ----- end blob methods -----
|
||||
|
||||
// } ===== end nsIMdbRow methods =====
|
||||
};
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
#endif /* _ORKINROW_ */
|
||||
|
@ -1,564 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _MDB_
|
||||
#include "mdb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORK_
|
||||
#include "mork.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKNODE_
|
||||
#include "morkNode.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKHANDLE_
|
||||
#include "morkHandle.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKROWCELLCURSOR_
|
||||
#include "morkRowCellCursor.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINROWCELLCURSOR_
|
||||
#include "orkinRowCellCursor.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKROWOBJECT_
|
||||
#include "morkRowObject.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKROW_
|
||||
#include "morkRow.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINROW_
|
||||
#include "orkinRow.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKCELL_
|
||||
#include "morkCell.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKENV_
|
||||
#include "morkEnv.h"
|
||||
#endif
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
/* public virtual*/
|
||||
orkinRowCellCursor:: ~orkinRowCellCursor() // morkHandle destructor does everything
|
||||
{
|
||||
}
|
||||
|
||||
/*protected non-poly construction*/
|
||||
orkinRowCellCursor::orkinRowCellCursor(morkEnv* ev, // morkUsage is morkUsage_kPool
|
||||
morkHandleFace* ioFace, // must not be nil, cookie for this handle
|
||||
morkRowCellCursor* ioObject) // must not be nil, the object for this handle
|
||||
: morkHandle(ev, ioFace, ioObject, morkMagic_kRowCellCursor)
|
||||
{
|
||||
// do not modify mNode_Derived; leave it equal to morkDerived_kHandle
|
||||
}
|
||||
|
||||
|
||||
/*static */ orkinRowCellCursor*
|
||||
orkinRowCellCursor::MakeRowCellCursor(morkEnv* ev, morkRowCellCursor* ioObject)
|
||||
{
|
||||
mork_bool isEnv = ev->IsEnv();
|
||||
MORK_ASSERT(isEnv);
|
||||
if ( isEnv )
|
||||
{
|
||||
morkHandleFace* face = ev->NewHandle(sizeof(orkinRowCellCursor));
|
||||
if ( face )
|
||||
return new(face) orkinRowCellCursor(ev, face, ioObject);
|
||||
else
|
||||
ev->OutOfMemoryError();
|
||||
}
|
||||
|
||||
return (orkinRowCellCursor*) 0;
|
||||
}
|
||||
|
||||
morkEnv*
|
||||
orkinRowCellCursor::CanUseRowCellCursor(nsIMdbEnv* mev, mork_bool inMutable,
|
||||
mdb_err* outErr, morkRow** outRow) const
|
||||
{
|
||||
morkEnv* outEnv = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev = morkEnv::FromMdbEnv(mev);
|
||||
if ( ev )
|
||||
{
|
||||
morkRowCellCursor* self = (morkRowCellCursor*)
|
||||
this->GetGoodHandleObject(ev, inMutable, morkMagic_kRowCellCursor,
|
||||
/*inClosedOkay*/ morkBool_kFalse);
|
||||
if ( self )
|
||||
{
|
||||
if ( self->IsRowCellCursor() )
|
||||
{
|
||||
if ( self->IsMutable() || !inMutable )
|
||||
{
|
||||
morkRowObject* rowObj = self->mRowCellCursor_RowObject;
|
||||
if ( rowObj )
|
||||
{
|
||||
morkRow* theRow = rowObj->mRowObject_Row;
|
||||
if ( theRow )
|
||||
{
|
||||
if ( theRow->IsRow() )
|
||||
{
|
||||
outEnv = ev;
|
||||
row = theRow;
|
||||
}
|
||||
else
|
||||
theRow->NonRowTypeError(ev);
|
||||
}
|
||||
else
|
||||
rowObj->NilRowError(ev);
|
||||
}
|
||||
else
|
||||
self->NilRowObjectError(ev);
|
||||
}
|
||||
else
|
||||
self->NonMutableNodeError(ev);
|
||||
}
|
||||
else
|
||||
self->NonRowCellCursorTypeError(ev);
|
||||
}
|
||||
*outErr = ev->AsErr();
|
||||
}
|
||||
*outRow = row;
|
||||
MORK_ASSERT(outEnv);
|
||||
return outEnv;
|
||||
}
|
||||
|
||||
// { ===== begin nsIMdbISupports methods =====
|
||||
NS_IMPL_QUERY_INTERFACE0(orkinRowCellCursor)
|
||||
|
||||
/*virtual*/ nsrefcnt
|
||||
orkinRowCellCursor::AddRef() // add strong ref with no
|
||||
{
|
||||
morkEnv* ev = mHandle_Env;
|
||||
if ( ev && ev->IsEnv() )
|
||||
return this->Handle_AddStrongRef(ev->AsMdbEnv());
|
||||
else
|
||||
return morkEnv_kNonEnvTypeError;
|
||||
}
|
||||
|
||||
/*virtual*/ nsrefcnt
|
||||
orkinRowCellCursor::Release() // cut strong ref
|
||||
{
|
||||
morkEnv* ev = mHandle_Env;
|
||||
if ( ev && ev->IsEnv() )
|
||||
return this->Handle_CutStrongRef(ev->AsMdbEnv());
|
||||
else
|
||||
return morkEnv_kNonEnvTypeError;
|
||||
}
|
||||
// } ===== end nsIMdbObject methods =====
|
||||
|
||||
// { ===== begin nsIMdbObject methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinRowCellCursor::IsFrozenMdbObject(nsIMdbEnv* mev, mdb_bool* outIsReadonly)
|
||||
{
|
||||
return this->Handle_IsFrozenMdbObject(mev, outIsReadonly);
|
||||
}
|
||||
// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin factory methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinRowCellCursor::GetMdbFactory(nsIMdbEnv* mev, nsIMdbFactory** acqFactory)
|
||||
{
|
||||
return this->Handle_GetMdbFactory(mev, acqFactory);
|
||||
}
|
||||
// } ----- end factory methods -----
|
||||
|
||||
// { ----- begin ref counting for well-behaved cyclic graphs -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinRowCellCursor::GetWeakRefCount(nsIMdbEnv* mev, // weak refs
|
||||
mdb_count* outCount)
|
||||
{
|
||||
return this->Handle_GetWeakRefCount(mev, outCount);
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinRowCellCursor::GetStrongRefCount(nsIMdbEnv* mev, // strong refs
|
||||
mdb_count* outCount)
|
||||
{
|
||||
return this->Handle_GetStrongRefCount(mev, outCount);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinRowCellCursor::AddWeakRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_AddWeakRef(mev);
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinRowCellCursor::AddStrongRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_AddStrongRef(mev);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinRowCellCursor::CutWeakRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_CutWeakRef(mev);
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinRowCellCursor::CutStrongRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_CutStrongRef(mev);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinRowCellCursor::CloseMdbObject(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_CloseMdbObject(mev);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinRowCellCursor::IsOpenMdbObject(nsIMdbEnv* mev, mdb_bool* outOpen)
|
||||
{
|
||||
return this->Handle_IsOpenMdbObject(mev, outOpen);
|
||||
}
|
||||
// } ----- end ref counting -----
|
||||
|
||||
// } ===== end nsIMdbObject methods =====
|
||||
|
||||
// { ===== begin nsIMdbCursor methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinRowCellCursor::GetCount(nsIMdbEnv* mev, mdb_count* outCount)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mdb_count count = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUseRowCellCursor(mev, /*mut*/ morkBool_kFalse, &outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
count = row->mRow_Length;
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( outCount )
|
||||
*outCount = count;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinRowCellCursor::GetSeed(nsIMdbEnv* mev, mdb_seed* outSeed)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mdb_seed seed = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUseRowCellCursor(mev, /*mut*/ morkBool_kFalse, &outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
seed = row->mRow_Seed;
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( outSeed )
|
||||
*outSeed = seed;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinRowCellCursor::SetPos(nsIMdbEnv* mev, mdb_pos inPos)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUseRowCellCursor(mev, /*mut*/ morkBool_kFalse, &outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
morkRowCellCursor* cursor = (morkRowCellCursor*) mHandle_Object;
|
||||
cursor->mCursor_Pos = inPos;
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinRowCellCursor::GetPos(nsIMdbEnv* mev, mdb_pos* outPos)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mdb_pos pos = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUseRowCellCursor(mev, /*mut*/ morkBool_kFalse, &outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
morkRowCellCursor* cursor = (morkRowCellCursor*) mHandle_Object;
|
||||
pos = cursor->mCursor_Pos;
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( outPos )
|
||||
*outPos = pos;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinRowCellCursor::SetDoFailOnSeedOutOfSync(nsIMdbEnv* mev, mdb_bool inFail)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUseRowCellCursor(mev, /*mut*/ morkBool_kFalse, &outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
morkRowCellCursor* cursor = (morkRowCellCursor*) mHandle_Object;
|
||||
cursor->mCursor_DoFailOnSeedOutOfSync = inFail;
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinRowCellCursor::GetDoFailOnSeedOutOfSync(nsIMdbEnv* mev, mdb_bool* outFail)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mdb_bool doFail = morkBool_kFalse;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUseRowCellCursor(mev, /*mut*/ morkBool_kFalse, &outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
morkRowCellCursor* cursor = (morkRowCellCursor*) mHandle_Object;
|
||||
doFail = cursor->mCursor_DoFailOnSeedOutOfSync;
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( outFail )
|
||||
*outFail = doFail;
|
||||
return outErr;
|
||||
}
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// } ===== end nsIMdbCursor methods =====
|
||||
|
||||
// { ===== begin nsIMdbRowCellCursor methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinRowCellCursor::SetRow(nsIMdbEnv* mev, nsIMdbRow* ioRow)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUseRowCellCursor(mev, /*mut*/ morkBool_kFalse, &outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
morkRowCellCursor* cursor = (morkRowCellCursor*) mHandle_Object;
|
||||
row = (morkRow *) ioRow;
|
||||
morkStore* store = row->GetRowSpaceStore(ev);
|
||||
if ( store )
|
||||
{
|
||||
morkRowObject* rowObj = row->AcquireRowObject(ev, store);
|
||||
if ( rowObj )
|
||||
{
|
||||
morkRowObject::SlotStrongRowObject((morkRowObject*) 0, ev,
|
||||
&cursor->mRowCellCursor_RowObject);
|
||||
|
||||
cursor->mRowCellCursor_RowObject = rowObj; // take this strong ref
|
||||
cursor->mCursor_Seed = row->mRow_Seed;
|
||||
|
||||
row->GetCell(ev, cursor->mRowCellCursor_Col, &cursor->mCursor_Pos);
|
||||
}
|
||||
}
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinRowCellCursor::GetRow(nsIMdbEnv* mev, nsIMdbRow** acqRow)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbRow* outRow = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUseRowCellCursor(mev, /*mut*/ morkBool_kFalse, &outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
morkRowCellCursor* cursor = (morkRowCellCursor*) mHandle_Object;
|
||||
morkRowObject* rowObj = cursor->mRowCellCursor_RowObject;
|
||||
if ( rowObj )
|
||||
outRow = rowObj->AcquireRowHandle(ev);
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( acqRow )
|
||||
*acqRow = outRow;
|
||||
return outErr;
|
||||
}
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin cell creation methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinRowCellCursor::MakeCell( // get cell at current pos in the row
|
||||
nsIMdbEnv* mev, // context
|
||||
mdb_column* outColumn, // column for this particular cell
|
||||
mdb_pos* outPos, // position of cell in row sequence
|
||||
nsIMdbCell** acqCell)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbCell* outCell = 0;
|
||||
mdb_pos pos = 0;
|
||||
mdb_column col = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUseRowCellCursor(mev, /*mut*/ morkBool_kFalse, &outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
morkRowCellCursor* cursor = (morkRowCellCursor*) mHandle_Object;
|
||||
pos = cursor->mCursor_Pos;
|
||||
morkCell* cell = row->CellAt(ev, pos);
|
||||
if ( cell )
|
||||
{
|
||||
col = cell->GetColumn();
|
||||
outCell = row->AcquireCellHandle(ev, cell, col, pos);
|
||||
}
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( acqCell )
|
||||
*acqCell = outCell;
|
||||
if ( outPos )
|
||||
*outPos = pos;
|
||||
if ( outColumn )
|
||||
*outColumn = col;
|
||||
|
||||
return outErr;
|
||||
}
|
||||
// } ----- end cell creation methods -----
|
||||
|
||||
// { ----- begin cell seeking methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinRowCellCursor::SeekCell( // same as SetRow() followed by MakeCell()
|
||||
nsIMdbEnv* mev, // context
|
||||
mdb_pos inPos, // position of cell in row sequence
|
||||
mdb_column* outColumn, // column for this particular cell
|
||||
nsIMdbCell** acqCell)
|
||||
{
|
||||
MORK_USED_1(inPos);
|
||||
mdb_err outErr = 0;
|
||||
mdb_column column = 0;
|
||||
nsIMdbCell* outCell = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUseRowCellCursor(mev, /*mut*/ morkBool_kFalse, &outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
morkRowCellCursor* cursor;
|
||||
cursor = (morkRowCellCursor*) mHandle_Object;
|
||||
ev->StubMethodOnlyError();
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( acqCell )
|
||||
*acqCell = outCell;
|
||||
if ( outColumn )
|
||||
*outColumn = column;
|
||||
return outErr;
|
||||
}
|
||||
// } ----- end cell seeking methods -----
|
||||
|
||||
// { ----- begin cell iteration methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinRowCellCursor::NextCell( // get next cell in the row
|
||||
nsIMdbEnv* mev, // context
|
||||
nsIMdbCell* ioCell, // changes to the next cell in the iteration
|
||||
mdb_column* outColumn, // column for this particular cell
|
||||
mdb_pos* outPos)
|
||||
{
|
||||
MORK_USED_1(ioCell);
|
||||
mdb_err outErr = 0;
|
||||
mdb_pos pos = -1;
|
||||
mdb_column column = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUseRowCellCursor(mev, /*mut*/ morkBool_kFalse, &outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
morkRowCellCursor* cursor;
|
||||
cursor = (morkRowCellCursor*) mHandle_Object;
|
||||
ev->StubMethodOnlyError();
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( outColumn )
|
||||
*outColumn = column;
|
||||
if ( outPos )
|
||||
*outPos = pos;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinRowCellCursor::PickNextCell( // get next cell in row within filter set
|
||||
nsIMdbEnv* mev, // context
|
||||
nsIMdbCell* ioCell, // changes to the next cell in the iteration
|
||||
const mdbColumnSet* inFilterSet, // col set of actual caller interest
|
||||
mdb_column* outColumn, // column for this particular cell
|
||||
mdb_pos* outPos)
|
||||
// Note that inFilterSet should not have too many (many more than 10?)
|
||||
// cols, since this might imply a potential excessive consumption of time
|
||||
// over many cursor calls when looking for column and filter intersection.
|
||||
{
|
||||
MORK_USED_2(ioCell,inFilterSet);
|
||||
mdb_pos pos = -1;
|
||||
mdb_column column = 0;
|
||||
mdb_err outErr = 0;
|
||||
morkRow* row = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUseRowCellCursor(mev, /*mut*/ morkBool_kFalse, &outErr, &row);
|
||||
if ( ev )
|
||||
{
|
||||
morkRowCellCursor* cursor;
|
||||
cursor = (morkRowCellCursor*) mHandle_Object;
|
||||
ev->StubMethodOnlyError();
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( outColumn )
|
||||
*outColumn = column;
|
||||
if ( outPos )
|
||||
*outPos = pos;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
// } ----- end cell iteration methods -----
|
||||
|
||||
// } ===== end nsIMdbRowCellCursor methods =====
|
||||
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
@ -1,217 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _ORKINROWCELLCURSOR_
|
||||
#define _ORKINROWCELLCURSOR_ 1
|
||||
|
||||
#ifndef _MDB_
|
||||
#include "mdb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORK_
|
||||
#include "mork.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKNODE_
|
||||
#include "morkNode.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKHANDLE_
|
||||
#include "morkHandle.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKROWCELLCURSOR_
|
||||
#include "morkRowCellCursor.h"
|
||||
#endif
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
#define morkMagic_kRowCellCursor 0x52634375 /* ascii 'RcCu' */
|
||||
|
||||
/*| orkinRowCellCursor: cursor class for iterating row cells
|
||||
**|
|
||||
**|| row: the cursor is associated with a specific row, which can be
|
||||
**| set to a different row (which resets the position to -1 so the
|
||||
**| next cell acquired is the first in the row.
|
||||
**|
|
||||
**|| NextCell: get the next cell in the row and return its position and
|
||||
**| a new instance of a nsIMdbCell to represent this next cell.
|
||||
|*/
|
||||
class orkinRowCellCursor :
|
||||
public morkHandle, public nsIMdbRowCellCursor { // nsIMdbCursor
|
||||
|
||||
// { ===== begin morkNode interface =====
|
||||
public: // morkNode virtual methods
|
||||
// virtual void CloseMorkNode(morkEnv* ev); // morkHandle is fine
|
||||
virtual ~orkinRowCellCursor(); // morkHandle destructor does everything
|
||||
|
||||
protected: // construction is protected (use the static Make() method)
|
||||
orkinRowCellCursor(morkEnv* ev, // note morkUsage is always morkUsage_kPool
|
||||
morkHandleFace* ioFace, // must not be nil, cookie for this handle
|
||||
morkRowCellCursor* ioObject); // must not be nil, the object for this handle
|
||||
|
||||
// void CloseHandle(morkEnv* ev); // don't need to specialize closing
|
||||
|
||||
private: // copying is not allowed
|
||||
orkinRowCellCursor(const morkHandle& other);
|
||||
orkinRowCellCursor& operator=(const morkHandle& other);
|
||||
|
||||
// public: // dynamic type identification
|
||||
// mork_bool IsHandle() const //
|
||||
// { return IsNode() && mNode_Derived == morkDerived_kHandle; }
|
||||
// } ===== end morkNode methods =====
|
||||
|
||||
protected: // morkHandle memory management operators
|
||||
void* operator new(size_t inSize, morkPool& ioPool, morkZone& ioZone, morkEnv* ev) CPP_THROW_NEW
|
||||
{ return ioPool.NewHandle(ev, inSize, &ioZone); }
|
||||
|
||||
void* operator new(size_t inSize, morkPool& ioPool, morkEnv* ev) CPP_THROW_NEW
|
||||
{ return ioPool.NewHandle(ev, inSize, (morkZone*) 0); }
|
||||
|
||||
void* operator new(size_t inSize, morkHandleFace* ioFace) CPP_THROW_NEW
|
||||
{ MORK_USED_1(inSize); return ioFace; }
|
||||
|
||||
public: // construction:
|
||||
|
||||
static orkinRowCellCursor* MakeRowCellCursor(morkEnv* ev,
|
||||
morkRowCellCursor* ioObject);
|
||||
|
||||
public: // utilities:
|
||||
|
||||
morkEnv* CanUseRowCellCursor(nsIMdbEnv* mev, mork_bool inMutable,
|
||||
mdb_err* outErr, morkRow** outRow) const;
|
||||
|
||||
public: // type identification
|
||||
mork_bool IsOrkinRowCellCursor() const
|
||||
{ return mHandle_Magic == morkMagic_kRowCellCursor; }
|
||||
|
||||
mork_bool IsOrkinRowCellCursorHandle() const
|
||||
{ return this->IsHandle() && this->IsOrkinRowCellCursor(); }
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
// { ===== begin nsIMdbObject methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
NS_IMETHOD IsFrozenMdbObject(nsIMdbEnv* ev, mdb_bool* outIsReadonly);
|
||||
// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin factory methods -----
|
||||
NS_IMETHOD GetMdbFactory(nsIMdbEnv* ev, nsIMdbFactory** acqFactory);
|
||||
// } ----- end factory methods -----
|
||||
|
||||
// { ----- begin ref counting for well-behaved cyclic graphs -----
|
||||
NS_IMETHOD GetWeakRefCount(nsIMdbEnv* ev, // weak refs
|
||||
mdb_count* outCount);
|
||||
NS_IMETHOD GetStrongRefCount(nsIMdbEnv* ev, // strong refs
|
||||
mdb_count* outCount);
|
||||
|
||||
NS_IMETHOD AddWeakRef(nsIMdbEnv* ev);
|
||||
NS_IMETHOD AddStrongRef(nsIMdbEnv* ev);
|
||||
|
||||
NS_IMETHOD CutWeakRef(nsIMdbEnv* ev);
|
||||
NS_IMETHOD CutStrongRef(nsIMdbEnv* ev);
|
||||
|
||||
NS_IMETHOD CloseMdbObject(nsIMdbEnv* ev); // called at strong refs zero
|
||||
NS_IMETHOD IsOpenMdbObject(nsIMdbEnv* ev, mdb_bool* outOpen);
|
||||
// } ----- end ref counting -----
|
||||
|
||||
// } ===== end nsIMdbObject methods =====
|
||||
|
||||
// { ===== begin nsIMdbCursor methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
NS_IMETHOD GetCount(nsIMdbEnv* ev, mdb_count* outCount); // readonly
|
||||
NS_IMETHOD GetSeed(nsIMdbEnv* ev, mdb_seed* outSeed); // readonly
|
||||
|
||||
NS_IMETHOD SetPos(nsIMdbEnv* ev, mdb_pos inPos); // mutable
|
||||
NS_IMETHOD GetPos(nsIMdbEnv* ev, mdb_pos* outPos);
|
||||
|
||||
NS_IMETHOD SetDoFailOnSeedOutOfSync(nsIMdbEnv* ev, mdb_bool inFail);
|
||||
NS_IMETHOD GetDoFailOnSeedOutOfSync(nsIMdbEnv* ev, mdb_bool* outFail);
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// } ===== end nsIMdbCursor methods =====
|
||||
|
||||
// { ===== begin nsIMdbRowCellCursor methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
NS_IMETHOD SetRow(nsIMdbEnv* ev, nsIMdbRow* ioRow); // sets pos to -1
|
||||
NS_IMETHOD GetRow(nsIMdbEnv* ev, nsIMdbRow** acqRow);
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin cell creation methods -----
|
||||
NS_IMETHOD MakeCell( // get cell at current pos in the row
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_column* outColumn, // column for this particular cell
|
||||
mdb_pos* outPos, // position of cell in row sequence
|
||||
nsIMdbCell** acqCell); // the cell at inPos
|
||||
// } ----- end cell creation methods -----
|
||||
|
||||
// { ----- begin cell seeking methods -----
|
||||
NS_IMETHOD SeekCell( // same as SetRow() followed by MakeCell()
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_pos inPos, // position of cell in row sequence
|
||||
mdb_column* outColumn, // column for this particular cell
|
||||
nsIMdbCell** acqCell); // the cell at inPos
|
||||
// } ----- end cell seeking methods -----
|
||||
|
||||
// { ----- begin cell iteration methods -----
|
||||
NS_IMETHOD NextCell( // get next cell in the row
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbCell* ioCell, // changes to the next cell in the iteration
|
||||
mdb_column* outColumn, // column for this particular cell
|
||||
mdb_pos* outPos); // position of cell in row sequence
|
||||
|
||||
NS_IMETHOD PickNextCell( // get next cell in row within filter set
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbCell* ioCell, // changes to the next cell in the iteration
|
||||
const mdbColumnSet* inFilterSet, // col set of actual caller interest
|
||||
mdb_column* outColumn, // column for this particular cell
|
||||
mdb_pos* outPos); // position of cell in row sequence
|
||||
|
||||
// Note that inFilterSet should not have too many (many more than 10?)
|
||||
// cols, since this might imply a potential excessive consumption of time
|
||||
// over many cursor calls when looking for column and filter intersection.
|
||||
// } ----- end cell iteration methods -----
|
||||
|
||||
// } ===== end nsIMdbRowCellCursor methods =====
|
||||
};
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
#endif /* _ORKINROWCELLCURSOR_ */
|
@ -1,457 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _MDB_
|
||||
#include "mdb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORK_
|
||||
#include "mork.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKNODE_
|
||||
#include "morkNode.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKHANDLE_
|
||||
#include "morkHandle.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKSORTING_
|
||||
#include "morkSorting.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKTABLE_
|
||||
#include "morkTable.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKENV_
|
||||
#include "morkEnv.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINTABLE_
|
||||
#include "orkinTable.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINSORTING_
|
||||
#include "orkinSorting.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINROW_
|
||||
#include "orkinRow.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKTABLEROWCURSOR_
|
||||
#include "morkTableRowCursor.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINTABLEROWCURSOR_
|
||||
#include "orkinTableRowCursor.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKROWSPACE_
|
||||
#include "morkRowSpace.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKSTORE_
|
||||
#include "morkStore.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINSTORE_
|
||||
#include "orkinStore.h"
|
||||
#endif
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
/* public virtual*/
|
||||
orkinSorting:: ~orkinSorting() // morkHandle destructor does everything
|
||||
{
|
||||
}
|
||||
|
||||
/*protected non-poly construction*/
|
||||
orkinSorting::orkinSorting(morkEnv* ev, // morkUsage is morkUsage_kPool
|
||||
morkHandleFace* ioFace, // must not be nil, cookie for this handle
|
||||
morkSorting* ioObject) // must not be nil, the object for this handle
|
||||
: morkHandle(ev, ioFace, ioObject, morkMagic_kSorting)
|
||||
{
|
||||
// do not modify mNode_Derived; leave it equal to morkDerived_kHandle
|
||||
}
|
||||
|
||||
|
||||
/*static */ orkinSorting*
|
||||
orkinSorting::MakeSorting(morkEnv* ev, morkSorting* ioObject)
|
||||
{
|
||||
mork_bool isEnv = ev->IsEnv();
|
||||
MORK_ASSERT(isEnv);
|
||||
if ( isEnv )
|
||||
{
|
||||
morkHandleFace* face = ev->NewHandle(sizeof(orkinSorting));
|
||||
if ( face )
|
||||
return new(face) orkinSorting(ev, face, ioObject);
|
||||
else
|
||||
ev->OutOfMemoryError();
|
||||
}
|
||||
|
||||
return (orkinSorting*) 0;
|
||||
}
|
||||
|
||||
morkEnv*
|
||||
orkinSorting::CanUseSorting(nsIMdbEnv* mev,
|
||||
mork_bool inMutable, mdb_err* outErr) const
|
||||
{
|
||||
morkEnv* outEnv = 0;
|
||||
morkEnv* ev = morkEnv::FromMdbEnv(mev);
|
||||
if ( ev )
|
||||
{
|
||||
morkSorting* self = (morkSorting*)
|
||||
this->GetGoodHandleObject(ev, inMutable, morkMagic_kSorting,
|
||||
/*inClosedOkay*/ morkBool_kFalse);
|
||||
if ( self )
|
||||
{
|
||||
if ( self->IsSorting() )
|
||||
outEnv = ev;
|
||||
else
|
||||
self->NonSortingTypeError(ev);
|
||||
}
|
||||
*outErr = ev->AsErr();
|
||||
}
|
||||
MORK_ASSERT(outEnv);
|
||||
return outEnv;
|
||||
}
|
||||
|
||||
|
||||
// { ===== begin nsIMdbISupports methods =====
|
||||
NS_IMPL_QUERY_INTERFACE0(orkinSorting)
|
||||
|
||||
/*virtual*/ nsrefcnt
|
||||
orkinSorting::AddRef() // add strong ref with no
|
||||
{
|
||||
morkEnv* ev = mHandle_Env;
|
||||
if ( ev && ev->IsEnv() )
|
||||
return this->Handle_AddStrongRef(ev->AsMdbEnv());
|
||||
else
|
||||
return morkEnv_kNonEnvTypeError;
|
||||
}
|
||||
|
||||
/*virtual*/ nsrefcnt
|
||||
orkinSorting::Release() // cut strong ref
|
||||
{
|
||||
morkEnv* ev = mHandle_Env;
|
||||
if ( ev && ev->IsEnv() )
|
||||
return this->Handle_CutStrongRef(ev->AsMdbEnv());
|
||||
else
|
||||
return morkEnv_kNonEnvTypeError;
|
||||
}
|
||||
// } ===== end nsIMdbISupports methods =====
|
||||
|
||||
// { ===== begin nsIMdbObject methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinSorting::IsFrozenMdbObject(nsIMdbEnv* mev, mdb_bool* outIsReadonly)
|
||||
{
|
||||
return this->Handle_IsFrozenMdbObject(mev, outIsReadonly);
|
||||
}
|
||||
// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin factory methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinSorting::GetMdbFactory(nsIMdbEnv* mev, nsIMdbFactory** acqFactory)
|
||||
{
|
||||
return this->Handle_GetMdbFactory(mev, acqFactory);
|
||||
}
|
||||
// } ----- end factory methods -----
|
||||
|
||||
// { ----- begin ref counting for well-behaved cyclic graphs -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinSorting::GetWeakRefCount(nsIMdbEnv* mev, // weak refs
|
||||
mdb_count* outCount)
|
||||
{
|
||||
return this->Handle_GetWeakRefCount(mev, outCount);
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinSorting::GetStrongRefCount(nsIMdbEnv* mev, // strong refs
|
||||
mdb_count* outCount)
|
||||
{
|
||||
return this->Handle_GetStrongRefCount(mev, outCount);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinSorting::AddWeakRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_AddWeakRef(mev);
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinSorting::AddStrongRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_AddStrongRef(mev);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinSorting::CutWeakRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_CutWeakRef(mev);
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinSorting::CutStrongRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_CutStrongRef(mev);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinSorting::CloseMdbObject(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_CloseMdbObject(mev);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinSorting::IsOpenMdbObject(nsIMdbEnv* mev, mdb_bool* outOpen)
|
||||
{
|
||||
return this->Handle_IsOpenMdbObject(mev, outOpen);
|
||||
}
|
||||
// } ----- end ref counting -----
|
||||
|
||||
// } ===== end nsIMdbObject methods =====
|
||||
|
||||
|
||||
// { ===== begin nsIMdbSorting methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinSorting::GetTable(nsIMdbEnv* mev, nsIMdbTable** acqTable)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbTable* outTable = 0;
|
||||
morkEnv* ev = this->CanUseSorting(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkSorting* sorting = (morkSorting*) mHandle_Object;
|
||||
morkTable* table = sorting->mSorting_Table;
|
||||
if ( table && ev->Good() )
|
||||
{
|
||||
outTable = table->AcquireTableHandle(ev);
|
||||
}
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( acqTable )
|
||||
*acqTable = outTable;
|
||||
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinSorting::GetSortColumn( // query which col is currently sorted
|
||||
nsIMdbEnv* mev, // context
|
||||
mdb_column* outColumn) // col the table uses for sorting (or zero)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mdb_column col = 0;
|
||||
morkEnv* ev = this->CanUseSorting(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkSorting* sorting = (morkSorting*) mHandle_Object;
|
||||
col = sorting->mSorting_Col;
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( outColumn )
|
||||
*outColumn = col;
|
||||
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinSorting::SetNewCompare(nsIMdbEnv* mev,
|
||||
nsIMdbCompare* ioNewCompare)
|
||||
// Setting the sorting's compare object will typically cause the rows
|
||||
// to be resorted, presumably in a lazy fashion when the sorting is
|
||||
// next required to be in a valid row ordering state, such as when a
|
||||
// call to PosToOid() happens. ioNewCompare can be nil, in which case
|
||||
// implementations should revert to the default sort order, which must
|
||||
// be equivalent to whatever is used by nsIMdbFactory::MakeCompare().
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkEnv* ev = this->CanUseSorting(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
if ( ioNewCompare )
|
||||
{
|
||||
morkSorting* sorting = (morkSorting*) mHandle_Object;
|
||||
nsIMdbCompare_SlotStrongCompare(ioNewCompare, ev,
|
||||
&sorting->mSorting_Compare);
|
||||
}
|
||||
else
|
||||
ev->NilPointerError();
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinSorting::GetOldCompare(nsIMdbEnv* mev,
|
||||
nsIMdbCompare** acqOldCompare)
|
||||
// Get this sorting instance's compare object, which handles the
|
||||
// ordering of rows in the sorting, by comparing yarns from the cells
|
||||
// in the column being sorted. Since nsIMdbCompare has no interface
|
||||
// to query the state of the compare object, it is not clear what you
|
||||
// would do with this object when returned, except maybe compare it
|
||||
// as a pointer address to some other instance, to check identities.
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbCompare* outCompare = 0;
|
||||
morkEnv* ev = this->CanUseSorting(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkSorting* sorting = (morkSorting*) mHandle_Object;
|
||||
nsIMdbCompare* compare = sorting->mSorting_Compare;
|
||||
if ( compare && ev->Good() )
|
||||
{
|
||||
compare->AddStrongRef(mev);
|
||||
|
||||
if ( ev->Good() )
|
||||
outCompare = compare;
|
||||
}
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( acqOldCompare )
|
||||
*acqOldCompare = outCompare;
|
||||
|
||||
return outErr;
|
||||
}
|
||||
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
|
||||
// { ----- begin cursor methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinSorting::GetSortingRowCursor( // make a cursor, starting at inRowPos
|
||||
nsIMdbEnv* mev, // context
|
||||
mdb_pos inRowPos, // zero-based ordinal position of row in table
|
||||
nsIMdbTableRowCursor** acqCursor) // acquire new cursor instance
|
||||
// A cursor interface turning same info as PosToOid() or PosToRow().
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbTableRowCursor* outCursor = 0;
|
||||
morkEnv* ev = this->CanUseSorting(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkSortingRowCursor* cursor =
|
||||
((morkSorting*) mHandle_Object)->NewSortingRowCursor(ev, inRowPos);
|
||||
if ( cursor )
|
||||
{
|
||||
// $$$$$
|
||||
// if ( ev->Good() )
|
||||
// {
|
||||
// outCursor = cursor->AcquireSortingRowCursorHandle(ev);
|
||||
// }
|
||||
// else
|
||||
// cursor->CutStrongRef(ev);
|
||||
}
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( acqCursor )
|
||||
*acqCursor = outCursor;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
// } ----- end row position methods -----
|
||||
|
||||
// { ----- begin row position methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinSorting::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 = (mork_id) -1;
|
||||
|
||||
morkEnv* ev = this->CanUseSorting(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkSorting* sorting = (morkSorting*) mHandle_Object;
|
||||
morkRow* row = sorting->SafeRowAt(ev, inRowPos);
|
||||
if ( row )
|
||||
roid = row->mRow_Oid;
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( outOid )
|
||||
*outOid = roid;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinSorting::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->CanUseSorting(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkSorting* sorting = (morkSorting*) mHandle_Object;
|
||||
morkStore* store = sorting->mSorting_Table->mTable_Store;
|
||||
morkRow* row = sorting->SafeRowAt(ev, inRowPos);
|
||||
if ( row && store )
|
||||
outRow = row->AcquireRowHandle(ev, store);
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( acqRow )
|
||||
*acqRow = outRow;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
// Note that HasRow() performs the inverse oid->pos mapping
|
||||
// } ----- end row position methods -----
|
||||
|
||||
|
||||
// } ===== end nsIMdbSorting methods =====
|
||||
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
@ -1,204 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _ORKINSORTING_
|
||||
#define _ORKINSORTING_ 1
|
||||
|
||||
#ifndef _MDB_
|
||||
#include "mdb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORK_
|
||||
#include "mork.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKNODE_
|
||||
#include "morkNode.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKHANDLE_
|
||||
#include "morkHandle.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKSORTING_
|
||||
#include "morkSorting.h"
|
||||
#endif
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
#define morkMagic_kSorting 0x536F7274 /* ascii 'Sort' */
|
||||
|
||||
/*| orkinSorting:
|
||||
|*/
|
||||
class orkinSorting : public morkHandle, public nsIMdbSorting { // nsIMdbSorting
|
||||
|
||||
// { ===== begin morkNode interface =====
|
||||
public: // morkNode virtual methods
|
||||
// virtual void CloseMorkNode(morkEnv* ev); // morkHandle is fine
|
||||
virtual ~orkinSorting(); // morkHandle destructor does everything
|
||||
|
||||
protected: // construction is protected (use the static Make() method)
|
||||
orkinSorting(morkEnv* ev, // note morkUsage is always morkUsage_kPool
|
||||
morkHandleFace* ioFace, // must not be nil, cookie for this handle
|
||||
morkSorting* ioObject); // must not be nil, the object for this handle
|
||||
|
||||
// void CloseHandle(morkEnv* ev); // don't need to specialize closing
|
||||
|
||||
private: // copying is not allowed
|
||||
orkinSorting(const orkinSorting& other);
|
||||
orkinSorting& operator=(const orkinSorting& other);
|
||||
|
||||
// public: // dynamic type identification
|
||||
// mork_bool IsHandle() const //
|
||||
// { return IsNode() && mNode_Derived == morkDerived_kHandle; }
|
||||
// } ===== end morkNode methods =====
|
||||
|
||||
protected: // morkHandle memory management operators
|
||||
void* operator new(size_t inSize, morkPool& ioPool, morkZone& ioZone, morkEnv* ev) CPP_THROW_NEW
|
||||
{ return ioPool.NewHandle(ev, inSize, &ioZone); }
|
||||
|
||||
void* operator new(size_t inSize, morkPool& ioPool, morkEnv* ev) CPP_THROW_NEW
|
||||
{ return ioPool.NewHandle(ev, inSize, (morkZone*) 0); }
|
||||
|
||||
void* operator new(size_t inSize, morkHandleFace* ioFace) CPP_THROW_NEW
|
||||
{ MORK_USED_1(inSize); return ioFace; }
|
||||
|
||||
|
||||
public: // construction:
|
||||
|
||||
static orkinSorting* MakeSorting(morkEnv* ev, morkSorting* ioObject);
|
||||
|
||||
public: // utilities:
|
||||
|
||||
morkEnv* CanUseSorting(nsIMdbEnv* mev, mork_bool inMutable,
|
||||
mdb_err* outErr) const;
|
||||
|
||||
public: // type identification
|
||||
mork_bool IsOrkinSorting() const
|
||||
{ return mHandle_Magic == morkMagic_kSorting; }
|
||||
|
||||
mork_bool IsOrkinSortingHandle() const
|
||||
{ return this->IsHandle() && this->IsOrkinSorting(); }
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
// { ===== begin nsIMdbObject methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
NS_IMETHOD IsFrozenMdbObject(nsIMdbEnv* ev, mdb_bool* outIsReadonly);
|
||||
// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin factory methods -----
|
||||
NS_IMETHOD GetMdbFactory(nsIMdbEnv* ev, nsIMdbFactory** acqFactory);
|
||||
// } ----- end factory methods -----
|
||||
|
||||
// { ----- begin ref counting for well-behaved cyclic graphs -----
|
||||
NS_IMETHOD GetWeakRefCount(nsIMdbEnv* ev, // weak refs
|
||||
mdb_count* outCount);
|
||||
NS_IMETHOD GetStrongRefCount(nsIMdbEnv* ev, // strong refs
|
||||
mdb_count* outCount);
|
||||
|
||||
NS_IMETHOD AddWeakRef(nsIMdbEnv* ev);
|
||||
NS_IMETHOD AddStrongRef(nsIMdbEnv* ev);
|
||||
|
||||
NS_IMETHOD CutWeakRef(nsIMdbEnv* ev);
|
||||
NS_IMETHOD CutStrongRef(nsIMdbEnv* ev);
|
||||
|
||||
NS_IMETHOD CloseMdbObject(nsIMdbEnv* ev); // called at strong refs zero
|
||||
NS_IMETHOD IsOpenMdbObject(nsIMdbEnv* ev, mdb_bool* outOpen);
|
||||
// } ----- end ref counting -----
|
||||
|
||||
// } ===== end nsIMdbObject methods =====
|
||||
|
||||
// { ===== begin nsIMdbSorting methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
// sorting: note all rows are assumed sorted by row ID as a secondary
|
||||
// sort following the primary column sort, when table rows are sorted.
|
||||
|
||||
NS_IMETHOD GetTable(nsIMdbEnv* ev, nsIMdbTable** acqTable);
|
||||
NS_IMETHOD GetSortColumn( // query which col is currently sorted
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_column* outColumn); // col the table uses for sorting (or zero)
|
||||
|
||||
NS_IMETHOD SetNewCompare(nsIMdbEnv* ev,
|
||||
nsIMdbCompare* ioNewCompare);
|
||||
// Setting the sorting's compare object will typically cause the rows
|
||||
// to be resorted, presumably in a lazy fashion when the sorting is
|
||||
// next required to be in a valid row ordering state, such as when a
|
||||
// call to PosToOid() happens. ioNewCompare can be nil, in which case
|
||||
// implementations should revert to the default sort order, which must
|
||||
// be equivalent to whatever is used by nsIMdbFactory::MakeCompare().
|
||||
|
||||
NS_IMETHOD GetOldCompare(nsIMdbEnv* ev,
|
||||
nsIMdbCompare** acqOldCompare);
|
||||
// Get this sorting instance's compare object, which handles the
|
||||
// ordering of rows in the sorting, by comparing yarns from the cells
|
||||
// in the column being sorted. Since nsIMdbCompare has no interface
|
||||
// to query the state of the compare object, it is not clear what you
|
||||
// would do with this object when returned, except maybe compare it
|
||||
// as a pointer address to some other instance, to check identities.
|
||||
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin cursor methods -----
|
||||
NS_IMETHOD GetSortingRowCursor( // make a cursor, starting at inRowPos
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_pos inRowPos, // zero-based ordinal position of row in table
|
||||
nsIMdbTableRowCursor** acqCursor); // acquire new cursor instance
|
||||
// A cursor interface turning same info as PosToOid() or PosToRow().
|
||||
// } ----- end row position methods -----
|
||||
|
||||
// { ----- begin row position methods -----
|
||||
NS_IMETHOD 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
|
||||
|
||||
NS_IMETHOD 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
|
||||
// } ----- end row position methods -----
|
||||
|
||||
// } ===== end nsIMdbSorting methods =====
|
||||
|
||||
};
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
#endif /* _ORKINSORTING_ */
|
File diff suppressed because it is too large
Load Diff
@ -1,505 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _ORKINSTORE_
|
||||
#define _ORKINSTORE_ 1
|
||||
|
||||
#ifndef _MDB_
|
||||
#include "mdb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORK_
|
||||
#include "mork.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKNODE_
|
||||
#include "morkNode.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKHANDLE_
|
||||
#include "morkHandle.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKStore_
|
||||
#include "morkStore.h"
|
||||
#endif
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
#define morkMagic_kStore 0x53746F72 /* ascii 'Stor' */
|
||||
|
||||
/*| orkinStore:
|
||||
|*/
|
||||
class orkinStore : public morkHandle, public nsIMdbStore { // nsIMdbPort
|
||||
|
||||
// { ===== begin morkNode interface =====
|
||||
public: // morkNode virtual methods
|
||||
// virtual void CloseMorkNode(morkEnv* ev); // morkHandle is fine
|
||||
virtual ~orkinStore(); // morkHandle destructor does everything
|
||||
|
||||
protected: // construction is protected (use the static Make() method)
|
||||
orkinStore(morkEnv* ev, // note morkUsage is always morkUsage_kPool
|
||||
morkHandleFace* ioFace, // must not be nil, cookie for this handle
|
||||
morkStore* ioObject); // must not be nil, the object for this handle
|
||||
|
||||
// void CloseHandle(morkEnv* ev); // don't need to specialize closing
|
||||
|
||||
private: // copying is not allowed
|
||||
orkinStore(const morkHandle& other);
|
||||
orkinStore& operator=(const morkHandle& other);
|
||||
|
||||
// public: // dynamic type identification
|
||||
// mork_bool IsHandle() const //
|
||||
// { return IsNode() && mNode_Derived == morkDerived_kHandle; }
|
||||
// } ===== end morkNode methods =====
|
||||
|
||||
protected: // morkHandle memory management operators
|
||||
void* operator new(size_t inSize, morkPool& ioPool, morkZone& ioZone, morkEnv* ev) CPP_THROW_NEW
|
||||
{ return ioPool.NewHandle(ev, inSize, &ioZone); }
|
||||
|
||||
void* operator new(size_t inSize, morkPool& ioPool, morkEnv* ev) CPP_THROW_NEW
|
||||
{ return ioPool.NewHandle(ev, inSize, (morkZone*) 0); }
|
||||
|
||||
void* operator new(size_t inSize, morkHandleFace* ioFace) CPP_THROW_NEW
|
||||
{ MORK_USED_1(inSize); return ioFace; }
|
||||
|
||||
|
||||
public: // construction:
|
||||
|
||||
static orkinStore* MakeStore(morkEnv* ev, morkStore* ioObject);
|
||||
|
||||
public: // utilities:
|
||||
|
||||
morkEnv* CanUseStore(nsIMdbEnv* mev, mork_bool inMutable,
|
||||
mdb_err* outErr) const;
|
||||
|
||||
public: // type identification
|
||||
mork_bool IsOrkinStore() const
|
||||
{ return mHandle_Magic == morkMagic_kStore; }
|
||||
|
||||
mork_bool IsOrkinStoreHandle() const
|
||||
{ return this->IsHandle() && this->IsOrkinStore(); }
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
// { ===== begin nsIMdbObject methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
NS_IMETHOD IsFrozenMdbObject(nsIMdbEnv* ev, mdb_bool* outIsReadonly);
|
||||
// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin factory methods -----
|
||||
NS_IMETHOD GetMdbFactory(nsIMdbEnv* ev, nsIMdbFactory** acqFactory);
|
||||
// } ----- end factory methods -----
|
||||
|
||||
// { ----- begin ref counting for well-behaved cyclic graphs -----
|
||||
NS_IMETHOD GetWeakRefCount(nsIMdbEnv* ev, // weak refs
|
||||
mdb_count* outCount);
|
||||
NS_IMETHOD GetStrongRefCount(nsIMdbEnv* ev, // strong refs
|
||||
mdb_count* outCount);
|
||||
|
||||
NS_IMETHOD AddWeakRef(nsIMdbEnv* ev);
|
||||
NS_IMETHOD AddStrongRef(nsIMdbEnv* ev);
|
||||
|
||||
NS_IMETHOD CutWeakRef(nsIMdbEnv* ev);
|
||||
NS_IMETHOD CutStrongRef(nsIMdbEnv* ev);
|
||||
|
||||
NS_IMETHOD CloseMdbObject(nsIMdbEnv* ev); // called at strong refs zero
|
||||
NS_IMETHOD IsOpenMdbObject(nsIMdbEnv* ev, mdb_bool* outOpen);
|
||||
// } ----- end ref counting -----
|
||||
|
||||
// } ===== end nsIMdbObject methods =====
|
||||
|
||||
// { ===== begin nsIMdbPort methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
NS_IMETHOD GetIsPortReadonly(nsIMdbEnv* ev, mdb_bool* outBool);
|
||||
NS_IMETHOD GetIsStore(nsIMdbEnv* ev, mdb_bool* outBool);
|
||||
NS_IMETHOD GetIsStoreAndDirty(nsIMdbEnv* ev, mdb_bool* outBool);
|
||||
|
||||
NS_IMETHOD GetUsagePolicy(nsIMdbEnv* ev,
|
||||
mdbUsagePolicy* ioUsagePolicy);
|
||||
|
||||
NS_IMETHOD SetUsagePolicy(nsIMdbEnv* ev,
|
||||
const mdbUsagePolicy* inUsagePolicy);
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin memory policy methods -----
|
||||
NS_IMETHOD IdleMemoryPurge( // do memory management already scheduled
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_size* outEstimatedBytesFreed); // approximate bytes actually freed
|
||||
|
||||
NS_IMETHOD SessionMemoryPurge( // request specific footprint decrease
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_size inDesiredBytesFreed, // approximate number of bytes wanted
|
||||
mdb_size* outEstimatedBytesFreed); // approximate bytes actually freed
|
||||
|
||||
NS_IMETHOD PanicMemoryPurge( // desperately free all possible memory
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_size* outEstimatedBytesFreed); // approximate bytes actually freed
|
||||
// } ----- end memory policy methods -----
|
||||
|
||||
// { ----- begin filepath methods -----
|
||||
NS_IMETHOD GetPortFilePath(
|
||||
nsIMdbEnv* ev, // context
|
||||
mdbYarn* outFilePath, // name of file holding port content
|
||||
mdbYarn* outFormatVersion); // file format description
|
||||
|
||||
NS_IMETHOD GetPortFile(
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbFile** acqFile); // acquire file used by port or store
|
||||
// } ----- end filepath methods -----
|
||||
|
||||
// { ----- begin export methods -----
|
||||
NS_IMETHOD BestExportFormat( // determine preferred export format
|
||||
nsIMdbEnv* ev, // context
|
||||
mdbYarn* outFormatVersion); // file format description
|
||||
|
||||
NS_IMETHOD
|
||||
CanExportToFormat( // can export content in given specific format?
|
||||
nsIMdbEnv* ev, // context
|
||||
const char* inFormatVersion, // file format description
|
||||
mdb_bool* outCanExport); // whether ExportSource() might succeed
|
||||
|
||||
NS_IMETHOD ExportToFormat( // export content in given specific format
|
||||
nsIMdbEnv* ev, // context
|
||||
// const char* inFilePath, // the file to receive exported content
|
||||
nsIMdbFile* ioFile, // destination abstract file interface
|
||||
const char* inFormatVersion, // file format description
|
||||
nsIMdbThumb** acqThumb); // acquire thumb for incremental export
|
||||
// Call nsIMdbThumb::DoMore() until done, or until the thumb is broken, and
|
||||
// then the export will be finished.
|
||||
|
||||
// } ----- end export methods -----
|
||||
|
||||
// { ----- begin token methods -----
|
||||
NS_IMETHOD TokenToString( // return a string name for an integer token
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_token inToken, // token for inTokenName inside this port
|
||||
mdbYarn* outTokenName); // the type of table to access
|
||||
|
||||
NS_IMETHOD StringToToken( // return an integer token for scope name
|
||||
nsIMdbEnv* ev, // context
|
||||
const char* inTokenName, // Latin1 string to tokenize if possible
|
||||
mdb_token* outToken); // token for inTokenName inside this port
|
||||
|
||||
// String token zero is never used and never supported. If the port
|
||||
// is a mutable store, then StringToToken() to create a new
|
||||
// association of inTokenName with a new integer token if possible.
|
||||
// But a readonly port will return zero for an unknown scope name.
|
||||
|
||||
NS_IMETHOD QueryToken( // like StringToToken(), but without adding
|
||||
nsIMdbEnv* ev, // context
|
||||
const char* inTokenName, // Latin1 string to tokenize if possible
|
||||
mdb_token* outToken); // token for inTokenName inside this port
|
||||
|
||||
// QueryToken() will return a string token if one already exists,
|
||||
// but unlike StringToToken(), will not assign a new token if not
|
||||
// already in use.
|
||||
|
||||
// } ----- end token methods -----
|
||||
|
||||
// { ----- begin row methods -----
|
||||
NS_IMETHOD HasRow( // contains a row with the specified oid?
|
||||
nsIMdbEnv* ev, // context
|
||||
const mdbOid* inOid, // hypothetical row oid
|
||||
mdb_bool* outHasRow); // whether GetRow() might succeed
|
||||
|
||||
NS_IMETHOD GetRowRefCount( // get number of tables that contain a row
|
||||
nsIMdbEnv* ev, // context
|
||||
const mdbOid* inOid, // hypothetical row oid
|
||||
mdb_count* outRefCount); // number of tables containing inRowKey
|
||||
|
||||
NS_IMETHOD GetRow( // access one row with specific oid
|
||||
nsIMdbEnv* ev, // context
|
||||
const mdbOid* inOid, // hypothetical row oid
|
||||
nsIMdbRow** acqRow); // acquire specific row (or null)
|
||||
|
||||
NS_IMETHOD FindRow(nsIMdbEnv* ev, // search for row with matching cell
|
||||
mdb_scope inRowScope, // row scope for row ids
|
||||
mdb_column inColumn, // the column to search (and maintain an index)
|
||||
const mdbYarn* inTargetCellValue, // cell value for which to search
|
||||
mdbOid* outRowOid, // out row oid on match (or {0,-1} for no match)
|
||||
nsIMdbRow** acqRow); // acquire matching row (or nil for no match)
|
||||
// FindRow() searches for one row that has a cell in column inColumn with
|
||||
// a contained value with the same form (i.e. charset) and is byte-wise
|
||||
// identical to the blob described by yarn inTargetCellValue. Both content
|
||||
// and form of the yarn must be an exact match to find a matching row.
|
||||
//
|
||||
// (In other words, both a yarn's blob bytes and form are significant. The
|
||||
// form is not expected to vary in columns used for identity anyway. This
|
||||
// is intended to make the cost of FindRow() cheaper for MDB implementors,
|
||||
// since any cell value atomization performed internally must necessarily
|
||||
// make yarn form significant in order to avoid data loss in atomization.)
|
||||
//
|
||||
// FindRow() can lazily create an index on attribute inColumn for all rows
|
||||
// with that attribute in row space scope inRowScope, so that subsequent
|
||||
// calls to FindRow() will perform faster. Such an index might or might
|
||||
// not be persistent (but this seems desirable if it is cheap to do so).
|
||||
// Note that lazy index creation in readonly DBs is not very feasible.
|
||||
//
|
||||
// This FindRow() interface assumes that attribute inColumn is effectively
|
||||
// an alternative means of unique identification for a row in a rowspace,
|
||||
// so correct behavior is only guaranteed when no duplicates for this col
|
||||
// appear in the given set of rows. (If more than one row has the same cell
|
||||
// value in this column, no more than one will be found; and cutting one of
|
||||
// two duplicate rows can cause the index to assume no other such row lives
|
||||
// in the row space, so future calls return nil for negative search results
|
||||
// even though some duplicate row might still live within the rowspace.)
|
||||
//
|
||||
// In other words, the FindRow() implementation is allowed to assume simple
|
||||
// hash tables mapping unqiue column keys to associated row values will be
|
||||
// sufficient, where any duplication is not recorded because only one copy
|
||||
// of a given key need be remembered. Implementors are not required to sort
|
||||
// all rows by the specified column.
|
||||
// } ----- end row methods -----
|
||||
|
||||
// { ----- begin table methods -----
|
||||
NS_IMETHOD HasTable( // supports a table with the specified oid?
|
||||
nsIMdbEnv* ev, // context
|
||||
const mdbOid* inOid, // hypothetical table oid
|
||||
mdb_bool* outHasTable); // whether GetTable() might succeed
|
||||
|
||||
NS_IMETHOD GetTable( // access one table with specific oid
|
||||
nsIMdbEnv* ev, // context
|
||||
const mdbOid* inOid, // hypothetical table oid
|
||||
nsIMdbTable** acqTable); // acquire specific table (or null)
|
||||
|
||||
NS_IMETHOD HasTableKind( // supports a table of the specified type?
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_scope inRowScope, // rid scope for row ids
|
||||
mdb_kind inTableKind, // the type of table to access
|
||||
mdb_count* outTableCount, // current number of such tables
|
||||
mdb_bool* outSupportsTable); // whether GetTableKind() might succeed
|
||||
|
||||
NS_IMETHOD GetTableKind( // access one (random) table of specific type
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_scope inRowScope, // row scope for row ids
|
||||
mdb_kind inTableKind, // the type of table to access
|
||||
mdb_count* outTableCount, // current number of such tables
|
||||
mdb_bool* outMustBeUnique, // whether port can hold only one of these
|
||||
nsIMdbTable** acqTable); // acquire scoped collection of rows
|
||||
|
||||
NS_IMETHOD
|
||||
GetPortTableCursor( // get cursor for all tables of specific type
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_scope inRowScope, // row scope for row ids
|
||||
mdb_kind inTableKind, // the type of table to access
|
||||
nsIMdbPortTableCursor** acqCursor); // all such tables in the port
|
||||
// } ----- end table methods -----
|
||||
|
||||
|
||||
// { ----- begin commit methods -----
|
||||
|
||||
NS_IMETHOD ShouldCompress( // store wastes at least inPercentWaste?
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_percent inPercentWaste, // 0..100 percent file size waste threshold
|
||||
mdb_percent* outActualWaste, // 0..100 percent of file actually wasted
|
||||
mdb_bool* outShould); // true when about inPercentWaste% is wasted
|
||||
// ShouldCompress() returns true if the store can determine that the file
|
||||
// will shrink by an estimated percentage of inPercentWaste% (or more) if
|
||||
// CompressCommit() is called, because that percentage of the file seems
|
||||
// to be recoverable free space. The granularity is only in terms of
|
||||
// percentage points, and any value over 100 is considered equal to 100.
|
||||
//
|
||||
// If a store only has an approximate idea how much space might be saved
|
||||
// during a compress, then a best guess should be made. For example, the
|
||||
// Mork implementation might keep track of how much file space began with
|
||||
// text content before the first updating transaction, and then consider
|
||||
// all content following the start of the first transaction as potentially
|
||||
// wasted space if it is all updates and not just new content. (This is
|
||||
// a safe assumption in the sense that behavior will stabilize on a low
|
||||
// estimate of wastage after a commit removes all transaction updates.)
|
||||
//
|
||||
// Some db formats might attempt to keep a very accurate reckoning of free
|
||||
// space size, so a very accurate determination can be made. But other db
|
||||
// formats might have difficulty determining size of free space, and might
|
||||
// require some lengthy calculation to answer. This is the reason for
|
||||
// passing in the percentage threshold of interest, so that such lengthy
|
||||
// computations can terminate early as soon as at least inPercentWaste is
|
||||
// found, so that the entire file need not be groveled when unnecessary.
|
||||
// However, we hope implementations will always favor fast but imprecise
|
||||
// heuristic answers instead of extremely slow but very precise answers.
|
||||
//
|
||||
// If the outActualWaste parameter is non-nil, it will be used to return
|
||||
// the actual estimated space wasted as a percentage of file size. (This
|
||||
// parameter is provided so callers need not call repeatedly with altered
|
||||
// inPercentWaste values to isolate the actual wastage figure.) Note the
|
||||
// actual wastage figure returned can exactly equal inPercentWaste even
|
||||
// when this grossly underestimates the real figure involved, if the db
|
||||
// finds it very expensive to determine the extent of wastage after it is
|
||||
// known to at least exceed inPercentWaste. Note we expect that whenever
|
||||
// outShould returns true, that outActualWaste returns >= inPercentWaste.
|
||||
//
|
||||
// The effect of different inPercentWaste values is not very uniform over
|
||||
// the permitted range. For example, 50 represents 50% wastage, or a file
|
||||
// that is about double what it should be ideally. But 99 represents 99%
|
||||
// wastage, or a file that is about ninety-nine times as big as it should
|
||||
// be ideally. In the smaller direction, 25 represents 25% wastage, or
|
||||
// a file that is only 33% larger than it should be ideally.
|
||||
//
|
||||
// Callers can determine what policy they want to use for considering when
|
||||
// a file holds too much wasted space, and express this as a percentage
|
||||
// of total file size to pass as in the inPercentWaste parameter. A zero
|
||||
// likely returns always trivially true, and 100 always trivially false.
|
||||
// The great majority of callers are expected to use values from 25 to 75,
|
||||
// since most plausible thresholds for compressing might fall between the
|
||||
// extremes of 133% of ideal size and 400% of ideal size. (Presumably the
|
||||
// larger a file gets, the more important the percentage waste involved, so
|
||||
// a sliding scale for compress thresholds might use smaller numbers for
|
||||
// much bigger file sizes.)
|
||||
|
||||
// } ----- end commit methods -----
|
||||
|
||||
// } ===== end nsIMdbPort methods =====
|
||||
|
||||
// { ===== begin nsIMdbStore methods =====
|
||||
|
||||
// { ----- begin table methods -----
|
||||
NS_IMETHOD NewTable( // make one new table of specific type
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_scope inRowScope, // row scope for row ids
|
||||
mdb_kind inTableKind, // the type of table to access
|
||||
mdb_bool inMustBeUnique, // whether store can hold only one of these
|
||||
const mdbOid* inOptionalMetaRowOid, // can be nil to avoid specifying
|
||||
nsIMdbTable** acqTable); // acquire scoped collection of rows
|
||||
|
||||
NS_IMETHOD NewTableWithOid( // make one new table of specific type
|
||||
nsIMdbEnv* ev, // context
|
||||
const mdbOid* inOid, // caller assigned oid
|
||||
mdb_kind inTableKind, // the type of table to access
|
||||
mdb_bool inMustBeUnique, // whether store can hold only one of these
|
||||
const mdbOid* inOptionalMetaRowOid, // can be nil to avoid specifying
|
||||
nsIMdbTable** acqTable); // acquire scoped collection of rows
|
||||
// } ----- end table methods -----
|
||||
|
||||
// { ----- begin row scope methods -----
|
||||
NS_IMETHOD RowScopeHasAssignedIds(nsIMdbEnv* ev,
|
||||
mdb_scope inRowScope, // row scope for row ids
|
||||
mdb_bool* outCallerAssigned, // nonzero if caller assigned specified
|
||||
mdb_bool* outStoreAssigned); // nonzero if store db assigned specified
|
||||
|
||||
NS_IMETHOD SetCallerAssignedIds(nsIMdbEnv* ev,
|
||||
mdb_scope inRowScope, // row scope for row ids
|
||||
mdb_bool* outCallerAssigned, // nonzero if caller assigned specified
|
||||
mdb_bool* outStoreAssigned); // nonzero if store db assigned specified
|
||||
|
||||
NS_IMETHOD SetStoreAssignedIds(nsIMdbEnv* ev,
|
||||
mdb_scope inRowScope, // row scope for row ids
|
||||
mdb_bool* outCallerAssigned, // nonzero if caller assigned specified
|
||||
mdb_bool* outStoreAssigned); // nonzero if store db assigned specified
|
||||
// } ----- end row scope methods -----
|
||||
|
||||
// { ----- begin row methods -----
|
||||
NS_IMETHOD NewRowWithOid(nsIMdbEnv* ev, // new row w/ caller assigned oid
|
||||
const mdbOid* inOid, // caller assigned oid
|
||||
nsIMdbRow** acqRow); // create new row
|
||||
|
||||
NS_IMETHOD NewRow(nsIMdbEnv* ev, // new row with db assigned oid
|
||||
mdb_scope inRowScope, // row scope for row ids
|
||||
nsIMdbRow** acqRow); // create new row
|
||||
// Note this row must be added to some table or cell child before the
|
||||
// store is closed in order to make this row persist across sesssions.
|
||||
// } ----- end row methods -----
|
||||
|
||||
// { ----- begin inport/export methods -----
|
||||
NS_IMETHOD ImportContent( // import content from port
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_scope inRowScope, // scope for rows (or zero for all?)
|
||||
nsIMdbPort* ioPort, // the port with content to add to store
|
||||
nsIMdbThumb** acqThumb); // acquire thumb for incremental import
|
||||
// Call nsIMdbThumb::DoMore() until done, or until the thumb is broken, and
|
||||
// then the import will be finished.
|
||||
|
||||
NS_IMETHOD ImportFile( // import content from port
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbFile* ioFile, // the file with content to add to store
|
||||
nsIMdbThumb** acqThumb); // acquire thumb for incremental import
|
||||
// Call nsIMdbThumb::DoMore() until done, or until the thumb is broken, and
|
||||
// then the import will be finished.
|
||||
// } ----- end inport/export methods -----
|
||||
|
||||
// { ----- begin hinting methods -----
|
||||
NS_IMETHOD
|
||||
ShareAtomColumnsHint( // advise re shared column content atomizing
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_scope inScopeHint, // zero, or suggested shared namespace
|
||||
const mdbColumnSet* inColumnSet); // cols desired tokenized together
|
||||
|
||||
NS_IMETHOD
|
||||
AvoidAtomColumnsHint( // advise column with poor atomizing prospects
|
||||
nsIMdbEnv* ev, // context
|
||||
const mdbColumnSet* inColumnSet); // cols with poor atomizing prospects
|
||||
// } ----- end hinting methods -----
|
||||
|
||||
// { ----- begin commit methods -----
|
||||
NS_IMETHOD SmallCommit( // save minor changes if convenient and uncostly
|
||||
nsIMdbEnv* ev); // context
|
||||
|
||||
NS_IMETHOD LargeCommit( // save important changes if at all possible
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbThumb** acqThumb); // acquire thumb for incremental commit
|
||||
// Call nsIMdbThumb::DoMore() until done, or until the thumb is broken, and
|
||||
// then the commit will be finished. Note the store is effectively write
|
||||
// locked until commit is finished or canceled through the thumb instance.
|
||||
// Until the commit is done, the store will report it has readonly status.
|
||||
|
||||
NS_IMETHOD SessionCommit( // save all changes if large commits delayed
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbThumb** acqThumb); // acquire thumb for incremental commit
|
||||
// Call nsIMdbThumb::DoMore() until done, or until the thumb is broken, and
|
||||
// then the commit will be finished. Note the store is effectively write
|
||||
// locked until commit is finished or canceled through the thumb instance.
|
||||
// Until the commit is done, the store will report it has readonly status.
|
||||
|
||||
NS_IMETHOD
|
||||
CompressCommit( // commit and make db physically smaller if possible
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbThumb** acqThumb); // acquire thumb for incremental commit
|
||||
// Call nsIMdbThumb::DoMore() until done, or until the thumb is broken, and
|
||||
// then the commit will be finished. Note the store is effectively write
|
||||
// locked until commit is finished or canceled through the thumb instance.
|
||||
// Until the commit is done, the store will report it has readonly status.
|
||||
// } ----- end commit methods -----
|
||||
|
||||
// } ===== end nsIMdbStore methods =====
|
||||
};
|
||||
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
#endif /* _ORKINSTORE_ */
|
File diff suppressed because it is too large
Load Diff
@ -1,445 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _ORKINTABLE_
|
||||
#define _ORKINTABLE_ 1
|
||||
|
||||
#ifndef _MDB_
|
||||
#include "mdb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORK_
|
||||
#include "mork.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKNODE_
|
||||
#include "morkNode.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKHANDLE_
|
||||
#include "morkHandle.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKTABLE_
|
||||
#include "morkTable.h"
|
||||
#endif
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
#define morkMagic_kTable 0x5461626C /* ascii 'Tabl' */
|
||||
|
||||
/*| orkinTable:
|
||||
|*/
|
||||
class orkinTable : public morkHandle, public nsIMdbTable { // nsIMdbTable
|
||||
|
||||
// { ===== begin morkNode interface =====
|
||||
public: // morkNode virtual methods
|
||||
// virtual void CloseMorkNode(morkEnv* ev); // morkHandle is fine
|
||||
virtual ~orkinTable(); // morkHandle destructor does everything
|
||||
|
||||
protected: // construction is protected (use the static Make() method)
|
||||
orkinTable(morkEnv* ev, // note morkUsage is always morkUsage_kPool
|
||||
morkHandleFace* ioFace, // must not be nil, cookie for this handle
|
||||
morkTable* ioObject); // must not be nil, the object for this handle
|
||||
|
||||
// void CloseHandle(morkEnv* ev); // don't need to specialize closing
|
||||
|
||||
private: // copying is not allowed
|
||||
orkinTable(const orkinTable& other);
|
||||
orkinTable& operator=(const orkinTable& other);
|
||||
|
||||
// public: // dynamic type identification
|
||||
// mork_bool IsHandle() const //
|
||||
// { return IsNode() && mNode_Derived == morkDerived_kHandle; }
|
||||
// } ===== end morkNode methods =====
|
||||
|
||||
protected: // morkHandle memory management operators
|
||||
void* operator new(size_t inSize, morkPool& ioPool, morkZone& ioZone, morkEnv* ev) CPP_THROW_NEW
|
||||
{ return ioPool.NewHandle(ev, inSize, &ioZone); }
|
||||
|
||||
void* operator new(size_t inSize, morkPool& ioPool, morkEnv* ev) CPP_THROW_NEW
|
||||
{ return ioPool.NewHandle(ev, inSize, (morkZone*) 0); }
|
||||
|
||||
void* operator new(size_t inSize, morkHandleFace* ioFace) CPP_THROW_NEW
|
||||
{ MORK_USED_1(inSize); return ioFace; }
|
||||
|
||||
|
||||
public: // construction:
|
||||
|
||||
static orkinTable* MakeTable(morkEnv* ev, morkTable* ioObject);
|
||||
|
||||
public: // utilities:
|
||||
|
||||
morkEnv* CanUseTable(nsIMdbEnv* mev, mork_bool inMutable,
|
||||
mdb_err* outErr) const;
|
||||
|
||||
public: // type identification
|
||||
mork_bool IsOrkinTable() const
|
||||
{ return mHandle_Magic == morkMagic_kTable; }
|
||||
|
||||
mork_bool IsOrkinTableHandle() const
|
||||
{ return this->IsHandle() && this->IsOrkinTable(); }
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
// { ===== begin nsIMdbObject methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
NS_IMETHOD IsFrozenMdbObject(nsIMdbEnv* ev, mdb_bool* outIsReadonly);
|
||||
// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin factory methods -----
|
||||
NS_IMETHOD GetMdbFactory(nsIMdbEnv* ev, nsIMdbFactory** acqFactory);
|
||||
// } ----- end factory methods -----
|
||||
|
||||
// { ----- begin ref counting for well-behaved cyclic graphs -----
|
||||
NS_IMETHOD GetWeakRefCount(nsIMdbEnv* ev, // weak refs
|
||||
mdb_count* outCount);
|
||||
NS_IMETHOD GetStrongRefCount(nsIMdbEnv* ev, // strong refs
|
||||
mdb_count* outCount);
|
||||
|
||||
NS_IMETHOD AddWeakRef(nsIMdbEnv* ev);
|
||||
NS_IMETHOD AddStrongRef(nsIMdbEnv* ev);
|
||||
|
||||
NS_IMETHOD CutWeakRef(nsIMdbEnv* ev);
|
||||
NS_IMETHOD CutStrongRef(nsIMdbEnv* ev);
|
||||
|
||||
NS_IMETHOD CloseMdbObject(nsIMdbEnv* ev); // called at strong refs zero
|
||||
NS_IMETHOD IsOpenMdbObject(nsIMdbEnv* ev, mdb_bool* outOpen);
|
||||
// } ----- end ref counting -----
|
||||
|
||||
// } ===== end nsIMdbObject methods =====
|
||||
|
||||
// { ===== begin nsIMdbCollection methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
NS_IMETHOD GetSeed(nsIMdbEnv* ev,
|
||||
mdb_seed* outSeed); // member change count
|
||||
NS_IMETHOD GetCount(nsIMdbEnv* ev,
|
||||
mdb_count* outCount); // member count
|
||||
|
||||
NS_IMETHOD GetPort(nsIMdbEnv* ev,
|
||||
nsIMdbPort** acqPort); // collection container
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin cursor methods -----
|
||||
NS_IMETHOD GetCursor( // make a cursor starting iter at inMemberPos
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_pos inMemberPos, // zero-based ordinal pos of member in collection
|
||||
nsIMdbCursor** acqCursor); // acquire new cursor instance
|
||||
// } ----- end cursor methods -----
|
||||
|
||||
// { ----- begin ID methods -----
|
||||
NS_IMETHOD GetOid(nsIMdbEnv* ev,
|
||||
mdbOid* outOid); // read object identity
|
||||
NS_IMETHOD BecomeContent(nsIMdbEnv* ev,
|
||||
const mdbOid* inOid); // exchange content
|
||||
// } ----- end ID methods -----
|
||||
|
||||
// { ----- begin activity dropping methods -----
|
||||
NS_IMETHOD DropActivity( // tell collection usage no longer expected
|
||||
nsIMdbEnv* ev);
|
||||
// } ----- end activity dropping methods -----
|
||||
|
||||
// } ===== end nsIMdbCollection methods =====
|
||||
|
||||
// { ===== begin nsIMdbTable methods =====
|
||||
|
||||
// { ----- begin meta attribute methods -----
|
||||
NS_IMETHOD SetTablePriority(nsIMdbEnv* ev, mdb_priority inPrio);
|
||||
NS_IMETHOD GetTablePriority(nsIMdbEnv* ev, mdb_priority* outPrio);
|
||||
|
||||
NS_IMETHOD GetTableBeVerbose(nsIMdbEnv* ev, mdb_bool* outBeVerbose);
|
||||
NS_IMETHOD SetTableBeVerbose(nsIMdbEnv* ev, mdb_bool inBeVerbose);
|
||||
|
||||
NS_IMETHOD GetTableIsUnique(nsIMdbEnv* ev, mdb_bool* outIsUnique);
|
||||
|
||||
NS_IMETHOD GetTableKind(nsIMdbEnv* ev, mdb_kind* outTableKind);
|
||||
NS_IMETHOD GetRowScope(nsIMdbEnv* ev, mdb_scope* outRowScope);
|
||||
|
||||
NS_IMETHOD GetMetaRow(
|
||||
nsIMdbEnv* ev, // context
|
||||
const mdbOid* inOptionalMetaRowOid, // can be nil to avoid specifying
|
||||
mdbOid* outOid, // output meta row oid, can be nil to suppress output
|
||||
nsIMdbRow** acqRow); // acquire table's unique singleton meta row
|
||||
// The purpose of a meta row is to support the persistent recording of
|
||||
// meta info about a table as cells put into the distinguished meta row.
|
||||
// Each table has exactly one meta row, which is not considered a member
|
||||
// of the collection of rows inside the table. The only way to tell
|
||||
// whether a row is a meta row is by the fact that it is returned by this
|
||||
// GetMetaRow() method from some table. Otherwise nothing distinguishes
|
||||
// a meta row from any other row. A meta row can be used anyplace that
|
||||
// any other row can be used, and can even be put into other tables (or
|
||||
// the same table) as a table member, if this is useful for some reason.
|
||||
// The first attempt to access a table's meta row using GetMetaRow() will
|
||||
// cause the meta row to be created if it did not already exist. When the
|
||||
// meta row is created, it will have the row oid that was previously
|
||||
// requested for this table's meta row; or if no oid was ever explicitly
|
||||
// specified for this meta row, then a unique oid will be generated in
|
||||
// the row scope named "metaScope" (so obviously MDB clients should not
|
||||
// manually allocate any row IDs from that special meta scope namespace).
|
||||
// The meta row oid can be specified either when the table is created, or
|
||||
// else the first time that GetMetaRow() is called, by passing a non-nil
|
||||
// pointer to an oid for parameter inOptionalMetaRowOid. The meta row's
|
||||
// actual oid is returned in outOid (if this is a non-nil pointer), and
|
||||
// it will be different from inOptionalMetaRowOid when the meta row was
|
||||
// already given a different oid earlier.
|
||||
// } ----- end meta attribute methods -----
|
||||
|
||||
// { ----- begin cursor methods -----
|
||||
NS_IMETHOD GetTableRowCursor( // make a cursor, starting iteration at inRowPos
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_pos inRowPos, // zero-based ordinal position of row in table
|
||||
nsIMdbTableRowCursor** acqCursor); // acquire new cursor instance
|
||||
// } ----- end row position methods -----
|
||||
|
||||
// { ----- begin row position methods -----
|
||||
NS_IMETHOD 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
|
||||
|
||||
NS_IMETHOD 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
|
||||
|
||||
NS_IMETHOD 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
|
||||
|
||||
NS_IMETHOD RowToPos( // test for the table position of a row member
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbRow* ioRow, // row to find in table
|
||||
mdb_pos* outPos); // zero-based ordinal position of row in table
|
||||
|
||||
// } ----- end row position methods -----
|
||||
|
||||
// { ----- begin oid set methods -----
|
||||
NS_IMETHOD AddOid( // make sure the row with inOid is a table member
|
||||
nsIMdbEnv* ev, // context
|
||||
const mdbOid* inOid); // row to ensure membership in table
|
||||
|
||||
NS_IMETHOD HasOid( // test for the table position of a row member
|
||||
nsIMdbEnv* ev, // context
|
||||
const mdbOid* inOid, // row to find in table
|
||||
mdb_bool* outHasOid); // whether inOid is a member row
|
||||
|
||||
NS_IMETHOD CutOid( // make sure the row with inOid is not a member
|
||||
nsIMdbEnv* ev, // context
|
||||
const mdbOid* inOid); // row to remove from table
|
||||
// } ----- end oid set methods -----
|
||||
|
||||
// { ----- begin row set methods -----
|
||||
NS_IMETHOD NewRow( // create a new row instance in table
|
||||
nsIMdbEnv* ev, // context
|
||||
mdbOid* ioOid, // please use zero (unbound) rowId for db-assigned IDs
|
||||
nsIMdbRow** acqRow); // create new row
|
||||
|
||||
NS_IMETHOD AddRow( // make sure the row with inOid is a table member
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbRow* ioRow); // row to ensure membership in table
|
||||
|
||||
NS_IMETHOD HasRow( // test for the table position of a row member
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbRow* ioRow, // row to find in table
|
||||
mdb_bool* outHasRow); // whether row is a table member
|
||||
|
||||
NS_IMETHOD CutRow( // make sure the row with inOid is not a member
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbRow* ioRow); // row to remove from table
|
||||
|
||||
NS_IMETHOD CutAllRows( // remove all rows from the table
|
||||
nsIMdbEnv* ev); // context
|
||||
// } ----- end row set methods -----
|
||||
|
||||
// { ----- begin hinting methods -----
|
||||
NS_IMETHOD SearchColumnsHint( // advise re future expected search cols
|
||||
nsIMdbEnv* ev, // context
|
||||
const mdbColumnSet* inColumnSet); // columns likely to be searched
|
||||
|
||||
NS_IMETHOD SortColumnsHint( // advise re future expected sort columns
|
||||
nsIMdbEnv* ev, // context
|
||||
const mdbColumnSet* inColumnSet); // columns for likely sort requests
|
||||
|
||||
NS_IMETHOD StartBatchChangeHint( // advise before many adds and cuts
|
||||
nsIMdbEnv* ev, // context
|
||||
const void* inLabel); // intend unique address to match end call
|
||||
// If batch starts nest by virtue of nesting calls in the stack, then
|
||||
// the address of a local variable makes a good batch start label that
|
||||
// can be used at batch end time, and such addresses remain unique.
|
||||
NS_IMETHOD EndBatchChangeHint( // advise before many adds and cuts
|
||||
nsIMdbEnv* ev, // context
|
||||
const void* inLabel); // label matching start label
|
||||
// Suppose a table is maintaining one or many sort orders for a table,
|
||||
// so that every row added to the table must be inserted in each sort,
|
||||
// and every row cut must be removed from each sort. If a db client
|
||||
// intends to make many such changes before needing any information
|
||||
// about the order or positions of rows inside a table, then a client
|
||||
// might tell the table to start batch changes in order to disable
|
||||
// sorting of rows for the interim. Presumably a table will then do
|
||||
// a full sort of all rows at need when the batch changes end, or when
|
||||
// a surprise request occurs for row position during batch changes.
|
||||
// } ----- end hinting methods -----
|
||||
|
||||
// { ----- begin searching methods -----
|
||||
NS_IMETHOD FindRowMatches( // search variable number of sorted cols
|
||||
nsIMdbEnv* ev, // context
|
||||
const mdbYarn* inPrefix, // content to find as prefix in row's column cell
|
||||
nsIMdbTableRowCursor** acqCursor); // set of matching rows
|
||||
|
||||
NS_IMETHOD GetSearchColumns( // query columns used by FindRowMatches()
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_count* outCount, // context
|
||||
mdbColumnSet* outColSet); // caller supplied space to put columns
|
||||
// GetSearchColumns() returns the columns actually searched when the
|
||||
// FindRowMatches() method is called. No more than mColumnSet_Count
|
||||
// slots of mColumnSet_Columns will be written, since mColumnSet_Count
|
||||
// indicates how many slots are present in the column array. The
|
||||
// actual number of search column used by the table is returned in
|
||||
// the outCount parameter; if this number exceeds mColumnSet_Count,
|
||||
// then a caller needs a bigger array to read the entire column set.
|
||||
// The minimum of mColumnSet_Count and outCount is the number slots
|
||||
// in mColumnSet_Columns that were actually written by this method.
|
||||
//
|
||||
// Callers are expected to change this set of columns by calls to
|
||||
// nsIMdbTable::SearchColumnsHint() or SetSearchSorting(), or both.
|
||||
// } ----- end searching methods -----
|
||||
|
||||
// { ----- begin sorting methods -----
|
||||
// sorting: note all rows are assumed sorted by row ID as a secondary
|
||||
// sort following the primary column sort, when table rows are sorted.
|
||||
|
||||
NS_IMETHOD
|
||||
CanSortColumn( // query which column is currently used for sorting
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_column inColumn, // column to query sorting potential
|
||||
mdb_bool* outCanSort); // whether the column can be sorted
|
||||
|
||||
NS_IMETHOD GetSorting( // view same table in particular sorting
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_column inColumn, // requested new column for sorting table
|
||||
nsIMdbSorting** acqSorting); // acquire sorting for column
|
||||
|
||||
NS_IMETHOD SetSearchSorting( // use this sorting in FindRowMatches()
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_column inColumn, // often same as nsIMdbSorting::GetSortColumn()
|
||||
nsIMdbSorting* ioSorting); // requested sorting for some column
|
||||
// SetSearchSorting() attempts to inform the table that ioSorting
|
||||
// should be used during calls to FindRowMatches() for searching
|
||||
// the column which is actually sorted by ioSorting. This method
|
||||
// is most useful in conjunction with nsIMdbSorting::SetCompare(),
|
||||
// because otherwise a caller would not be able to override the
|
||||
// comparison ordering method used during searchs. Note that some
|
||||
// database implementations might be unable to use an arbitrarily
|
||||
// specified sort order, either due to schema or runtime interface
|
||||
// constraints, in which case ioSorting might not actually be used.
|
||||
// Presumably ioSorting is an instance that was returned from some
|
||||
// earlier call to nsIMdbTable::GetSorting(). A caller can also
|
||||
// use nsIMdbTable::SearchColumnsHint() to specify desired change
|
||||
// in which columns are sorted and searched by FindRowMatches().
|
||||
//
|
||||
// A caller can pass a nil pointer for ioSorting to request that
|
||||
// column inColumn no longer be used at all by FindRowMatches().
|
||||
// But when ioSorting is non-nil, then inColumn should match the
|
||||
// column actually sorted by ioSorting; when these do not agree,
|
||||
// implementations are instructed to give precedence to the column
|
||||
// specified by ioSorting (so this means callers might just pass
|
||||
// zero for inColumn when ioSorting is also provided, since then
|
||||
// inColumn is both redundant and ignored).
|
||||
// } ----- end sorting methods -----
|
||||
|
||||
// { ----- begin moving methods -----
|
||||
// moving a row does nothing unless a table is currently unsorted
|
||||
|
||||
NS_IMETHOD MoveOid( // change position of row in unsorted table
|
||||
nsIMdbEnv* ev, // context
|
||||
const mdbOid* inOid, // row oid to find in table
|
||||
mdb_pos inHintFromPos, // suggested hint regarding start position
|
||||
mdb_pos inToPos, // desired new position for row inRowId
|
||||
mdb_pos* outActualPos); // actual new position of row in table
|
||||
|
||||
NS_IMETHOD MoveRow( // change position of row in unsorted table
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbRow* ioRow, // row oid to find in table
|
||||
mdb_pos inHintFromPos, // suggested hint regarding start position
|
||||
mdb_pos inToPos, // desired new position for row inRowId
|
||||
mdb_pos* outActualPos); // actual new position of row in table
|
||||
// } ----- end moving methods -----
|
||||
|
||||
// { ----- begin index methods -----
|
||||
NS_IMETHOD AddIndex( // create a sorting index for column if possible
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_column inColumn, // the column to sort by index
|
||||
nsIMdbThumb** acqThumb); // acquire thumb for incremental index building
|
||||
// Call nsIMdbThumb::DoMore() until done, or until the thumb is broken, and
|
||||
// then the index addition will be finished.
|
||||
|
||||
NS_IMETHOD CutIndex( // stop supporting a specific column index
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_column inColumn, // the column with index to be removed
|
||||
nsIMdbThumb** acqThumb); // acquire thumb for incremental index destroy
|
||||
// Call nsIMdbThumb::DoMore() until done, or until the thumb is broken, and
|
||||
// then the index removal will be finished.
|
||||
|
||||
NS_IMETHOD HasIndex( // query for current presence of a column index
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_column inColumn, // the column to investigate
|
||||
mdb_bool* outHasIndex); // whether column has index for this column
|
||||
|
||||
|
||||
NS_IMETHOD EnableIndexOnSort( // create an index for col on first sort
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_column inColumn); // the column to index if ever sorted
|
||||
|
||||
NS_IMETHOD QueryIndexOnSort( // check whether index on sort is enabled
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_column inColumn, // the column to investigate
|
||||
mdb_bool* outIndexOnSort); // whether column has index-on-sort enabled
|
||||
|
||||
NS_IMETHOD DisableIndexOnSort( // prevent future index creation on sort
|
||||
nsIMdbEnv* ev, // context
|
||||
mdb_column inColumn); // the column to index if ever sorted
|
||||
// } ----- end index methods -----
|
||||
|
||||
// } ===== end nsIMdbTable methods =====
|
||||
};
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
#endif /* _ORKINTABLE_ */
|
@ -1,509 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _MDB_
|
||||
#include "mdb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORK_
|
||||
#include "mork.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKNODE_
|
||||
#include "morkNode.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKHANDLE_
|
||||
#include "morkHandle.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKFACTORY_
|
||||
#include "morkFactory.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINFACTORY_
|
||||
#include "orkinFactory.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKTABLEROWCURSOR_
|
||||
#include "morkTableRowCursor.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINTABLEROWCURSOR_
|
||||
#include "orkinTableRowCursor.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKROW_
|
||||
#include "morkRow.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKARRAY_
|
||||
#include "morkArray.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKTABLE_
|
||||
#include "morkTable.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINTABLE_
|
||||
#include "orkinTable.h"
|
||||
#endif
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
/* public virtual*/
|
||||
orkinTableRowCursor:: ~orkinTableRowCursor()
|
||||
// morkHandle destructor does everything
|
||||
{
|
||||
}
|
||||
|
||||
/*protected non-poly construction*/
|
||||
orkinTableRowCursor::orkinTableRowCursor(morkEnv* ev, // morkUsage_kPool
|
||||
morkHandleFace* ioFace, // must not be nil, cookie for this handle
|
||||
morkTableRowCursor* ioObject) // must not be nil, object for this handle
|
||||
: morkHandle(ev, ioFace, ioObject, morkMagic_kTableRowCursor)
|
||||
{
|
||||
// do not modify mNode_Derived; leave it equal to morkDerived_kHandle
|
||||
}
|
||||
|
||||
|
||||
/*static */ orkinTableRowCursor*
|
||||
orkinTableRowCursor::MakeTableRowCursor(morkEnv* ev,
|
||||
morkTableRowCursor* ioObject)
|
||||
{
|
||||
mork_bool isEnv = ev->IsEnv();
|
||||
MORK_ASSERT(isEnv);
|
||||
if ( isEnv )
|
||||
{
|
||||
morkHandleFace* face = ev->NewHandle(sizeof(orkinTableRowCursor));
|
||||
if ( face )
|
||||
return new(face) orkinTableRowCursor(ev, face, ioObject);
|
||||
else
|
||||
ev->OutOfMemoryError();
|
||||
}
|
||||
|
||||
return (orkinTableRowCursor*) 0;
|
||||
}
|
||||
|
||||
morkEnv*
|
||||
orkinTableRowCursor::CanUseTableRowCursor(nsIMdbEnv* mev,
|
||||
mork_bool inMutable, mdb_err* outErr) const
|
||||
{
|
||||
morkEnv* outEnv = 0;
|
||||
morkEnv* ev = morkEnv::FromMdbEnv(mev);
|
||||
if ( ev )
|
||||
{
|
||||
morkTableRowCursor* self = (morkTableRowCursor*)
|
||||
this->GetGoodHandleObject(ev, inMutable, morkMagic_kTableRowCursor,
|
||||
/*inClosedOkay*/ morkBool_kFalse);
|
||||
if ( self )
|
||||
{
|
||||
if ( self->IsTableRowCursor() )
|
||||
{
|
||||
morkTable* table = self->mTableRowCursor_Table;
|
||||
if ( table && table->IsOpenNode() )
|
||||
{
|
||||
outEnv = ev;
|
||||
}
|
||||
}
|
||||
else
|
||||
self->NonTableRowCursorTypeError(ev);
|
||||
}
|
||||
*outErr = ev->AsErr();
|
||||
}
|
||||
MORK_ASSERT(outEnv);
|
||||
return outEnv;
|
||||
}
|
||||
|
||||
// { ===== begin nsIMdbISupports methods =====
|
||||
NS_IMPL_QUERY_INTERFACE1(orkinTableRowCursor, nsIMdbTableRowCursor)
|
||||
|
||||
/*virtual*/ nsrefcnt
|
||||
orkinTableRowCursor::AddRef() // add strong ref with no
|
||||
{
|
||||
morkEnv* ev = mHandle_Env;
|
||||
if ( ev && ev->IsEnv() )
|
||||
return this->Handle_AddStrongRef(ev->AsMdbEnv());
|
||||
else
|
||||
return morkEnv_kNonEnvTypeError;
|
||||
}
|
||||
|
||||
/*virtual*/ nsrefcnt
|
||||
orkinTableRowCursor::Release() // cut strong ref
|
||||
{
|
||||
morkEnv* ev = mHandle_Env;
|
||||
if ( ev && ev->IsEnv() )
|
||||
return this->Handle_CutStrongRef(ev->AsMdbEnv());
|
||||
else
|
||||
return morkEnv_kNonEnvTypeError;
|
||||
}
|
||||
// } ===== end nsIMdbObject methods =====
|
||||
|
||||
|
||||
// { ===== begin nsIMdbObject methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinTableRowCursor::IsFrozenMdbObject(nsIMdbEnv* mev, mdb_bool* outIsReadonly)
|
||||
{
|
||||
return this->Handle_IsFrozenMdbObject(mev, outIsReadonly);
|
||||
}
|
||||
// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin factory methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinTableRowCursor::GetMdbFactory(nsIMdbEnv* mev, nsIMdbFactory** acqFactory)
|
||||
{
|
||||
return this->Handle_GetMdbFactory(mev, acqFactory);
|
||||
}
|
||||
// } ----- end factory methods -----
|
||||
|
||||
// { ----- begin ref counting for well-behaved cyclic graphs -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinTableRowCursor::GetWeakRefCount(nsIMdbEnv* mev, // weak refs
|
||||
mdb_count* outCount)
|
||||
{
|
||||
return this->Handle_GetWeakRefCount(mev, outCount);
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinTableRowCursor::GetStrongRefCount(nsIMdbEnv* mev, // strong refs
|
||||
mdb_count* outCount)
|
||||
{
|
||||
return this->Handle_GetStrongRefCount(mev, outCount);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinTableRowCursor::AddWeakRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_AddWeakRef(mev);
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinTableRowCursor::AddStrongRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_AddStrongRef(mev);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinTableRowCursor::CutWeakRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_CutWeakRef(mev);
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinTableRowCursor::CutStrongRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_CutStrongRef(mev);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinTableRowCursor::CloseMdbObject(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_CloseMdbObject(mev);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinTableRowCursor::IsOpenMdbObject(nsIMdbEnv* mev, mdb_bool* outOpen)
|
||||
{
|
||||
return this->Handle_IsOpenMdbObject(mev, outOpen);
|
||||
}
|
||||
// } ----- end ref counting -----
|
||||
|
||||
// } ===== end nsIMdbObject methods =====
|
||||
|
||||
// { ===== begin nsIMdbCursor methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinTableRowCursor::GetCount(nsIMdbEnv* mev, mdb_count* outCount)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mdb_count count = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUseTableRowCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkTableRowCursor* cursor = (morkTableRowCursor*) mHandle_Object;
|
||||
count = cursor->GetMemberCount(ev);
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( outCount )
|
||||
*outCount = count;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinTableRowCursor::GetSeed(nsIMdbEnv* mev, mdb_seed* outSeed)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mdb_seed seed = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUseTableRowCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
ev->StubMethodOnlyError();
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( outSeed )
|
||||
*outSeed = seed;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinTableRowCursor::SetPos(nsIMdbEnv* mev, mdb_pos inPos)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUseTableRowCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkTableRowCursor* cursor = (morkTableRowCursor*) mHandle_Object;
|
||||
cursor->mCursor_Pos = inPos;
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinTableRowCursor::GetPos(nsIMdbEnv* mev, mdb_pos* outPos)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mdb_pos pos = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUseTableRowCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkTableRowCursor* cursor = (morkTableRowCursor*) mHandle_Object;
|
||||
pos = cursor->mCursor_Pos;
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( outPos )
|
||||
*outPos = pos;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinTableRowCursor::SetDoFailOnSeedOutOfSync(nsIMdbEnv* mev, mdb_bool inFail)
|
||||
{
|
||||
MORK_USED_1(inFail);
|
||||
mdb_err outErr = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUseTableRowCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkTableRowCursor* cursor = (morkTableRowCursor*) mHandle_Object;
|
||||
cursor->mCursor_DoFailOnSeedOutOfSync = inFail;
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinTableRowCursor::GetDoFailOnSeedOutOfSync(nsIMdbEnv* mev, mdb_bool* outFail)
|
||||
{
|
||||
mdb_bool fail = morkBool_kFalse;
|
||||
mdb_err outErr = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUseTableRowCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkTableRowCursor* cursor = (morkTableRowCursor*) mHandle_Object;
|
||||
fail = cursor->mCursor_DoFailOnSeedOutOfSync;
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( outFail )
|
||||
*outFail = fail;
|
||||
return outErr;
|
||||
}
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// } ===== end nsIMdbCursor methods =====
|
||||
|
||||
|
||||
// { ===== begin nsIMdbTableRowCursor methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinTableRowCursor::GetTable(nsIMdbEnv* mev, nsIMdbTable** acqTable)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbTable* outTable = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUseTableRowCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkTableRowCursor* cursor = (morkTableRowCursor*) mHandle_Object;
|
||||
morkTable* table = cursor->mTableRowCursor_Table;
|
||||
if ( table )
|
||||
outTable = table->AcquireTableHandle(ev);
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( acqTable )
|
||||
*acqTable = outTable;
|
||||
return outErr;
|
||||
}
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin oid iteration methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinTableRowCursor::NextRowOid( // get row id of next row in the table
|
||||
nsIMdbEnv* mev, // context
|
||||
mdbOid* outOid, // out row oid
|
||||
mdb_pos* outRowPos)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mork_pos pos = -1;
|
||||
morkEnv* ev =
|
||||
this->CanUseTableRowCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
if ( outOid )
|
||||
{
|
||||
pos = ((morkTableRowCursor*) mHandle_Object)->NextRowOid(ev, outOid);
|
||||
}
|
||||
else
|
||||
ev->NilPointerError();
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( outRowPos )
|
||||
*outRowPos = pos;
|
||||
return outErr;
|
||||
}
|
||||
// } ----- end oid iteration methods -----
|
||||
|
||||
// { ----- begin row iteration methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinTableRowCursor::NextRow( // get row cells from table for cells already in row
|
||||
nsIMdbEnv* mev, // context
|
||||
nsIMdbRow** acqRow, // acquire next row in table
|
||||
mdb_pos* outRowPos)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbRow* outRow = 0;
|
||||
morkEnv* ev =
|
||||
this->CanUseTableRowCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkTableRowCursor* cursor = (morkTableRowCursor*) mHandle_Object;
|
||||
|
||||
mdbOid oid; // place to put oid we intend to ignore
|
||||
morkRow* row = cursor->NextRow(ev, &oid, outRowPos);
|
||||
if ( row )
|
||||
{
|
||||
morkStore* store = row->GetRowSpaceStore(ev);
|
||||
if ( store )
|
||||
outRow = row->AcquireRowHandle(ev, store);
|
||||
}
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( acqRow )
|
||||
*acqRow = outRow;
|
||||
return outErr;
|
||||
}
|
||||
// } ----- end row iteration methods -----
|
||||
|
||||
|
||||
// { ----- begin duplicate row removal methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinTableRowCursor::CanHaveDupRowMembers(nsIMdbEnv* mev, // cursor might hold dups?
|
||||
mdb_bool* outCanHaveDups)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
mdb_bool canHaveDups = mdbBool_kFalse;
|
||||
|
||||
morkEnv* ev =
|
||||
this->CanUseTableRowCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkTableRowCursor* cursor = (morkTableRowCursor*) mHandle_Object;
|
||||
canHaveDups = cursor->CanHaveDupRowMembers(ev);
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( outCanHaveDups )
|
||||
*outCanHaveDups = canHaveDups;
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinTableRowCursor::MakeUniqueCursor( // clone cursor, removing duplicate rows
|
||||
nsIMdbEnv* mev, // context
|
||||
nsIMdbTableRowCursor** acqCursor) // acquire clone with no dups
|
||||
// Note that MakeUniqueCursor() is never necessary for a cursor which was
|
||||
// created by table method nsIMdbTable::GetTableRowCursor(), because a table
|
||||
// never contains the same row as a member more than once. However, a cursor
|
||||
// created by table method nsIMdbTable::FindRowMatches() might contain the
|
||||
// same row more than once, because the same row can generate a hit by more
|
||||
// than one column with a matching string prefix. Note this method can
|
||||
// return the very same cursor instance with just an incremented refcount,
|
||||
// when the original cursor could not contain any duplicate rows (calling
|
||||
// CanHaveDupRowMembers() shows this case on a false return). Otherwise
|
||||
// this method returns a different cursor instance. Callers should not use
|
||||
// this MakeUniqueCursor() method lightly, because it tends to defeat the
|
||||
// purpose of lazy programming techniques, since it can force creation of
|
||||
// an explicit row collection in a new cursor's representation, in order to
|
||||
// inspect the row membership and remove any duplicates; this can have big
|
||||
// impact if a collection holds tens of thousands of rows or more, when
|
||||
// the original cursor with dups simply referenced rows indirectly by row
|
||||
// position ranges, without using an explicit row set representation.
|
||||
// Callers are encouraged to use nsIMdbCursor::GetCount() to determine
|
||||
// whether the row collection is very large (tens of thousands), and to
|
||||
// delay calling MakeUniqueCursor() when possible, until a user interface
|
||||
// element actually demands the creation of an explicit set representation.
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
nsIMdbTableRowCursor* outCursor = 0;
|
||||
|
||||
morkEnv* ev =
|
||||
this->CanUseTableRowCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
if ( this->Handle_AddStrongRef(mev) == 0 )
|
||||
outCursor = this;
|
||||
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
if ( acqCursor )
|
||||
*acqCursor = outCursor;
|
||||
return outErr;
|
||||
}
|
||||
// } ----- end duplicate row removal methods -----
|
||||
|
||||
// } ===== end nsIMdbTableRowCursor methods =====
|
||||
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
@ -1,220 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _ORKINTABLEROWCURSOR_
|
||||
#define _ORKINTABLEROWCURSOR_ 1
|
||||
|
||||
#ifndef _MDB_
|
||||
#include "mdb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORK_
|
||||
#include "mork.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKNODE_
|
||||
#include "morkNode.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKHANDLE_
|
||||
#include "morkHandle.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKTABLEROWCURSOR_
|
||||
#include "morkTableRowCursor.h"
|
||||
#endif
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
class morkTableRowCursor;
|
||||
#define morkMagic_kTableRowCursor 0x54724375 /* ascii 'TrCu' */
|
||||
|
||||
/*| orkinTableRowCursor:
|
||||
|*/
|
||||
class orkinTableRowCursor :
|
||||
public morkHandle, public nsIMdbTableRowCursor { // nsIMdbCursor
|
||||
|
||||
// { ===== begin morkNode interface =====
|
||||
public: // morkNode virtual methods
|
||||
// virtual void CloseMorkNode(morkEnv* ev); // morkHandle is fine
|
||||
virtual ~orkinTableRowCursor(); // morkHandle destructor does everything
|
||||
|
||||
protected: // construction is protected (use the static Make() method)
|
||||
orkinTableRowCursor(morkEnv* ev, // note morkUsage is always morkUsage_kPool
|
||||
morkHandleFace* ioFace, // must not be nil, cookie for this handle
|
||||
morkTableRowCursor* ioObject); // must not be nil, object for this handle
|
||||
|
||||
// void CloseHandle(morkEnv* ev); // don't need to specialize closing
|
||||
|
||||
private: // copying is not allowed
|
||||
orkinTableRowCursor(const morkHandle& other);
|
||||
orkinTableRowCursor& operator=(const morkHandle& other);
|
||||
|
||||
// public: // dynamic type identification
|
||||
// mork_bool IsHandle() const //
|
||||
// { return IsNode() && mNode_Derived == morkDerived_kHandle; }
|
||||
// } ===== end morkNode methods =====
|
||||
|
||||
protected: // morkHandle memory management operators
|
||||
void* operator new(size_t inSize, morkPool& ioPool, morkZone& ioZone, morkEnv* ev) CPP_THROW_NEW
|
||||
{ return ioPool.NewHandle(ev, inSize, &ioZone); }
|
||||
|
||||
void* operator new(size_t inSize, morkPool& ioPool, morkEnv* ev) CPP_THROW_NEW
|
||||
{ return ioPool.NewHandle(ev, inSize, (morkZone*) 0); }
|
||||
|
||||
void* operator new(size_t inSize, morkHandleFace* ioFace) CPP_THROW_NEW
|
||||
{ MORK_USED_1(inSize); return ioFace; }
|
||||
|
||||
|
||||
public: // construction:
|
||||
|
||||
static orkinTableRowCursor* MakeTableRowCursor(morkEnv* ev,
|
||||
morkTableRowCursor* ioObject);
|
||||
|
||||
public: // utilities:
|
||||
|
||||
morkEnv* CanUseTableRowCursor(nsIMdbEnv* mev, mork_bool inMutable,
|
||||
mdb_err* outErr) const;
|
||||
|
||||
public: // type identification
|
||||
mork_bool IsOrkinTableRowCursor() const
|
||||
{ return mHandle_Magic == morkMagic_kTableRowCursor; }
|
||||
|
||||
mork_bool IsOrkinTableRowCursorHandle() const
|
||||
{ return this->IsHandle() && this->IsOrkinTableRowCursor(); }
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
// { ===== begin nsIMdbObject methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
NS_IMETHOD IsFrozenMdbObject(nsIMdbEnv* ev, mdb_bool* outIsReadonly);
|
||||
// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin factory methods -----
|
||||
NS_IMETHOD GetMdbFactory(nsIMdbEnv* ev, nsIMdbFactory** acqFactory);
|
||||
// } ----- end factory methods -----
|
||||
|
||||
// { ----- begin ref counting for well-behaved cyclic graphs -----
|
||||
NS_IMETHOD GetWeakRefCount(nsIMdbEnv* ev, // weak refs
|
||||
mdb_count* outCount);
|
||||
NS_IMETHOD GetStrongRefCount(nsIMdbEnv* ev, // strong refs
|
||||
mdb_count* outCount);
|
||||
|
||||
NS_IMETHOD AddWeakRef(nsIMdbEnv* ev);
|
||||
NS_IMETHOD AddStrongRef(nsIMdbEnv* ev);
|
||||
|
||||
NS_IMETHOD CutWeakRef(nsIMdbEnv* ev);
|
||||
NS_IMETHOD CutStrongRef(nsIMdbEnv* ev);
|
||||
|
||||
NS_IMETHOD CloseMdbObject(nsIMdbEnv* ev); // called at strong refs zero
|
||||
NS_IMETHOD IsOpenMdbObject(nsIMdbEnv* ev, mdb_bool* outOpen);
|
||||
// } ----- end ref counting -----
|
||||
|
||||
// } ===== end nsIMdbObject methods =====
|
||||
|
||||
// { ===== begin nsIMdbCursor methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
NS_IMETHOD GetCount(nsIMdbEnv* ev, mdb_count* outCount); // readonly
|
||||
NS_IMETHOD GetSeed(nsIMdbEnv* ev, mdb_seed* outSeed); // readonly
|
||||
|
||||
NS_IMETHOD SetPos(nsIMdbEnv* ev, mdb_pos inPos); // mutable
|
||||
NS_IMETHOD GetPos(nsIMdbEnv* ev, mdb_pos* outPos);
|
||||
|
||||
NS_IMETHOD SetDoFailOnSeedOutOfSync(nsIMdbEnv* ev, mdb_bool inFail);
|
||||
NS_IMETHOD GetDoFailOnSeedOutOfSync(nsIMdbEnv* ev, mdb_bool* outFail);
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// } ===== end nsIMdbCursor methods =====
|
||||
|
||||
// { ===== begin nsIMdbTableRowCursor methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
NS_IMETHOD GetTable(nsIMdbEnv* ev, nsIMdbTable** acqTable);
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin oid iteration methods -----
|
||||
NS_IMETHOD NextRowOid( // get row id of next row in the table
|
||||
nsIMdbEnv* ev, // context
|
||||
mdbOid* outOid, // out row oid
|
||||
mdb_pos* outRowPos); // zero-based position of the row in table
|
||||
// } ----- end oid iteration methods -----
|
||||
|
||||
// { ----- begin row iteration methods -----
|
||||
NS_IMETHOD NextRow( // get row cells from table for cells already in row
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbRow** acqRow, // acquire next row in table
|
||||
mdb_pos* outRowPos); // zero-based position of the row in table
|
||||
// } ----- end row iteration methods -----
|
||||
|
||||
// { ----- begin duplicate row removal methods -----
|
||||
NS_IMETHOD CanHaveDupRowMembers(nsIMdbEnv* ev, // cursor might hold dups?
|
||||
mdb_bool* outCanHaveDups);
|
||||
|
||||
NS_IMETHOD MakeUniqueCursor( // clone cursor, removing duplicate rows
|
||||
nsIMdbEnv* ev, // context
|
||||
nsIMdbTableRowCursor** acqCursor); // acquire clone with no dups
|
||||
// Note that MakeUniqueCursor() is never necessary for a cursor which was
|
||||
// created by table method nsIMdbTable::GetTableRowCursor(), because a table
|
||||
// never contains the same row as a member more than once. However, a cursor
|
||||
// created by table method nsIMdbTable::FindRowMatches() might contain the
|
||||
// same row more than once, because the same row can generate a hit by more
|
||||
// than one column with a matching string prefix. Note this method can
|
||||
// return the very same cursor instance with just an incremented refcount,
|
||||
// when the original cursor could not contain any duplicate rows (calling
|
||||
// CanHaveDupRowMembers() shows this case on a false return). Otherwise
|
||||
// this method returns a different cursor instance. Callers should not use
|
||||
// this MakeUniqueCursor() method lightly, because it tends to defeat the
|
||||
// purpose of lazy programming techniques, since it can force creation of
|
||||
// an explicit row collection in a new cursor's representation, in order to
|
||||
// inspect the row membership and remove any duplicates; this can have big
|
||||
// impact if a collection holds tens of thousands of rows or more, when
|
||||
// the original cursor with dups simply referenced rows indirectly by row
|
||||
// position ranges, without using an explicit row set representation.
|
||||
// Callers are encouraged to use nsIMdbCursor::GetCount() to determine
|
||||
// whether the row collection is very large (tens of thousands), and to
|
||||
// delay calling MakeUniqueCursor() when possible, until a user interface
|
||||
// element actually demands the creation of an explicit set representation.
|
||||
// } ----- end duplicate row removal methods -----
|
||||
|
||||
// } ===== end nsIMdbTableRowCursor methods =====
|
||||
};
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
#endif /* _ORKINTABLEROWCURSOR_ */
|
@ -1,269 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _MDB_
|
||||
#include "mdb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORK_
|
||||
#include "mork.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKNODE_
|
||||
#include "morkNode.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKHANDLE_
|
||||
#include "morkHandle.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKTHUMB_
|
||||
#include "morkThumb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKENV_
|
||||
#include "morkEnv.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ORKINTHUMB_
|
||||
#include "orkinThumb.h"
|
||||
#endif
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
/* public virtual*/
|
||||
orkinThumb:: ~orkinThumb() // morkHandle destructor does everything
|
||||
{
|
||||
}
|
||||
|
||||
/*protected non-poly construction*/
|
||||
orkinThumb::orkinThumb(morkEnv* ev, // morkUsage is morkUsage_kPool
|
||||
morkHandleFace* ioFace, // must not be nil, cookie for this handle
|
||||
morkThumb* ioObject) // must not be nil, the object for this handle
|
||||
: morkHandle(ev, ioFace, ioObject, morkMagic_kThumb)
|
||||
{
|
||||
// do not modify mNode_Derived; leave it equal to morkDerived_kHandle
|
||||
}
|
||||
|
||||
|
||||
/*static */ orkinThumb*
|
||||
orkinThumb::MakeThumb(morkEnv* ev, morkThumb* ioObject)
|
||||
{
|
||||
mork_bool isEnv = ev->IsEnv();
|
||||
MORK_ASSERT(isEnv);
|
||||
if ( isEnv )
|
||||
{
|
||||
morkHandleFace* face = ev->NewHandle(sizeof(orkinThumb));
|
||||
if ( face )
|
||||
return new(face) orkinThumb(ev, face, ioObject);
|
||||
else
|
||||
ev->OutOfMemoryError();
|
||||
}
|
||||
|
||||
return (orkinThumb*) 0;
|
||||
}
|
||||
|
||||
morkEnv*
|
||||
orkinThumb::CanUseThumb(nsIMdbEnv* mev,
|
||||
mork_bool inMutable, mdb_err* outErr) const
|
||||
{
|
||||
morkEnv* outEnv = 0;
|
||||
morkEnv* ev = morkEnv::FromMdbEnv(mev);
|
||||
if ( ev )
|
||||
{
|
||||
morkThumb* self = (morkThumb*)
|
||||
this->GetGoodHandleObject(ev, inMutable, morkMagic_kThumb,
|
||||
/*inClosedOkay*/ morkBool_kFalse);
|
||||
if ( self )
|
||||
{
|
||||
if ( self->IsThumb() )
|
||||
outEnv = ev;
|
||||
else
|
||||
self->NonThumbTypeError(ev);
|
||||
}
|
||||
*outErr = ev->AsErr();
|
||||
}
|
||||
MORK_ASSERT(outEnv);
|
||||
return outEnv;
|
||||
}
|
||||
|
||||
|
||||
// { ===== begin nsIMdbISupports methods =====
|
||||
NS_IMPL_QUERY_INTERFACE1(orkinThumb, nsIMdbThumb)
|
||||
|
||||
/*virtual*/ nsrefcnt
|
||||
orkinThumb::AddRef() // add strong ref with no
|
||||
{
|
||||
morkEnv* ev = mHandle_Env;
|
||||
if ( ev && ev->IsEnv() )
|
||||
return this->Handle_AddStrongRef(ev->AsMdbEnv());
|
||||
else
|
||||
return morkEnv_kNonEnvTypeError;
|
||||
}
|
||||
|
||||
/*virtual*/ nsrefcnt
|
||||
orkinThumb::Release() // cut strong ref
|
||||
{
|
||||
morkEnv* ev = mHandle_Env;
|
||||
if ( ev && ev->IsEnv() )
|
||||
return this->Handle_CutStrongRef(ev->AsMdbEnv());
|
||||
else
|
||||
return morkEnv_kNonEnvTypeError;
|
||||
}
|
||||
// } ===== end nsIMdbObject methods =====
|
||||
|
||||
|
||||
// { ===== begin nsIMdbObject methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinThumb::IsFrozenMdbObject(nsIMdbEnv* mev, mdb_bool* outIsReadonly)
|
||||
{
|
||||
return this->Handle_IsFrozenMdbObject(mev, outIsReadonly);
|
||||
}
|
||||
// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin factory methods -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinThumb::GetMdbFactory(nsIMdbEnv* mev, nsIMdbFactory** acqFactory)
|
||||
{
|
||||
return this->Handle_GetMdbFactory(mev, acqFactory);
|
||||
}
|
||||
// } ----- end factory methods -----
|
||||
|
||||
// { ----- begin ref counting for well-behaved cyclic graphs -----
|
||||
/*virtual*/ mdb_err
|
||||
orkinThumb::GetWeakRefCount(nsIMdbEnv* mev, // weak refs
|
||||
mdb_count* outCount)
|
||||
{
|
||||
return this->Handle_GetWeakRefCount(mev, outCount);
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinThumb::GetStrongRefCount(nsIMdbEnv* mev, // strong refs
|
||||
mdb_count* outCount)
|
||||
{
|
||||
return this->Handle_GetStrongRefCount(mev, outCount);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinThumb::AddWeakRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_AddWeakRef(mev);
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinThumb::AddStrongRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_AddStrongRef(mev);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinThumb::CutWeakRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_CutWeakRef(mev);
|
||||
}
|
||||
/*virtual*/ mdb_err
|
||||
orkinThumb::CutStrongRef(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_CutStrongRef(mev);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinThumb::CloseMdbObject(nsIMdbEnv* mev)
|
||||
{
|
||||
return this->Handle_CloseMdbObject(mev);
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinThumb::IsOpenMdbObject(nsIMdbEnv* mev, mdb_bool* outOpen)
|
||||
{
|
||||
return this->Handle_IsOpenMdbObject(mev, outOpen);
|
||||
}
|
||||
// } ----- end ref counting -----
|
||||
|
||||
// } ===== end nsIMdbObject methods =====
|
||||
|
||||
|
||||
// { ===== begin nsIMdbThumb methods =====
|
||||
/*virtual*/ mdb_err
|
||||
orkinThumb::GetProgress(nsIMdbEnv* mev, mdb_count* outTotal,
|
||||
mdb_count* outCurrent, mdb_bool* outDone, mdb_bool* outBroken)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkEnv* ev = this->CanUseThumb(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
((morkThumb*) mHandle_Object)->GetProgress(ev, outTotal,
|
||||
outCurrent, outDone, outBroken);
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinThumb::DoMore(nsIMdbEnv* mev, mdb_count* outTotal,
|
||||
mdb_count* outCurrent, mdb_bool* outDone, mdb_bool* outBroken)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkEnv* ev = this->CanUseThumb(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkThumb* thumb = (morkThumb*) mHandle_Object;
|
||||
thumb->DoMore(ev, outTotal, outCurrent, outDone, outBroken);
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
|
||||
/*virtual*/ mdb_err
|
||||
orkinThumb::CancelAndBreakThumb(nsIMdbEnv* mev)
|
||||
{
|
||||
mdb_err outErr = 0;
|
||||
morkEnv* ev = this->CanUseThumb(mev, /*inMutable*/ morkBool_kFalse, &outErr);
|
||||
if ( ev )
|
||||
{
|
||||
morkThumb* thumb = (morkThumb*) mHandle_Object;
|
||||
thumb->mThumb_Done = morkBool_kTrue;
|
||||
thumb->mThumb_Broken = morkBool_kTrue;
|
||||
thumb->CloseMorkNode(ev); // should I close this here?
|
||||
outErr = ev->AsErr();
|
||||
}
|
||||
return outErr;
|
||||
}
|
||||
// } ===== end nsIMdbThumb methods =====
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
@ -1,164 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _ORKINTHUMB_
|
||||
#define _ORKINTHUMB_ 1
|
||||
|
||||
#ifndef _MDB_
|
||||
#include "mdb.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORK_
|
||||
#include "mork.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKNODE_
|
||||
#include "morkNode.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKHANDLE_
|
||||
#include "morkHandle.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKTHUMB_
|
||||
#include "morkThumb.h"
|
||||
#endif
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
#define morkMagic_kThumb 0x54686D62 /* ascii 'Thmb' */
|
||||
|
||||
/*| orkinThumb:
|
||||
|*/
|
||||
class orkinThumb : public morkHandle, public nsIMdbThumb { // nsIMdbObject
|
||||
|
||||
// { ===== begin morkNode interface =====
|
||||
public: // morkNode virtual methods
|
||||
// virtual void CloseMorkNode(morkEnv* ev); // morkHandle is fine
|
||||
virtual ~orkinThumb(); // morkHandle destructor does everything
|
||||
|
||||
protected: // construction is protected (use the static Make() method)
|
||||
orkinThumb(morkEnv* ev, // note morkUsage is always morkUsage_kPool
|
||||
morkHandleFace* ioFace, // must not be nil, cookie for this handle
|
||||
morkThumb* ioObject); // must not be nil, the object for this handle
|
||||
|
||||
// void CloseHandle(morkEnv* ev); // don't need to specialize closing
|
||||
|
||||
private: // copying is not allowed
|
||||
orkinThumb(const morkHandle& other);
|
||||
orkinThumb& operator=(const morkHandle& other);
|
||||
|
||||
// public: // dynamic type identification
|
||||
// mork_bool IsHandle() const //
|
||||
// { return IsNode() && mNode_Derived == morkDerived_kHandle; }
|
||||
// } ===== end morkNode methods =====
|
||||
|
||||
protected: // morkHandle memory management operators
|
||||
void* operator new(size_t inSize, morkPool& ioPool, morkZone& ioZone, morkEnv* ev) CPP_THROW_NEW
|
||||
{ return ioPool.NewHandle(ev, inSize, &ioZone); }
|
||||
|
||||
void* operator new(size_t inSize, morkPool& ioPool, morkEnv* ev) CPP_THROW_NEW
|
||||
{ return ioPool.NewHandle(ev, inSize, (morkZone*) 0); }
|
||||
|
||||
void* operator new(size_t inSize, morkHandleFace* ioFace) CPP_THROW_NEW
|
||||
{ MORK_USED_1(inSize); return ioFace; }
|
||||
|
||||
|
||||
public: // construction:
|
||||
|
||||
static orkinThumb* MakeThumb(morkEnv* ev, morkThumb* ioObject);
|
||||
|
||||
public: // utilities:
|
||||
|
||||
morkEnv* CanUseThumb(nsIMdbEnv* mev, mork_bool inMutable,
|
||||
mdb_err* outErr) const;
|
||||
|
||||
public: // type identification
|
||||
mork_bool IsOrkinThumb() const
|
||||
{ return mHandle_Magic == morkMagic_kThumb; }
|
||||
|
||||
mork_bool IsOrkinThumbHandle() const
|
||||
{ return this->IsHandle() && this->IsOrkinThumb(); }
|
||||
|
||||
public: // nsIMdbThumb
|
||||
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
// { ===== begin nsIMdbObject methods =====
|
||||
|
||||
// { ----- begin attribute methods -----
|
||||
NS_IMETHOD IsFrozenMdbObject(nsIMdbEnv* ev, mdb_bool* outIsReadonly);
|
||||
// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
|
||||
// } ----- end attribute methods -----
|
||||
|
||||
// { ----- begin factory methods -----
|
||||
NS_IMETHOD GetMdbFactory(nsIMdbEnv* ev, nsIMdbFactory** acqFactory);
|
||||
// } ----- end factory methods -----
|
||||
|
||||
// { ----- begin ref counting for well-behaved cyclic graphs -----
|
||||
NS_IMETHOD GetWeakRefCount(nsIMdbEnv* ev, // weak refs
|
||||
mdb_count* outCount);
|
||||
NS_IMETHOD GetStrongRefCount(nsIMdbEnv* ev, // strong refs
|
||||
mdb_count* outCount);
|
||||
|
||||
NS_IMETHOD AddWeakRef(nsIMdbEnv* ev);
|
||||
NS_IMETHOD AddStrongRef(nsIMdbEnv* ev);
|
||||
|
||||
NS_IMETHOD CutWeakRef(nsIMdbEnv* ev);
|
||||
NS_IMETHOD CutStrongRef(nsIMdbEnv* ev);
|
||||
|
||||
NS_IMETHOD CloseMdbObject(nsIMdbEnv* ev); // called at strong refs zero
|
||||
NS_IMETHOD IsOpenMdbObject(nsIMdbEnv* ev, mdb_bool* outOpen);
|
||||
// } ----- end ref counting -----
|
||||
|
||||
// } ===== end nsIMdbObject methods =====
|
||||
|
||||
// { ===== begin nsIMdbThumb methods =====
|
||||
NS_IMETHOD GetProgress(nsIMdbEnv* ev, mdb_count* outTotal,
|
||||
mdb_count* outCurrent, mdb_bool* outDone, mdb_bool* outBroken);
|
||||
|
||||
NS_IMETHOD DoMore(nsIMdbEnv* ev, mdb_count* outTotal,
|
||||
mdb_count* outCurrent, mdb_bool* outDone, mdb_bool* outBroken);
|
||||
|
||||
NS_IMETHOD CancelAndBreakThumb(nsIMdbEnv* ev);
|
||||
// } ===== end nsIMdbThumb methods =====
|
||||
};
|
||||
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
||||
#endif /* _ORKINTHUMB_ */
|
Loading…
Reference in New Issue
Block a user