/* Compute the offset from the start of the row to the given field */ static ossim_int32 row_offset( int field, row_type row, vpf_table_type table) { ossim_int32 offset,n,size; int i; id_triplet_type key; int keysize[] = {0,sizeof(char),sizeof(short int),sizeof(ossim_int32)}; if (field < 0 || field >= table.nfields) return -1; offset = 0L; for (i=0;i<field;i++) { switch (table.header[i].type) { case 'I': offset += sizeof(ossim_int32)*row[i].count; break; case 'S': offset += sizeof(short int)*row[i].count; break; case 'T': offset += sizeof(char)*row[i].count; break; case 'F': offset += sizeof(float)*row[i].count; break; case 'D': offset += sizeof(date_type)*row[i].count; break; case 'K': get_table_element(i,row,table,&key,&n); size = sizeof(char) + keysize[TYPE0(key.type)] + keysize[TYPE1(key.type)] + keysize[TYPE2(key.type)]; offset += size*row[i].count; break; case 'R': offset += sizeof(double)*row[i].count; break; case 'C': offset += sizeof(coordinate_type)*row[i].count; break; case 'B': offset += sizeof(double_coordinate_type)*row[i].count; break; case 'Z': offset += sizeof(tri_coordinate_type)*row[i].count; break; case 'Y': offset += sizeof(double_tri_coordinate_type)*row[i].count; break; } } return offset; }
static vmIntrinsics::ID wrapper_intrinsic(BasicType type, bool unboxing) { #define TYPE2(type, unboxing) ((int)(type)*2 + ((unboxing) ? 1 : 0)) switch (TYPE2(type, unboxing)) { #define BASIC_TYPE_CASE(type, box, unbox) \ case TYPE2(type, false): return vmIntrinsics::box; \ case TYPE2(type, true): return vmIntrinsics::unbox BASIC_TYPE_CASE(T_BOOLEAN, _Boolean_valueOf, _booleanValue); BASIC_TYPE_CASE(T_BYTE, _Byte_valueOf, _byteValue); BASIC_TYPE_CASE(T_CHAR, _Character_valueOf, _charValue); BASIC_TYPE_CASE(T_SHORT, _Short_valueOf, _shortValue); BASIC_TYPE_CASE(T_INT, _Integer_valueOf, _intValue); BASIC_TYPE_CASE(T_LONG, _Long_valueOf, _longValue); BASIC_TYPE_CASE(T_FLOAT, _Float_valueOf, _floatValue); BASIC_TYPE_CASE(T_DOUBLE, _Double_valueOf, _doubleValue); #undef BASIC_TYPE_CASE } #undef TYPE2 return vmIntrinsics::_none; }
/************************************************************************* * *N write_key * *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Purpose: *P * This function writes an id triplet key from the specified file. * It is assumed that there is enough free disk space to write to the * file. It is also assumed that the file pointer (fp) is already opened * for writing. *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Parameters: *A * key <input> == (id_triplet_type) id triplet key. * fp <input> == (FILE *) input file pointer. * return <output> == (long int) size of the key. *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * History: *H * Dave Flinn July 1991 Based on read_key in vpftable.c *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * External Variables: *X * None *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Functions Called: *F * None *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Portability: *O * This module should be ANSI C compatible. *E *************************************************************************/ long int write_key( id_triplet_type key, FILE *fp ) { long int size = 0 ; /* to count size of key write */ unsigned char tint ; short int tshort ; /* Assume that any count value has been written before this */ /* Only write one key in this subroutine, do not write more */ Write_Vpf_Char (&(key.type),fp,1); size += sizeof ( char ) ; switch (TYPE0(key.type)) { case 0: break; case 1: tint = (unsigned char) key.id ; Write_Vpf_Char ( &tint, fp, 1 ) ; size += sizeof ( char ) ; break; case 2: tshort = (short) key.id ; Write_Vpf_Short ( &tshort, fp, 1 ) ; size += sizeof ( short int ) ; break; case 3: Write_Vpf_Int (&(key.id), fp, 1 ) ; size += sizeof ( long int ) ; break; } switch (TYPE1(key.type)) { case 0: break; case 1: tint = (unsigned char) key.tile ; Write_Vpf_Char ( &tint, fp, 1 ) ; size += sizeof ( char ) ; break; case 2: tshort = (short) key.tile ; Write_Vpf_Short ( &tshort, fp, 1 ) ; size += sizeof ( short int ) ; break; case 3: Write_Vpf_Int (&(key.tile), fp, 1 ) ; size += sizeof ( long int ) ; break; } switch (TYPE2(key.type)) { case 0: break; case 1: tint = (unsigned char) key.exid ; Write_Vpf_Char ( &tint, fp, 1 ) ; size += sizeof ( char ) ; break; case 2: tshort = (short) key.exid ; Write_Vpf_Short ( &tshort, fp, 1 ) ; size += sizeof ( short int ) ; break; case 3: Write_Vpf_Int (&(key.exid), fp, 1 ) ; size += sizeof ( long int ) ; break; } return size ; }
/************************************************************************* * *N read_key * *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Purpose: *P * This function reads an id triplet key from a VPF table. * The table must be open for read. *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Parameters: *A * table <input> == (vpf_table_type) VPF table. * read_key <output> == (id_triplet_type) id triplet key. *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * History: *H * Barry Michaels May 1991 Original Version DOS Turbo C * Dave Flinn July 1991 Updated for UNIX *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * External Variables: *X * None *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Functions Called: *F * None *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Portability: *O * This module should be ANSI C compatible. *E *************************************************************************/ id_triplet_type read_key( vpf_table_type table ) { id_triplet_type key; unsigned char ucval; unsigned short int uival; STORAGE_BYTE_ORDER = table.byte_order; key.id = 0L; key.tile = 0L; key.exid = 0L; /* just doing this to be consistent */ Read_Vpf_Char (&(key.type),table.fp,1); switch (TYPE0(key.type)) { case 0: break; case 1: Read_Vpf_Char (&ucval, table.fp, 1 ) ; key.id = (ossim_int32)ucval; break; case 2: Read_Vpf_Short (&uival, table.fp, 1 ) ; key.id = (ossim_int32)uival; break; case 3: Read_Vpf_Int (&(key.id), table.fp, 1 ) ; break; } switch (TYPE1(key.type)) { case 0: break; case 1: Read_Vpf_Char (&ucval, table.fp, 1 ) ; key.tile = (ossim_int32)ucval; break; case 2: Read_Vpf_Short (&uival, table.fp, 1 ) ; key.tile = (ossim_int32)uival; break; case 3: Read_Vpf_Int (&(key.tile), table.fp, 1 ) ; break; } switch (TYPE2(key.type)) { case 0: break; case 1: Read_Vpf_Char (&ucval, table.fp, 1 ) ; key.exid = (ossim_int32)ucval; break; case 2: Read_Vpf_Short (&uival, table.fp, 1 ) ; key.exid = (ossim_int32)uival; break; case 3: Read_Vpf_Int (&(key.exid), table.fp, 1 ) ; break; } return key; }