int axiscAxisDelete()

in src/cbindings/AxisC.cpp [94:221]


int axiscAxisDelete(void * pValue,  
                    AXISC_XSDTYPE type)
{
    int rc = AXISC_SUCCESS;
    
    try 
    {
        if (pValue == NULL)
            return rc;
            
        // There are some types we cannot pass to C++ engine
        switch (type)
        {
            case XSDC_DURATION:
            case XSDC_DATETIME:
            case XSDC_TIME:
            case XSDC_DATE:
            case XSDC_GYEARMONTH:
            case XSDC_GYEAR:
            case XSDC_GMONTHDAY:
            case XSDC_GDAY:
            case XSDC_GMONTH:
            case XSDC_STRING:
            case XSDC_NORMALIZEDSTRING:
            case XSDC_TOKEN:
            case XSDC_LANGUAGE:
            case XSDC_NAME:
            case XSDC_NCNAME:
            case XSDC_ID:
            case XSDC_IDREF:
            case XSDC_IDREFS:
            case XSDC_ENTITY:
            case XSDC_ENTITIES:
            case XSDC_NMTOKEN:
            case XSDC_NMTOKENS:
            case XSDC_BOOLEAN:
            case XSDC_FLOAT:
            case XSDC_DECIMAL:
            case XSDC_NONPOSITIVEINTEGER:
            case XSDC_NEGATIVEINTEGER:
            case XSDC_INTEGER:
            case XSDC_LONG:
            case XSDC_INT:
            case XSDC_SHORT:
            case XSDC_BYTE:
            case XSDC_NONNEGATIVEINTEGER:
            case XSDC_UNSIGNEDLONG:
            case XSDC_UNSIGNEDINT:
            case XSDC_UNSIGNEDSHORT:
            case XSDC_UNSIGNEDBYTE:
            case XSDC_POSITIVEINTEGER:
            case XSDC_DOUBLE:
            case XSDC_ANYURI:
            case XSDC_QNAME:
            case XSDC_NOTATION:
            case C_USER_TYPE:
            case C_ATTACHMENT:
            case XSDC_UNKNOWN:
            case XSDC_ANYTYPE:
            {
                Axis::AxisDelete(pValue, (XSDTYPE) type);
                break;
            }
            case XSDC_ARRAY:
            {
                Axisc_Array *array = (Axisc_Array*)pValue;
                
                // Delete array elements via recursion
                if (array->m_Array)
                {
                	for (int i=0; i<array->m_Size; ++i)
                    	if (array->m_Array[i])
                        	axiscAxisDelete(array->m_Array[i], array->m_Type);
                    delete [] array->m_Array;
                }

                // Delete array
                delete array;
                break;
            }
            case XSDC_BASE64BINARY:
            {
                xsdc__base64Binary* b64 = (xsdc__base64Binary*) pValue;
                if (b64->__ptr)
                    delete [] b64->__ptr;
                delete b64;
                break;
            }
            case XSDC_HEXBINARY:
            {
                xsdc__hexBinary* hb = (xsdc__hexBinary*) pValue;
                if (hb->__ptr)
                    delete [] hb->__ptr;
                delete hb;
                break;
            }
            case XSDC_ANY:
            {
                AxiscAnyType *anytype = (AxiscAnyType *)pValue;
				if (anytype->_size > 0 && anytype->_array) 
				{
					for (int i=0; i<anytype->_size; i++)
						if (anytype->_array[i]) 
							delete [] anytype->_array[i];
                    
                    delete [] anytype->_array;
				}
				delete anytype;
                break;
            }
            
            default:
                ;
        }
    }
    catch ( AxisException& e  )
    {
        axiscAxisInvokeExceptionHandler(e.getExceptionCode(), e.what(), NULL, NULL);
        rc = AXISC_FAIL;    
    }
    catch ( ... )
    {
        axiscAxisInvokeExceptionHandler(-1, "Unrecognized exception thrown.", NULL, NULL);
        rc = AXISC_FAIL;
    }    
    
    return rc;
}