Web Services Client for C++ は、ディープ・コピーをサポートします。 ディープ・コピーは、複合型に値を設定するときに、set メソッドで元のデータのプライベート・コピーを作成する方法です。その後、元のデータを変更または削除しても、複合型には影響はありません。また、メモリー・リークが起こらないようにするために、アプリケーションで元のデータを削除する必要があります。
//This is an example of deep copying. ComplexType * complexType = new ComplexType(); xsd__string aStringType = new char[9]; strcpy(aStringType, "Welcome!"); complexType->setaStringType(aStringType); // Note: By default deep copying will take place. delete [] aStringType; // This object is no longer required by the generated objects so can be deleted // at the earliest opportunity. Result result = ws.useComplexType(complexType); delete complexType; // This is an example of explicitly deep copying. ComplexType * complexType = new ComplexType(); xsd__string aStringType = new char[9]; strcpy(aStringType, "Welcome!"); complexType->setaStringType(aStringType, true); // Note: Use of additional parameter set to 'true' indicates deep copying is to // take place. delete [] aStringType; // This object is no longer required by the generated objects so can be deleted // at the earliest opportunity. Result result = ws.useComplexType(complexType); delete complexType;
// This is an example of shallow copying ComplexType * complexType = new ComplexType(); xsd__string aStringType = new char[9]; strcpy(aStringType, "Welcome!"); complexType->setaStringType(aStringType, false); // Note: Use of additional parameter set to 'false' indicates shallow // copying is to take place. Result result = ws.useComplexType(complexType); delete complexType; delete [] aStringType; // This object MUST NOT be deleted until generated object has been deleted.