CommitToFile Method

WRAPPER_API bool CommitToFile()

WRAPPER_API bool CommitToFile(const BmgChar *fileName)

 

Description

The CommitToFile method saves the contents of the DataSource to a file. There are two signatures for this method. The first signature takes no arguments and saves the DataSource to the files specified by the FileName and CustomFileName properties. Note that if the datasource is non-Editable, the base data source will not be saved. If there is a specified custom data source, it will always be Editable and thus we will always attempt to save custom data.

The second signature takes a single argument that indicates the path to the file to which the DataSource should be saved. If a custom file was being used, the save will combine both custom and base data into a single datasource file to be saved. Note that saving in this fashion will not reset the number of modifications registered in the data source.

During the CommitToFile the current default DataView will also be saved to its current location (or, in the case of the second signature, to a new view file named to match the output datasource xml file but with a .xvw extension).

Both methods return a boolean value indicating the success of the operation.

 

Example

void DataSource_CommitToFile(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()));

}

}