/* gencodeGeneSource.c was originally generated by the autoSql program, which also 
 * generated gencodeGeneSource.h and gencodeGeneSource.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 "gencodeGeneSource.h"



char *gencodeGeneSourceCommaSepFieldNames = "geneId,source";

void gencodeGeneSourceStaticLoad(char **row, struct gencodeGeneSource *ret)
/* Load a row from gencodeGeneSource table into ret.  The contents of ret will
 * be replaced at the next call to this function. */
{

ret->geneId = row[0];
ret->source = row[1];
}

struct gencodeGeneSource *gencodeGeneSourceLoad(char **row)
/* Load a gencodeGeneSource from row fetched with select * from gencodeGeneSource
 * from database.  Dispose of this with gencodeGeneSourceFree(). */
{
struct gencodeGeneSource *ret;

AllocVar(ret);
ret->geneId = cloneString(row[0]);
ret->source = cloneString(row[1]);
return ret;
}

struct gencodeGeneSource *gencodeGeneSourceLoadAll(char *fileName) 
/* Load all gencodeGeneSource from a whitespace-separated file.
 * Dispose of this with gencodeGeneSourceFreeList(). */
{
struct gencodeGeneSource *list = NULL, *el;
struct lineFile *lf = lineFileOpen(fileName, TRUE);
char *row[2];

while (lineFileRow(lf, row))
    {
    el = gencodeGeneSourceLoad(row);
    slAddHead(&list, el);
    }
lineFileClose(&lf);
slReverse(&list);
return list;
}

struct gencodeGeneSource *gencodeGeneSourceLoadAllByChar(char *fileName, char chopper) 
/* Load all gencodeGeneSource from a chopper separated file.
 * Dispose of this with gencodeGeneSourceFreeList(). */
{
struct gencodeGeneSource *list = NULL, *el;
struct lineFile *lf = lineFileOpen(fileName, TRUE);
char *row[2];

while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
    {
    el = gencodeGeneSourceLoad(row);
    slAddHead(&list, el);
    }
lineFileClose(&lf);
slReverse(&list);
return list;
}

struct gencodeGeneSource *gencodeGeneSourceCommaIn(char **pS, struct gencodeGeneSource *ret)
/* Create a gencodeGeneSource out of a comma separated string. 
 * This will fill in ret if non-null, otherwise will
 * return a new gencodeGeneSource */
{
char *s = *pS;

if (ret == NULL)
    AllocVar(ret);
ret->geneId = sqlStringComma(&s);
ret->source = sqlStringComma(&s);
*pS = s;
return ret;
}

void gencodeGeneSourceFree(struct gencodeGeneSource **pEl)
/* Free a single dynamically allocated gencodeGeneSource such as created
 * with gencodeGeneSourceLoad(). */
{
struct gencodeGeneSource *el;

if ((el = *pEl) == NULL) return;
freeMem(el->geneId);
freeMem(el->source);
freez(pEl);
}

void gencodeGeneSourceFreeList(struct gencodeGeneSource **pList)
/* Free a list of dynamically allocated gencodeGeneSource's */
{
struct gencodeGeneSource *el, *next;

for (el = *pList; el != NULL; el = next)
    {
    next = el->next;
    gencodeGeneSourceFree(&el);
    }
*pList = NULL;
}

void gencodeGeneSourceOutput(struct gencodeGeneSource *el, FILE *f, char sep, char lastSep) 
/* Print out gencodeGeneSource.  Separate fields with sep. Follow last field with lastSep. */
{
if (sep == ',') fputc('"',f);
fprintf(f, "%s", el->geneId);
if (sep == ',') fputc('"',f);
fputc(sep,f);
if (sep == ',') fputc('"',f);
fprintf(f, "%s", el->source);
if (sep == ',') fputc('"',f);
fputc(lastSep,f);
}

/* -------------------------------- End autoSql Generated Code -------------------------------- */

