WebSphere Web Services Client for C++, Version 1.0.1 オペレーティング・システム: Linux, Windows

ディープ・コピー

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;
注: Web Services Client for C++ では、シャロー・コピーはサポートされません。シャロー・コピーでは、複合型に値を設定するときに、set メソッドが元のデータへの参照 (またはポインター) を維持します。 複合型のライフ・サイクルの間は (つまり、複合型が削除されるまで)、元のデータを変更してはならず、削除もできません。メモリー・リークが起こらないようにするために、アプリケーションで元のデータを削除する必要があります。
// 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.

Reference topic

ご利用条件 | フィードバック (英語のみ)

Timestamp icon最終更新: 12 Jun 2006
(C) Copyright IBM Corporation 2005, 2006. All Rights Reserved.
このインフォメーション・センターでは Eclipse テクノロジーが採用されています。(http://www.eclipse.org)