Remove Methods

WRAPPER_API bool Remove[Type](const BmgChar *code)

WRAPPER_API bool Remove[Type](const BmgChar *issuer, const BmgChar *code)

 

Above, [Type]is a placeholder for the class name of the desired object.

 

Description

The DataSource has a 'Remove' method for each type of object that can reside in the data source.  The 'Remove' method will delete an object from the data source that matches the identifiers passed as argument.  In order to remove an AngularUnit from the data source, one would use the RemoveAngularUnit method, and to remove a PrimeMeridian from the data source, one would use the RemovePrimeMeridian method.

There are two signatures for the 'Remove' methods.  The first signature takes a single argument, which is the code to identify the object in the data source.  The DefaultIssuer property will be used as the issuer to identify the object.  The second signature takes two arguments, the first of which is the issuer for the object, and the second of which is the code to identify the object in the data source.  

If the specified identifier does not exist in the DataSource, a GeoCalcException will be thrown with ErrorCode specifying IdentifierNotFound.  If the Editable property is false, then a GeoCalcException will be thrown with ErrorCode specifying FileReadOnly.

The signatures are different in the case of a Serializable object, where one must specify the ObjectType that corresponds to the type of the Serializable object.  In order to remove a Serializable from the data source using the DefaultIssuer property, one would call RemoveSerializable, specifying the ObjectType of the Serializable as the first argument, and the code to identify the object as the second argument.  In order to remove Serializable from the data source without using the DefaultIssuer property, one would call RemoveSerializable, specifying the ObjectType of the Serializable as the first argument, the issuer as the second argument, and the code as the third argument.

The following example shows how to remove an AngularUnit from the data source, but the usage is the same for all objects with the exception of Serializable.

 

Example

void DataSource_Remove(GEOCALCPBW_NAMESPACE::DataSource & data)

{

data.set_Editable(TRUE);

_towchar issuer("BMG");

_towchar code("ARCSECONDS");

try

{

data.RemoveAngularUnit(issuer.c_str(), code.c_str());

}

catch(GEOCALCPBW_NAMESPACE::GeoCalcException & ex)

{

if(ex.get_ErrorCode() == GEOCALCPBW_NAMESPACE::GeoCalcException::Code::IdentifierNotFound)

{

AfxMessageBox("RemoveAngularUnit failed: invalid identifiers");

}

}

if(! data.CommitToFile())

{

AfxMessageBox(CString("unable to save data source to ") + CString(_tochar(data.get_FileName()).c_str()));

}

}