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



char *gencodeTranscriptSourceCommaSepFieldNames = "transcriptId,source";

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

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

struct gencodeTranscriptSource *gencodeTranscriptSourceLoad(char **row)
/* Load a gencodeTranscriptSource from row fetched with select * from gencodeTranscriptSource
 * from database.  Dispose of this with gencodeTranscriptSourceFree(). */
{
struct gencodeTranscriptSource *ret;

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

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

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

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

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

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

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

void gencodeTranscriptSourceFree(struct gencodeTranscriptSource **pEl)
/* Free a single dynamically allocated gencodeTranscriptSource such as created
 * with gencodeTranscriptSourceLoad(). */
{
struct gencodeTranscriptSource *el;

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

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

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

void gencodeTranscriptSourceOutput(struct gencodeTranscriptSource *el, FILE *f, char sep, char lastSep) 
/* Print out gencodeTranscriptSource.  Separate fields with sep. Follow last field with lastSep. */
{
if (sep == ',') fputc('"',f);
fprintf(f, "%s", el->transcriptId);
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 -------------------------------- */

