inc/spacedColumn.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  spacedColumn

Defines

#define spacedColumnFreeList   slFreeList

Functions

spacedColumnspacedColumnFromWidthArray (int array[], int size)
spacedColumnspacedColumnFromSample (char *sample)
spacedColumnspacedColumnFromSizeCommaList (char *commaList)
spacedColumnspacedColumnFromLineFile (struct lineFile *lf)
spacedColumnspacedColumnFromFile (char *fileName)
int spacedColumnBiggestSize (struct spacedColumn *colList)
boolean spacedColumnParseLine (struct spacedColumn *colList, char *line, char *row[])


Define Documentation

#define spacedColumnFreeList   slFreeList

Definition at line 15 of file spacedColumn.h.


Function Documentation

int spacedColumnBiggestSize ( struct spacedColumn colList  ) 

Definition at line 71 of file spacedColumn.c.

References spacedColumn::next, and spacedColumn::size.

00073 {
00074 int maxSize = 0;
00075 struct spacedColumn *col;
00076 for (col = colList; col != NULL; col = col->next)
00077     if (maxSize < col->size)
00078         maxSize = col->size;
00079 return maxSize;
00080 }

struct spacedColumn* spacedColumnFromFile ( char *  fileName  )  [read]

Definition at line 62 of file spacedColumn.c.

References lineFileClose(), lineFileOpen(), spacedColumnFromLineFile(), and TRUE.

00064 {
00065 struct lineFile *lf = lineFileOpen(fileName, TRUE);
00066 struct spacedColumn *colList = spacedColumnFromLineFile(lf);
00067 lineFileClose(&lf);
00068 return colList;
00069 }

Here is the call graph for this function:

struct spacedColumn* spacedColumnFromLineFile ( struct lineFile lf  )  [read]

Definition at line 31 of file spacedColumn.c.

References freeMem(), lineFileNext(), needMem(), and spacedColumnFromSample().

Referenced by spacedColumnFromFile().

00034 {
00035 int maxLine = 64*1024;
00036 int lineSize, widestLine = 0;
00037 char *projection = needMem(maxLine+1);
00038 char *line;
00039 struct spacedColumn *colList;
00040 int i;
00041 
00042 /* Create projection of all lines. */
00043 for (i=0; i<maxLine; ++i)
00044     projection[i] = ' ';
00045 while (lineFileNext(lf, &line, &lineSize))
00046     {
00047     if (lineSize > widestLine)
00048          widestLine = lineSize;
00049     for (i=0; i<lineSize; ++i)
00050         {
00051         char c = line[i];
00052         if (c != 0 && c != ' ')
00053             projection[i] = line[i];
00054         }
00055     }
00056 projection[widestLine] = 0;
00057 colList = spacedColumnFromSample(projection);
00058 freeMem(projection);
00059 return colList;
00060 }

Here is the call graph for this function:

Here is the caller graph for this function:

struct spacedColumn* spacedColumnFromSample ( char *  sample  )  [read]

Definition at line 12 of file spacedColumn.c.

References AllocVar, cloneString(), freeMem(), nextWord(), slAddHead, and slReverse().

Referenced by hpfNext(), and spacedColumnFromLineFile().

00015 {
00016 struct spacedColumn *col, *colList = NULL;
00017 char *dupe = cloneString(sample);
00018 char *word, *line = dupe;
00019 while ((word = nextWord(&line)) != NULL)
00020     {
00021     AllocVar(col);
00022     col->start = word - dupe;
00023     col->size = strlen(word);
00024     slAddHead(&colList, col);
00025     }
00026 freeMem(dupe);
00027 slReverse(&colList);
00028 return colList;
00029 }

Here is the call graph for this function:

Here is the caller graph for this function:

struct spacedColumn* spacedColumnFromSizeCommaList ( char *  commaList  )  [read]

Definition at line 123 of file spacedColumn.c.

References commaSepToSlNames(), slName::name, slName::next, slCount(), slFreeList(), spacedColumnFromWidthArray(), and sqlUnsigned().

00126 {
00127 struct slName *ascii, *asciiList = commaSepToSlNames(commaList);
00128 int colCount = slCount(asciiList);
00129 int widths[colCount], i;
00130 for (ascii = asciiList, i=0; ascii != NULL; ascii = ascii->next, ++i)
00131     widths[i] = sqlUnsigned(ascii->name);
00132 slFreeList(&asciiList);
00133 return spacedColumnFromWidthArray(widths, colCount);
00134 }

Here is the call graph for this function:

struct spacedColumn* spacedColumnFromWidthArray ( int  array[],
int  size 
) [read]

Definition at line 103 of file spacedColumn.c.

References AllocVar, slAddHead, slReverse(), and spacedColumn::start.

Referenced by spacedColumnFromSizeCommaList().

00106 {
00107 struct spacedColumn *col, *colList = NULL;
00108 int i;
00109 int start = 0;
00110 for (i=0; i<size; ++i)
00111     {
00112     int width = array[i];
00113     AllocVar(col);
00114     col->start = start;
00115     col->size = width-1;
00116     slAddHead(&colList, col);
00117     start += width;
00118     }
00119 slReverse(&colList);
00120 return colList;
00121 }

Here is the call graph for this function:

Here is the caller graph for this function:

boolean spacedColumnParseLine ( struct spacedColumn colList,
char *  line,
char *  row[] 
)

Definition at line 82 of file spacedColumn.c.

References FALSE, spacedColumn::next, spacedColumn::size, spacedColumn::start, trimSpaces(), and TRUE.

Referenced by hpfNext().

00088 {
00089 struct spacedColumn *col;
00090 int i, len = strlen(line);
00091 for (i=0, col = colList; col != NULL; col = col->next, ++i)
00092     {
00093     if (col->start > len)
00094         return FALSE;
00095     int end = col->start + col->size;
00096     if (end > len) end = len;
00097     line[end] = 0;
00098     row[i] = trimSpaces(line + col->start);
00099     }
00100 return TRUE;
00101 }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on Tue Dec 25 19:15:30 2007 for blat by  doxygen 1.5.2