Is it possible to create a new matrix signature with a dynamic number of columns? In my case, it is difficult to know in advance the number of columns (and, in fact, the number of columns can even be variable). My problem is that if I do not declare at least one column, the new signature of the matrix is not written because the column list is empty (see SdifFOneMatrixTypeToSdifString () in SdiFPut.c) and therefore the reading does not work. If I declare a column, the new signature is well written, and the reading works (regardless of the actual number of columns). In fact, it seems that the number of columns defined in the matrix declaration is not used when reading the file (but I might be wrong). Anyway, if the format can support a dynamic number of columns, it would be better to be able to leave the columns definition empty.
I use SDIF 3.11.7.
Here is my suggestion:
int SdifFOneMatrixTypeToSdifString(SdifMatrixTypeT *MatrixType, SdifStringT *SdifString) { int success = 1; SdifColumnDefT *ColumnDef; success *= SdifStringAppend(SdifString, " "); success *= SdifStringAppend(SdifString,SdifSignatureToString(e1MTD)); success *= SdifStringAppend(SdifString, " "); success *= SdifStringAppend(SdifString,SdifSignatureToString(MatrixType->Signature)); success *= SdifStringAppend(SdifString,"\t{"); if (! SdifListIsEmpty(MatrixType->ColumnUserList)) { ColumnDef = (SdifColumnDefT *)SdifListGetHead(MatrixType->ColumnUserList); /* Reinit GetNext */ success *= SdifStringAppend(SdifString,ColumnDef->Name); while (SdifListIsNext(MatrixType->ColumnUserList)) { ColumnDef = (SdifColumnDefT *)SdifListGetNext(MatrixType->ColumnUserList); success *= SdifStringAppend(SdifString,", "); success *= SdifStringAppend(SdifString,ColumnDef->Name); } } success *= SdifStringAppend(SdifString,"}\n"); return(success); }