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

入力パラメーターとしての配列型

プロトタイプ・メソッドでは、入力配列を作成する必要があります。この配列は、適切に作成し管理する必要があります。

配列を入力パラメーターとして使用する場合は、配列を作成しデータを入力する必要があります。

次の例では、生成されたスタブが必要とする nillable の単純配列型の一般的な使用法を示しています。この配列は、メソッドに対する入力配列の例です。この例では、配列に値がそれぞれ 0、1、2 の 3 つのエレメントが含まれていることが前提となっています。

// Need an input array of 3 elements.
int iArraySize = 3;
// Final object type to be passed as an input parameter to the web service.
xsd__int_Array iInputArray;
// Preparatory array that contains the values to be passed. Note that the
// array is an array of pointers of the required type.
xsd__int ** ppiPrepArray = new xsd__int*[iArraySize];
// Loop used to populate the preparatory array.
for( int iCount = 0 ; iCount < iArraySize ; iCount++)
{
// Each element in the array of type pointers is filled with a pointer to an
// object of the required type. In this example we have chosen the value of
// each element to be the same as the current count and so have passed this
// value to the new instance of the pointer.
ppiPrepArray[iCount] = new xsd__int( iCount);
}
// Set the contents of the final object to contain the elements of the
// preparatory array.
iInputArray.set( ppiPrepArray, iArraySize);
… Call the web service(s) that use the input array …
// No longer require iInputArray. Delete the preparatory array held within.
for( int iCount = 0 ; iCount < iArraySize ; iCount++)
{
// Delete each pointer in the pointer array.
delete ppiPrepArray[iCount];
ppiPrepArray[iCount] = NULL;
}
// Delete the array of pointers and then set the value to NULL so that it
// cannot be reused.
delete [] ppiPrepArray;
ppiPrepArray = NULL;

メソッドが戻ると、iInputType を破棄することができます。iInputType がポインター (piInputType) として作成された場合は、クライアント・ユーザー・コードで削除することを覚えておく必要があります。そうでないと、コードにより、メモリー・リークが発生することになります。


Reference topic

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

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