OGRDataSource *OGRSFDriver::CopyDataSource( OGRDataSource *poSrcDS, const char *pszNewName, char **papszOptions ) { if( !TestCapability( ODrCCreateDataSource ) ) { CPLError( CE_Failure, CPLE_NotSupported, "%s driver does not support data source creation.", GetName() ); return NULL; } OGRDataSource *poODS; poODS = CreateDataSource( pszNewName, papszOptions ); if( poODS == NULL ) return NULL; /* -------------------------------------------------------------------- */ /* Process each data source layer. */ /* -------------------------------------------------------------------- */ for( int iLayer = 0; iLayer < poSrcDS->GetLayerCount(); iLayer++ ) { OGRLayer *poLayer = poSrcDS->GetLayer(iLayer); if( poLayer == NULL ) continue; poODS->CopyLayer( poLayer, poLayer->GetLayerDefn()->GetName(), papszOptions ); } return poODS; }
OGRDataSource *OGRSFDriver::CopyDataSource( OGRDataSource *poSrcDS, const char *pszNewName, char **papszOptions ) { if( !TestCapability( ODrCCreateDataSource ) ) { CPLError( CE_Failure, CPLE_NotSupported, "%s driver does not support data source creation.", GetName() ); return NULL; } OGRDataSource *poODS; poODS = CreateDataSource( pszNewName, papszOptions ); if( poODS == NULL ) return NULL; /* -------------------------------------------------------------------- */ /* Process each data source layer. */ /* -------------------------------------------------------------------- */ for( int iLayer = 0; iLayer < poSrcDS->GetLayerCount(); iLayer++ ) { OGRLayer *poLayer = poSrcDS->GetLayer(iLayer); if( poLayer == NULL ) continue; poODS->CopyLayer( poLayer, poLayer->GetLayerDefn()->GetName(), papszOptions ); } /* Make sure that the driver is attached to the created datasource */ /* It is also done in OGR_Dr_CopyDataSource() C method, in case */ /* another C++ implementation forgets to do it. Currently (Nov 2011), */ /* this implementation is the only one in the OGR source tree */ if( poODS != NULL && poODS->GetDriver() == NULL ) poODS->SetDriver( this ); return poODS; }
/** * This function sets up the variables required for a FormatDecode NewL call. * @param aIsFile - 'ETrue' if DataSource is file based, 'EFalse' if Descriptor based. * @param aNewL - Enum inicating which NewL function should be called. * @param aFilename - The filename containing the audio data. * @param aUid - Only required if aNewL is KNewLUid. */ void CTestStep_MMF_AFMT_NewL::SetupNewL(TBool aIsFile, const ENewLType& aNewL, const TDesC& aFilename, const TInt& aUid) { // We store the NewL to save having to repeat it in every call for the NewL tests... iNewL = aNewL; // Set the iDecode member variable depending on whether we are creating a decode // or encoding Format object. switch (aUid) { case KMmfUidFormatAUWrite: case KMmfUidFormatRAWWrite: case KMmfUidFormatWAVWrite: // Create the CMMFWavFormatWrite object. iDecode = EFalse; CreateDataSink(aIsFile, aFilename); break; case KMmfUidFormatAURead: case KMmfUidFormatRAWRead: case KMmfUidFormatWAVRead: // Create the CMMFWavFormatRead object. iDecode = ETrue; CreateDataSource(aIsFile, aFilename); break; default: INFO_PRINTF1(_L("Leaving from Setup as UID not supported")); User::Leave(KErrNotSupported); } switch (aNewL) { case KNewLUid: // Call NewL with a UID { iUID = TUid::Uid(aUid); break; } case KNewLFilename: // Call NewL with a filename { // Setup other parameters for the NewL call. iFilename.Set(aFilename); iPreferredSupplier.Set(KNoPreferredSupplier); break; } case KNewLDescriptor:// Call NewL with a Descriptor of data { // ReadFileToDescriptorL(iFilename, 0, KFormatDefaultFrameSize ); ReadFileToDescriptorL(aFilename, 0, KFormatDefaultFrameSize ); iPreferredSupplier.Set(KNoPreferredSupplier); break; } case KNewLClip: // Call NewL passing in a CMMFClip { iPreferredSupplier.Set(KNoPreferredSupplier); break; } default: User::Leave(KErrGeneral); } }