1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
class GdsHeader
{
public:
unsigned short rlen;
char record_type;
char data_type;
};
class GdsRecord
{
public:
#ifndef SWIG
union
{
short *two_int;
int *four_int;
double *eight_real;
char *one_ascii;
// void *v;
};
#endif
int length;
GdsRecord (); // { v = 0; length = 0; }
~GdsRecord () ;// { delete v; }
void len (int l, int type);
};
class GdsRecord
{
public:
#ifndef SWIG
union
{
short *two_int;
int *four_int;
double *eight_real;
char *one_ascii;
// void *v;
};
#endif
int length;
GdsRecord (); // { v = 0; length = 0; }
~GdsRecord () ;// { delete v; }
void len (int l, int type);
};
class GdsBlock
{
bool valid_block ();
int len;
public:
bool record_unred;
int header_ftell;
GdsHeader h;
GdsRecord r;
int array_size;
// bool re_read;
// GdsBlock () { re_read = false; }
GdsBlock () { record_unred = false; header_ftell = 0; }
void set (int rt, int dt, int sz)
{TBE;
h.record_type = rt; h.data_type = dt;
array_size = sz; r.len (sz, dt);TBX;
}
int read_header (FILE *);
void read_block (FILE *);
void write (FILE *);
void prt ();
};
void GdsBlock :: write (FILE *outstr)
{
switch(h.data_type)
{
Case 3:
for(i = 0; i < array_size; i++)
{
cout<<r.four_int[i]<<endl;
int *temp = &r.four_int[i];
reverse(4,temp);
}
fwrite (r.one_ascii, 1, i, outstr);
}
#ifndef sparc
static void reverse (int len, char *buf)
{
TBE;
char tmp[24];
int i;
for (i = 0; i < len; i++) tmp[i] = buf[i];
for (i = 0; i < len; i++) buf[i] = tmp[ (len - 1) - i];
TBX;
}
inline void reverse (int len, short *s) { reverse (len, (char *) s); }
inline void reverse (int len, int *s) { reverse (len, (char *) s); }
inline void reverse (int len, double *s) { reverse (len, (char *) s); }
inline void reverse (int len, unsigned char *s) {reverse (len, (char *) s); }
#endif
|