1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0026937: Eliminate NO_CXX_EXCEPTION macro support

Macro NO_CXX_EXCEPTION was removed from code.
Method Raise() was replaced by explicit throw statement.
Method Standard_Failure::Caught() was replaced by normal C++mechanism of exception transfer.
Method Standard_Failure::Caught() is deprecated now.
Eliminated empty constructors.
Updated samples.
Eliminate empty method ChangeValue from NCollection_Map class.
Removed not operable methods from NCollection classes.
This commit is contained in:
ski
2017-02-02 16:35:21 +03:00
committed by apn
parent 0c63f2f8b9
commit 9775fa6110
1146 changed files with 4860 additions and 6183 deletions

View File

@@ -98,8 +98,8 @@ void NCollection_AccAllocator::Free(void* theAddress)
#if !defined No_Exception && !defined No_Standard_ProgramError
if (aBlock == 0L || aBlock->IsEmpty())
{
Standard_ProgramError::Raise("NCollection_AccAllocator::Free: \
Trying to free an invalid address");
throw Standard_ProgramError("NCollection_AccAllocator::Free: \
Trying to free an invalid address");
}
#endif

View File

@@ -216,7 +216,7 @@ void NCollection_BaseSequence::PInsertAfter (const Standard_Integer theIndex,
NCollection_BaseSequence& Other)
{
if (theIndex < 0 || theIndex > mySize)
Standard_OutOfRange::Raise();
throw Standard_OutOfRange();
if (Other.mySize != 0) {
if (theIndex == 0)
PPrepend (Other);

View File

@@ -246,7 +246,7 @@ protected:
ListNode()
{
// Empty constructor is forbidden.
Standard_NoSuchObject::Raise("NCollection_CellFilter::ListNode()");
throw Standard_NoSuchObject("NCollection_CellFilter::ListNode()");
}
Target Object;

View File

@@ -301,7 +301,7 @@ class NCollection_DataMap : public NCollection_BaseMap
{
DataMapNode* p = 0;
if (!lookup(theKey, p))
Standard_NoSuchObject::Raise("NCollection_DataMap::Find");
throw Standard_NoSuchObject("NCollection_DataMap::Find");
return p->Value();
}
@@ -337,7 +337,7 @@ class NCollection_DataMap : public NCollection_BaseMap
{
DataMapNode* p = 0;
if (!lookup(theKey, p))
Standard_NoSuchObject::Raise("NCollection_DataMap::Find");
throw Standard_NoSuchObject("NCollection_DataMap::Find");
return p->ChangeValue();
}

View File

@@ -112,12 +112,6 @@ class NCollection_DoubleMap : public NCollection_BaseMap
Standard_NoSuchObject_Raise_if (!More(), "NCollection_DoubleMap::Iterator::Value");
return ((DoubleMapNode *) myNode)->Value();
}
//! Value change access - denied
TheKey2Type& ChangeValue(void) const
{
Standard_ImmutableObject::Raise("NCollection_DoubleMap::Iterator::ChangeValue");
return * (TheKey2Type *) NULL; // For compiler
}
};
public:
@@ -219,14 +213,14 @@ class NCollection_DoubleMap : public NCollection_BaseMap
while (pNode)
{
if (Hasher1::IsEqual (pNode->Key1(), theKey1))
Standard_MultiplyDefined::Raise("NCollection_DoubleMap:Bind");
throw Standard_MultiplyDefined("NCollection_DoubleMap:Bind");
pNode = (DoubleMapNode *) pNode->Next();
}
pNode = (DoubleMapNode *) myData2[iK2];
while (pNode)
{
if (Hasher2::IsEqual (pNode->Key2(), theKey2))
Standard_MultiplyDefined::Raise("NCollection_DoubleMap:Bind");
throw Standard_MultiplyDefined("NCollection_DoubleMap:Bind");
pNode = (DoubleMapNode *) pNode->Next();
}
pNode = new (this->myAllocator) DoubleMapNode (theKey1, theKey2,
@@ -403,8 +397,7 @@ class NCollection_DoubleMap : public NCollection_BaseMap
return pNode1->Key2();
pNode1 = (DoubleMapNode*) pNode1->Next();
}
Standard_NoSuchObject::Raise("NCollection_DoubleMap::Find1");
return pNode1->Key2(); // This for compiler
throw Standard_NoSuchObject("NCollection_DoubleMap::Find1");
}
//! Find2
@@ -419,8 +412,7 @@ class NCollection_DoubleMap : public NCollection_BaseMap
return pNode2->Key1();
pNode2 = (DoubleMapNode*) pNode2->Next2();
}
Standard_NoSuchObject::Raise("NCollection_DoubleMap::Find2");
return pNode2->Key1(); // This for compiler
throw Standard_NoSuchObject("NCollection_DoubleMap::Find2");
}
//! Clear data. If doReleaseMemory is false then the table of

View File

@@ -34,7 +34,7 @@ void * NCollection_HeapAllocator::Allocate (const Standard_Size theSize)
{
char aBuffer[96];
Sprintf (aBuffer, "Failed to allocate %" PRIuPTR " bytes in global dynamic heap", theSize);
Standard_OutOfMemory::Raise (aBuffer);
throw Standard_OutOfMemory(aBuffer);
}
return aResult;
}

View File

@@ -194,7 +194,7 @@ NCollection_IncAllocator::NCollection_IncAllocator (const size_t theBlockSize)
mySize = aSize - IMEM_SIZE(sizeof(IBlock));
myMemSize = aSize * sizeof(aligned_t);
if (aBlock == NULL)
Standard_OutOfMemory::Raise("NCollection_IncAllocator: out of memory");
throw Standard_OutOfMemory("NCollection_IncAllocator: out of memory");
aBlock -> p_free_space = (aligned_t *) IMEM_ALIGN (&aBlock[1]);
aBlock -> p_end_block = ((aligned_t *) aBlock) + aSize;
aBlock -> p_next = NULL;
@@ -233,7 +233,7 @@ void * NCollection_IncAllocator::Allocate (const size_t aSize)
if (aResult)
myFirstBlock -> p_free_space = myFirstBlock -> p_end_block;
else
Standard_OutOfMemory::Raise("NCollection_IncAllocator: out of memory");
throw Standard_OutOfMemory("NCollection_IncAllocator: out of memory");
} else
if (cSize <= IMEM_FREE(myFirstBlock)) {
/* If the requested size fits into the free space in the 1st block */
@@ -259,14 +259,14 @@ void * NCollection_IncAllocator::Allocate (const size_t aSize)
{
const size_t aDefault = IMEM_SIZE(DefaultBlockSize);
if (cSize > aDefault)
Standard_OutOfMemory::Raise("NCollection_IncAllocator: out of memory");
throw Standard_OutOfMemory("NCollection_IncAllocator: out of memory");
else
{
aResult = (aligned_t *) allocateNewBlock (aDefault);
if (aResult)
myFirstBlock -> p_free_space = aResult + cSize;
else
Standard_OutOfMemory::Raise("NCollection_IncAllocator: out of memory");
throw Standard_OutOfMemory("NCollection_IncAllocator: out of memory");
}
}
}
@@ -327,7 +327,7 @@ void * NCollection_IncAllocator::Reallocate (void * theAddress,
}
else
{
Standard_OutOfMemory::Raise("NCollection_IncAllocator: out of memory");
throw Standard_OutOfMemory("NCollection_IncAllocator: out of memory");
}
return aResult;
}

View File

@@ -306,8 +306,8 @@ class NCollection_IndexedDataMap : public NCollection_BaseMap
{
if (p->Key2() != theIndex)
{
Standard_DomainError::Raise ("NCollection_IndexedDataMap::Substitute : "
"Attempt to substitute existing key");
throw Standard_DomainError ("NCollection_IndexedDataMap::Substitute : "
"Attempt to substitute existing key");
}
p->Key1() = theKey1;
p->ChangeValue() = theItem;
@@ -443,7 +443,7 @@ class NCollection_IndexedDataMap : public NCollection_BaseMap
IndexedDataMapNode* aNode = nodeFromIndex (theKey2);
if (aNode == NULL)
{
Standard_NoSuchObject::Raise ("NCollection_IndexedDataMap::FindKey");
throw Standard_NoSuchObject("NCollection_IndexedDataMap::FindKey");
}
return aNode->Key1();
}
@@ -456,7 +456,7 @@ class NCollection_IndexedDataMap : public NCollection_BaseMap
IndexedDataMapNode* aNode = nodeFromIndex (theKey2);
if (aNode == NULL)
{
Standard_NoSuchObject::Raise ("NCollection_IndexedDataMap::FindFromIndex");
throw Standard_NoSuchObject("NCollection_IndexedDataMap::FindFromIndex");
}
return aNode->Value();
}
@@ -473,7 +473,7 @@ class NCollection_IndexedDataMap : public NCollection_BaseMap
IndexedDataMapNode* aNode = nodeFromIndex (theKey2);
if (aNode == NULL)
{
Standard_NoSuchObject::Raise ("NCollection_IndexedDataMap::ChangeFromIndex");
throw Standard_NoSuchObject("NCollection_IndexedDataMap::ChangeFromIndex");
}
return aNode->ChangeValue();
}
@@ -510,8 +510,7 @@ class NCollection_IndexedDataMap : public NCollection_BaseMap
return pNode1->Value();
pNode1 = (IndexedDataMapNode*) pNode1->Next();
}
Standard_NoSuchObject::Raise("NCollection_IndexedDataMap::FindFromKey");
return pNode1->Value();
throw Standard_NoSuchObject("NCollection_IndexedDataMap::FindFromKey");
}
//! ChangeFromKey
@@ -527,8 +526,7 @@ class NCollection_IndexedDataMap : public NCollection_BaseMap
return pNode1->ChangeValue();
pNode1 = (IndexedDataMapNode*) pNode1->Next();
}
Standard_NoSuchObject::Raise("NCollection_IndexedDataMap::ChangeFromKey");
return pNode1->ChangeValue();
throw Standard_NoSuchObject("NCollection_IndexedDataMap::ChangeFromKey");
}
//! Seek returns pointer to Item by Key. Returns

View File

@@ -20,7 +20,6 @@
#include <NCollection_TListNode.hxx>
#include <NCollection_StlIterator.hxx>
#include <Standard_NoSuchObject.hxx>
#include <Standard_ImmutableObject.hxx>
#include <NCollection_DefaultHasher.hxx>
@@ -104,12 +103,7 @@ class NCollection_IndexedMap : public NCollection_BaseMap
Standard_NoSuchObject_Raise_if(!More(), "NCollection_IndexedMap::Iterator::Value");
return myMap->FindKey(myIndex);
}
//! Value change access denied - use Substitute
TheKeyType& ChangeValue(void) const
{
Standard_ImmutableObject::Raise ("impossible to ChangeValue");
return * (TheKeyType *) NULL; // This for compiler
}
//! Performs comparison of two iterators.
Standard_Boolean IsEqual (const Iterator& theOther) const
{
@@ -277,8 +271,8 @@ class NCollection_IndexedMap : public NCollection_BaseMap
{
if (p->Key2() != theIndex)
{
Standard_DomainError::Raise ("NCollection_IndexedMap::Substitute : "
"Attempt to substitute existing key");
throw Standard_DomainError ("NCollection_IndexedMap::Substitute : "
"Attempt to substitute existing key");
}
p->Key1() = theKey1;
return;
@@ -417,8 +411,7 @@ class NCollection_IndexedMap : public NCollection_BaseMap
return pNode2->Key1();
pNode2 = (IndexedMapNode*) pNode2->Next2();
}
Standard_NoSuchObject::Raise("NCollection_IndexedMap::FindKey");
return pNode2->Key1(); // This for compiler
throw Standard_NoSuchObject("NCollection_IndexedMap::FindKey");
}
//! operator ()

View File

@@ -22,7 +22,6 @@
#include <NCollection_StlIterator.hxx>
#include <NCollection_DefaultHasher.hxx>
#include <Standard_ImmutableObject.hxx>
#include <Standard_NoSuchObject.hxx>
/**
@@ -96,12 +95,7 @@ class NCollection_Map : public NCollection_BaseMap
Standard_NoSuchObject_Raise_if (!More(), "NCollection_Map::Iterator::Value");
return ((MapNode *) myNode)->Value();
}
//! Value change access - denied
TheKeyType& ChangeValue(void) const
{
Standard_ImmutableObject::Raise("NCollection_Map::Iterator::ChangeValue");
return * (TheKeyType *) NULL; // For compiler
}
//! Key
const TheKeyType& Key (void) const
{

View File

@@ -74,7 +74,7 @@ void* NCollection_WinHeapAllocator::Allocate (const Standard_Size theSize)
{
char aBuf[128];
Sprintf (aBuf, "Failed to allocate %" PRIuPTR " bytes in local dynamic heap", theSize);
Standard_OutOfMemory::Raise (aBuf);
throw Standard_OutOfMemory(aBuf);
}
return aResult;
}