PBArrayAccessor template class:
SetAt method
Description
Sets the array item at the specified dimension.
Syntax
For arrays of a specified ValueType:
SetAt(pblong dim[ ], ValueType v)
For string arrays:
SetAt(pblong dim[ ], LPCTSTR string)
SetAt(pblong dim[ ], pbstring string)
Argument |
Description |
---|---|
dim |
The dimension of the array item to be set |
v |
A ValueType defined in pbtraits.h |
string |
A string of type pbstring or LPCTSTR |
Return Values
None.
Examples
This example shows the use of GetAt and SetAt in arrays of a type specified by a ValueType:
template < typename T, pbvalue_type I>
void ArrayCreator<T, I>::f_unbounded_simple_array(
IPB_Session* session,
ifstream in,
fstream out,
LPCSTR data_type)
{
pbarray out_array;
int i;
pblong dim[4], itemcount1, itemcount2;
T *iarg, oarg;
in >> itemcount1;
iarg = new T[itemcount1];
// Create unbounded integer array
{
PBUnboundedArrayCreator<I> ac(session);
out_array = ac.GetArray();
PBArrayAccessor<I> aa(session, out_array);
for(i=0; i<itemcount1; i++)
in >> iarg[i];
for (i=0; i<itemcount1; i++)
{
dim[0]=i+1;
aa.SetAt(dim, iarg[i]);
}
itemcount2 = session->GetArrayItemCount(out_array);
out <<"The array item count is "<< itemcount2 <<
endl;
for (i=0; i<itemcount2; i++)
{
dim[0]=i+1;
oarg=aa.GetAt(dim);
if (oarg != iarg[i])
out << "*** ERROR"<< endl;
else
out << oarg << " ";
}
}
delete []iarg;
out << endl;
return;
}