101c33cf32e9ce191cad2a8b333d473f2059fa7a kent Tue Sep 3 16:09:46 2013 -0700 Adding support for arrays, and also extraH option to raToStructGen. diff --git src/lib/raToStruct.c src/lib/raToStruct.c index 530efb7..42d805e 100644 --- src/lib/raToStruct.c +++ src/lib/raToStruct.c @@ -57,15 +57,119 @@ /* Make sure that all required files have been seen in the stanza we just parsed. */ { int *requiredFieldIds = reader->requiredFieldIds; bool *fieldsObserved = reader->fieldsObserved; int i; for (i=0; i<reader->requiredFieldCount; ++i) { if (!fieldsObserved[requiredFieldIds[i]]) { errAbort("Required field %s not found line %d of %s", reader->requiredFields[i], lf->lineIx, lf->fileName); } } } +void raToStructArraySignedSizer(struct lineFile *lf, int curSize, int *pSize, char *fieldName) +/* If *pSize is zero, set it to curSize, othersize check that it is the same as curSize. + * The lf and fieldName are for error reporting. */ +{ +int oldSize = *pSize; +if (oldSize == 0) + *pSize = curSize; +else if (curSize != oldSize) + errAbort("Array dimension mismatch between %s and another field in stanza ending line %d of %s", + fieldName, lf->lineIx, lf->fileName); +} + +void raToStructArrayUnsignedSizer(struct lineFile *lf, unsigned curSize, + unsigned *pSize, char *fieldName) +/* If *pSize is zero, set it to curSize, othersize check that it is the same as curSize. + * The lf and fieldName are for error reporting. */ +{ +unsigned oldSize = *pSize; +if (oldSize == 0) + *pSize = curSize; +else if (curSize != oldSize) + errAbort("Array dimension mismatch between %s and another field in stanza ending line %d of %s", + fieldName, lf->lineIx, lf->fileName); +} + +void raToStructArrayShortSizer(struct lineFile *lf, short curSize, + short *pSize, char *fieldName) +/* If *pSize is zero, set it to curSize, othersize check that it is the same as curSize. + * The lf and fieldName are for error reporting. */ +{ +short oldSize = *pSize; +if (oldSize == 0) + *pSize = curSize; +else if (curSize != oldSize) + errAbort("Array dimension mismatch between %s and another field in stanza ending line %d of %s", + fieldName, lf->lineIx, lf->fileName); +} + +void raToStructArrayUshortSizer(struct lineFile *lf, unsigned short curSize, + unsigned short *pSize, char *fieldName) +/* If *pSize is zero, set it to curSize, othersize check that it is the same as curSize. + * The lf and fieldName are for error reporting. */ +{ +unsigned short oldSize = *pSize; +if (oldSize == 0) + *pSize = curSize; +else if (curSize != oldSize) + errAbort("Array dimension mismatch between %s and another field in stanza ending line %d of %s", + fieldName, lf->lineIx, lf->fileName); +} + +void raToStructArrayByteSizer(struct lineFile *lf, signed char curSize, + signed char *pSize, char *fieldName) +/* If *pSize is zero, set it to curSize, othersize check that it is the same as curSize. + * The lf and fieldName are for error reporting. */ +{ +signed char oldSize = *pSize; +if (oldSize == 0) + *pSize = curSize; +else if (curSize != oldSize) + errAbort("Array dimension mismatch between %s and another field in stanza ending line %d of %s", + fieldName, lf->lineIx, lf->fileName); +} + +void raToStructArrayUbyteSizer(struct lineFile *lf, unsigned char curSize, + unsigned char *pSize, char *fieldName) +/* If *pSize is zero, set it to curSize, othersize check that it is the same as curSize. + * The lf and fieldName are for error reporting. */ +{ +unsigned char oldSize = *pSize; +if (oldSize == 0) + *pSize = curSize; +else if (curSize != oldSize) + errAbort("Array dimension mismatch between %s and another field in stanza ending line %d of %s", + fieldName, lf->lineIx, lf->fileName); +} + +void raToStructArrayLongLongSizer(struct lineFile *lf, long long curSize, + long long *pSize, char *fieldName) +/* If *pSize is zero, set it to curSize, othersize check that it is the same as curSize. + * The lf and fieldName are for error reporting. */ +{ +long long oldSize = *pSize; +if (oldSize == 0) + *pSize = curSize; +else if (curSize != oldSize) + errAbort("Array dimension mismatch between %s and another field in stanza ending line %d of %s", + fieldName, lf->lineIx, lf->fileName); +} + +#ifdef NEVER +void raToStructArrayXyzSizer(struct lineFile *lf, xyz curSize, + xyz *pSize, char *fieldName) +/* If *pSize is zero, set it to curSize, othersize check that it is the same as curSize. + * The lf and fieldName are for error reporting. */ +{ +xyz oldSize = *pSize; +if (oldSize == 0) + *pSize = curSize; +else if (curSize != oldSize) + errAbort("Array dimension mismatch between %s and another field in stanza ending line %d of %s", + fieldName, lf->lineIx, lf->fileName); +} +#endif /* NEVER */