SpiceInt size_c ( SpiceCell * cell )
Return the size (maximum cardinality) of a SPICE cell of any
data type.
CELLS
CELLS
VARIABLE I/O DESCRIPTION
-------- --- --------------------------------------------------
cell I Input cell.
The function returns the size of the input cell.
cell is a CSPICE cell of any data type. Cell must be
declared as a character, double precision, or
integer SpiceCell.
The function returns the size of (maximum number of elements in)
the input cell.
None.
1) If the input array has invalid cardinality, the error
SPICE(INVALIDCARDINALITY) is signaled. size_c returns
an unspecified value in this case.
2) If the input array has invalid size, the error
SPICE(INVALIDSIZE) is signaled. size_c returns
an unspecified value in this case.
None.
None.
The size_c function is typically used in conjunction
with the card_c function to predict (and subsequently
avoid) overflows when manipulating cells. In the following
example, size_c is used to determine whether the integer cell
original can be safely copied into the integer cell save before
actually attempting the operation. (If original contains more
elements than save is capable of holding, then the operation
will fail.)
#include "SpiceUsr.h"
.
.
.
/.
Declare the cells original and save with string length
LNSIZE and maximum number of strings SIZE1 and SIZE2
respectively.
./
SPICECHAR_CELL ( original, SIZE1, LNSIZE );
SPICECHAR_CELL ( save, SIZE2, LNSIZE );
.
.
.
if ( card_c(&original) <= size_c(&save) )
{
copy_c ( &original, &save );
}
else
{
[ Handle overflow case ]
.
.
.
}
None.
None.
N.J. Bachman (JPL)
C.A. Curzon (JPL)
H.A. Neilan (JPL)
W.L. Taber (JPL)
I.M. Underwood (JPL)
-CSPICE Version 1.0.0, 06-AUG-2002 (NJB) (CAC) (HAN) (WLT) (IMU)
size of a cell
Link to routine size_c source file size_c.c
|