7d86e0ffbe4295c91220ff671c3eeb2009d41408 braney Sun Feb 25 11:09:39 2024 -0800 working on quickLift UI diff --git src/hg/lib/exportedDataHubs.c src/hg/lib/exportedDataHubs.c new file mode 100644 index 0000000..e576711 --- /dev/null +++ src/hg/lib/exportedDataHubs.c @@ -0,0 +1,123 @@ +/* exportedDataHubs.c was originally generated by the autoSql program, which also + * generated exportedDataHubs.h and exportedDataHubs.sql. This module links the database and + * the RAM representation of objects. */ + +#include "common.h" +#include "linefile.h" +#include "dystring.h" +#include "jksql.h" +#include "exportedDataHubs.h" + + + +char *exportedDataHubsCommaSepFieldNames = "id,path"; + +void exportedDataHubsStaticLoad(char **row, struct exportedDataHubs *ret) +/* Load a row from exportedDataHubs table into ret. The contents of ret will + * be replaced at the next call to this function. */ +{ + +ret->id = sqlUnsigned(row[0]); +ret->path = row[1]; +} + +struct exportedDataHubs *exportedDataHubsLoad(char **row) +/* Load a exportedDataHubs from row fetched with select * from exportedDataHubs + * from database. Dispose of this with exportedDataHubsFree(). */ +{ +struct exportedDataHubs *ret; + +AllocVar(ret); +ret->id = sqlUnsigned(row[0]); +ret->path = cloneString(row[1]); +return ret; +} + +struct exportedDataHubs *exportedDataHubsLoadAll(char *fileName) +/* Load all exportedDataHubs from a whitespace-separated file. + * Dispose of this with exportedDataHubsFreeList(). */ +{ +struct exportedDataHubs *list = NULL, *el; +struct lineFile *lf = lineFileOpen(fileName, TRUE); +char *row[2]; + +while (lineFileRow(lf, row)) + { + el = exportedDataHubsLoad(row); + slAddHead(&list, el); + } +lineFileClose(&lf); +slReverse(&list); +return list; +} + +struct exportedDataHubs *exportedDataHubsLoadAllByChar(char *fileName, char chopper) +/* Load all exportedDataHubs from a chopper separated file. + * Dispose of this with exportedDataHubsFreeList(). */ +{ +struct exportedDataHubs *list = NULL, *el; +struct lineFile *lf = lineFileOpen(fileName, TRUE); +char *row[2]; + +while (lineFileNextCharRow(lf, chopper, row, ArraySize(row))) + { + el = exportedDataHubsLoad(row); + slAddHead(&list, el); + } +lineFileClose(&lf); +slReverse(&list); +return list; +} + +struct exportedDataHubs *exportedDataHubsCommaIn(char **pS, struct exportedDataHubs *ret) +/* Create a exportedDataHubs out of a comma separated string. + * This will fill in ret if non-null, otherwise will + * return a new exportedDataHubs */ +{ +char *s = *pS; + +if (ret == NULL) + AllocVar(ret); +ret->id = sqlUnsignedComma(&s); +ret->path = sqlStringComma(&s); +*pS = s; +return ret; +} + +void exportedDataHubsFree(struct exportedDataHubs **pEl) +/* Free a single dynamically allocated exportedDataHubs such as created + * with exportedDataHubsLoad(). */ +{ +struct exportedDataHubs *el; + +if ((el = *pEl) == NULL) return; +freeMem(el->path); +freez(pEl); +} + +void exportedDataHubsFreeList(struct exportedDataHubs **pList) +/* Free a list of dynamically allocated exportedDataHubs's */ +{ +struct exportedDataHubs *el, *next; + +for (el = *pList; el != NULL; el = next) + { + next = el->next; + exportedDataHubsFree(&el); + } +*pList = NULL; +} + +void exportedDataHubsOutput(struct exportedDataHubs *el, FILE *f, char sep, char lastSep) +/* Print out exportedDataHubs. Separate fields with sep. Follow last field with lastSep. */ +{ +fprintf(f, "%u", el->id); +fputc(sep,f); +if (sep == ',') fputc('"',f); +fprintf(f, "%s", el->path); +if (sep == ',') fputc('"',f); +fputc(lastSep,f); +} + +/* -------------------------------- End autoSql Generated Code -------------------------------- */ +