summaryrefslogtreecommitdiff
path: root/connectivity/source/drivers/dbase/dindexnode.cxx
diff options
context:
space:
mode:
authorOcke Janssen <oj@openoffice.org>2001-05-23 08:18:28 +0000
committerOcke Janssen <oj@openoffice.org>2001-05-23 08:18:28 +0000
commit39dcd561255d9c1b438c618c9810a1b39eeb3d65 (patch)
treedcb67742d4f052c7f614c11cedc45bfef85a0af1 /connectivity/source/drivers/dbase/dindexnode.cxx
parentc6431349f002d326d811070c29534e12efbe53de (diff)
#86528# disable exception in some files
Diffstat (limited to 'connectivity/source/drivers/dbase/dindexnode.cxx')
-rw-r--r--connectivity/source/drivers/dbase/dindexnode.cxx359
1 files changed, 2 insertions, 357 deletions
diff --git a/connectivity/source/drivers/dbase/dindexnode.cxx b/connectivity/source/drivers/dbase/dindexnode.cxx
index c1ae7aebc2ed..56aa81ce2330 100644
--- a/connectivity/source/drivers/dbase/dindexnode.cxx
+++ b/connectivity/source/drivers/dbase/dindexnode.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: dindexnode.cxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: oj $ $Date: 2001-05-10 14:30:43 $
+ * last change: $Author: oj $ $Date: 2001-05-23 09:13:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -381,19 +381,6 @@ BOOL ONDXPage::Append(ONDXNode& rNode)
DBG_ASSERT(!IsFull(), "kein Append moeglich");
return Insert(nCount, rNode);
}
-
-//------------------------------------------------------------------
-void ONDXPage::Remove(USHORT nPos)
-{
- DBG_ASSERT(nCount > nPos, "falscher Indexzugriff");
-
- for (USHORT i = nPos; i < (nCount-1); i++)
- (*this)[i] = (*this)[i+1];
-
- nCount--;
- bModified = TRUE;
-}
-
//------------------------------------------------------------------
void ONDXPage::Release(BOOL bSave)
{
@@ -430,68 +417,6 @@ void ONDXPage::ReleaseFull(BOOL bSave)
aTempParent->GetChild().Clear();
}
}
-
-
-//------------------------------------------------------------------
-ONDXNode& ONDXPage::operator[] (USHORT nPos)
-{
- DBG_ASSERT(nCount > nPos, "falscher Indexzugriff");
- return ppNodes[nPos];
-}
-
-//------------------------------------------------------------------
-const ONDXNode& ONDXPage::operator[] (USHORT nPos) const
-{
- DBG_ASSERT(nCount > nPos, "falscher Indexzugriff");
- return ppNodes[nPos];
-}
-
-//------------------------------------------------------------------
-// laeuft rekursiv
-void ONDXPage::SearchAndReplace(const ONDXKey& rSearch,
- ONDXKey& rReplace)
-{
- if (rSearch == rReplace)
- return;
-
- USHORT nPos = NODE_NOTFOUND;
- ONDXPage* pPage = this;
-
- while (pPage && (nPos = pPage->Search(rSearch)) == NODE_NOTFOUND)
- pPage = pPage->aParent;
-
- if (pPage)
- {
- (*pPage)[nPos].GetKey() = rReplace;
- pPage->SetModified(TRUE);
- }
-}
-
-//------------------------------------------------------------------
-USHORT ONDXPage::Search(const ONDXKey& rSearch)
-{
- // binare Suche spaeter
- USHORT i = 0xFFFF;
- while (++i < Count())
- if ((*this)[i].GetKey() == rSearch)
- break;
-
- return (i < Count()) ? i : NODE_NOTFOUND;
-}
-
-//------------------------------------------------------------------
-USHORT ONDXPage::Search(const ONDXPage* pPage)
-{
- USHORT i = 0xFFFF;
- while (++i < Count())
- if (((*this)[i]).GetChild() == pPage)
- break;
-
- // wenn nicht gefunden, dann wird davon ausgegangen, dass die Seite selbst
- // auf die Page zeigt
- return (i < Count()) ? i : NODE_NOTFOUND;
-}
-
//------------------------------------------------------------------
BOOL ONDXPage::Delete(USHORT nNodePos)
{
@@ -812,242 +737,9 @@ void ONDXPage::Merge(USHORT nParentNodePos, ONDXPagePtr xPage)
}
}
// -------------------------------------------------------------------------
-BOOL ONDXPage::IsFull() const
-{
- return Count() == rIndex.getHeader().db_maxkeys;
-}
-
-#ifdef DEBUG
-//------------------------------------------------------------------
-void ONDXPage::PrintPage()
-{
- DBG_TRACE4("\nSDB: -----------Page: %d Parent: %d Count: %d Child: %d-----",
- nPagePos, HasParent() ? aParent->GetPagePos() : 0 ,nCount, aChild.GetPagePos());
-
- for (USHORT i = 0; i < nCount; i++)
- {
- ONDXNode rNode = (*this)[i];
- ONDXKey& rKey = rNode.GetKey();
- if (!IsLeaf())
- rNode.GetChild(&rIndex, this);
-
- if (rKey.getValue().isNull())
- {
- DBG_TRACE2("SDB: [%d,NULL,%d]",rKey.GetRecord(), rNode.GetChild().GetPagePos());
- }
- else if (rIndex.getHeader().db_keytype)
- {
- DBG_TRACE3("SDB: [%d,%f,%d]",rKey.GetRecord(), rKey.getValue().getDouble(),rNode.GetChild().GetPagePos());
- }
- else
- {
- DBG_TRACE3("SDB: [%d,%s,%d]",rKey.GetRecord(), (const char* )ByteString(rKey.getValue().getString().getStr(), rIndex.m_pTable->getConnection()->getTextEncoding()).GetBuffer(),rNode.GetChild().GetPagePos());
- }
- }
- DBG_TRACE("SDB: -----------------------------------------------\n");
- if (!IsLeaf())
- {
- GetChild(&rIndex)->PrintPage();
- for (USHORT i = 0; i < nCount; i++)
- {
- ONDXNode rNode = (*this)[i];
- rNode.GetChild(&rIndex,this)->PrintPage();
- }
- }
- DBG_TRACE("SDB: ===============================================\n");
-}
-#endif
-
-
-static UINT32 nValue;
-//------------------------------------------------------------------
-SvStream& connectivity::dbase::operator >> (SvStream &rStream, ONDXPage& rPage)
-{
- rStream.Seek(rPage.GetPagePos() * 512);
- rStream >> nValue >> rPage.aChild;
- rPage.nCount = USHORT(nValue);
-
-// DBG_ASSERT(rPage.nCount && rPage.nCount < rPage.GetIndex().GetMaxNodes(), "Falscher Count");
- for (USHORT i = 0; i < rPage.nCount; i++)
- rPage[i].Read(rStream, rPage.GetIndex());
- return rStream;
-}
-
-//------------------------------------------------------------------
-SvStream& connectivity::dbase::operator << (SvStream &rStream, const ONDXPage& rPage)
-{
- // Seite existiert noch nicht
- ULONG nSize = (rPage.GetPagePos() + 1) * 512;
- if (nSize > rStream.Seek(STREAM_SEEK_TO_END))
- {
- rStream.SetStreamSize(nSize);
- rStream.Seek(rPage.GetPagePos() * 512);
-
- char aEmptyData[512];
- memset(aEmptyData,0x00,512);
- rStream.Write((BYTE*)aEmptyData,512);
- }
- ULONG nCurrentPos = rStream.Seek(rPage.GetPagePos() * 512);
-
- nValue = rPage.nCount;
- rStream << nValue << rPage.aChild;
-
- USHORT i = 0;
- for (; i < rPage.nCount; i++)
- rPage[i].Write(rStream, rPage);
-
- // check if we have to fill the stream with '\0'
- if(i < rPage.rIndex.getHeader().db_maxkeys)
- {
- ULONG nTell = rStream.Tell() % 512;
- USHORT nBufferSize = rStream.GetBufferSize();
- ULONG nSize = nBufferSize - nTell;
- char* pEmptyData = new char[nSize];
- memset(pEmptyData,0x00,nSize);
- rStream.Write((BYTE*)pEmptyData,nSize);
- rStream.Seek(nTell);
- delete pEmptyData;
- }
- return rStream;
-}
-
-//==================================================================
-// ONDXNode
-//==================================================================
-
-//------------------------------------------------------------------
-void ONDXNode::Read(SvStream &rStream, ODbaseIndex& rIndex)
-{
- rStream >> (sal_uInt32)aKey.nRecord; // schluessel
- if (rIndex.getHeader().db_keytype)
- {
- double aDbl;
- rStream >> aDbl;
- aKey = ONDXKey(aDbl,aKey.nRecord);
- }
- else
- {
- ByteString aBuf;
- USHORT nLen = rIndex.getHeader().db_keylen;
- char* pStr = aBuf.AllocBuffer(nLen+1);
-
- rStream.Read(pStr,nLen);
- pStr[nLen] = 0;
- aBuf.ReleaseBufferAccess();
- aBuf.EraseTrailingChars();
-
- // aKey = ONDXKey((aBuf,rIndex.GetDBFConnection()->GetCharacterSet()) ,aKey.nRecord);
- aKey = ONDXKey(::rtl::OUString(aBuf.GetBuffer(),aBuf.Len(),rIndex.m_pTable->getConnection()->getTextEncoding()) ,aKey.nRecord);
- }
- rStream >> aChild;
-}
-
-union
-{
- double aDbl;
- char aData[128];
-} aNodeData;
-//------------------------------------------------------------------
-void ONDXNode::Write(SvStream &rStream, const ONDXPage& rPage) const
-{
- const ODbaseIndex& rIndex = rPage.GetIndex();
- if (!rIndex.isUnique() || rPage.IsLeaf())
- rStream << (sal_uInt32)aKey.nRecord; // schluessel
- else
- rStream << (sal_uInt32)0; // schluessel
-
- if (rIndex.getHeader().db_keytype) // double
- {
- if (aKey.getValue().isNull())
- {
- memset(aNodeData.aData,0,rIndex.getHeader().db_keylen);
- rStream.Write((BYTE*)aNodeData.aData,rIndex.getHeader().db_keylen);
- }
- else
- rStream << (double) aKey.getValue();
- }
- else
- {
- memset(aNodeData.aData,0x20,rIndex.getHeader().db_keylen);
- if (!aKey.getValue().isNull())
- {
- ::rtl::OUString sValue = aKey.getValue();
- ByteString aText(sValue.getStr(), rIndex.m_pTable->getConnection()->getTextEncoding());
- strncpy(aNodeData.aData,aText.GetBuffer(),min(rIndex.getHeader().db_keylen, aText.Len()));
- }
- rStream.Write((BYTE*)aNodeData.aData,rIndex.getHeader().db_keylen);
- }
- rStream << aChild;
-}
-
-
-//------------------------------------------------------------------
-ONDXPagePtr& ONDXNode::GetChild(ODbaseIndex* pIndex, ONDXPage* pParent)
-{
- if (!aChild.Is() && pIndex)
- {
- aChild = pIndex->CreatePage(aChild.GetPagePos(),pParent,aChild.HasPage());
- }
- return aChild;
-}
-
-//==================================================================
-// ONDXKey
-//==================================================================
-//------------------------------------------------------------------
-BOOL ONDXKey::IsText(sal_Int32 eType)
-{
- return eType == DataType::VARCHAR || eType == DataType::CHAR;
-}
-
-//------------------------------------------------------------------
-StringCompare ONDXKey::Compare(const ONDXKey& rKey) const
-{
- // DBG_ASSERT(is(), "Falscher Indexzugriff");
- StringCompare eResult;
- if (getValue().isNull())
- {
- if (rKey.getValue().isNull() || (rKey.IsText(getDBType()) && !rKey.getValue().getString().getLength()))
- eResult = COMPARE_EQUAL;
- else
- eResult = COMPARE_LESS;
- }
- else if (rKey.getValue().isNull())
- {
- if (getValue().isNull() || (IsText(getDBType()) && !getValue().getString().getLength()))
- eResult = COMPARE_EQUAL;
- else
- eResult = COMPARE_GREATER;
- }
- else if (IsText(getDBType()))
- {
- INT32 nRes = getValue().getString().compareTo(rKey.getValue());
- eResult = (nRes > 0) ? COMPARE_GREATER : (nRes == 0) ? COMPARE_EQUAL : COMPARE_LESS;
- }
- else
- {
- double m = getValue(),n = rKey.getValue();
- eResult = (m > n) ? COMPARE_GREATER : (n == m) ? COMPARE_EQUAL : COMPARE_LESS;
- }
- // Record vergleich, wenn Index !Unique
- if (eResult == COMPARE_EQUAL && nRecord && rKey.nRecord)
- eResult = (nRecord > rKey.nRecord) ? COMPARE_GREATER :
- (nRecord == rKey.nRecord) ? COMPARE_EQUAL : COMPARE_LESS;
- return eResult;
-}
-// -----------------------------------------------------------------------------
-void ONDXKey::setValue(const ORowSetValue& _rVal)
-{
- xValue = _rVal;
-}
-// -----------------------------------------------------------------------------
-const ORowSetValue& ONDXKey::getValue() const
-{
- return xValue;
-}
// -----------------------------------------------------------------------------
//namespace connectivity
//{
@@ -1056,52 +748,5 @@ const ORowSetValue& ONDXKey::getValue() const
// SV_IMPL_REF(ONDXPage);
// }
//}
-//==================================================================
-// ONDXPagePtr
-//==================================================================
-//------------------------------------------------------------------
-SvStream& connectivity::dbase::operator >> (SvStream &rStream, ONDXPagePtr& rPage)
-{
- rStream >> rPage.nPagePos;
- return rStream;
-}
-
-//------------------------------------------------------------------
-SvStream& connectivity::dbase::operator << (SvStream &rStream, const ONDXPagePtr& rPage)
-{
- rStream << rPage.nPagePos;
- return rStream;
-}
-//------------------------------------------------------------------
-ONDXPagePtr::ONDXPagePtr(const ONDXPagePtr& rRef)
- :ONDXPageRef(rRef)
- ,nPagePos(rRef.nPagePos)
-{
-}
-
-//------------------------------------------------------------------
-ONDXPagePtr::ONDXPagePtr(ONDXPage* pRefPage)
- :ONDXPageRef(pRefPage)
- ,nPagePos(0)
-{
- if (pRefPage)
- nPagePos = pRefPage->GetPagePos();
-}
-//------------------------------------------------------------------
-ONDXPagePtr& ONDXPagePtr::operator=(const ONDXPagePtr& rRef)
-{
- ONDXPageRef::operator=(rRef);
- nPagePos = rRef.nPagePos;
- return *this;
-}
-
-//------------------------------------------------------------------
-ONDXPagePtr& ONDXPagePtr::operator= (ONDXPage* pRef)
-{
- ONDXPageRef::operator=(pRef);
- nPagePos = (pRef) ? pRef->GetPagePos() : 0;
- return *this;
-}
-// -----------------------------------------------------------------------------