/* wgEncodeGencodeTranscriptSource.c was originally generated by the autoSql program, which also 
 * generated wgEncodeGencodeTranscriptSource.h and wgEncodeGencodeTranscriptSource.sql.  This module links the database and
 * the RAM representation of objects. */

/* Copyright (C) 2011 The Regents of the University of California 
 * See README in this or parent directory for licensing information. */

#include "common.h"
#include "linefile.h"
#include "dystring.h"
#include "jksql.h"
#include "encode/wgEncodeGencodeTranscriptSource.h"


void wgEncodeGencodeTranscriptSourceStaticLoad(char **row, struct wgEncodeGencodeTranscriptSource *ret)
/* Load a row from wgEncodeGencodeTranscriptSource 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 wgEncodeGencodeTranscriptSource *wgEncodeGencodeTranscriptSourceLoad(char **row)
/* Load a wgEncodeGencodeTranscriptSource from row fetched with select * from wgEncodeGencodeTranscriptSource
 * from database.  Dispose of this with wgEncodeGencodeTranscriptSourceFree(). */
{
struct wgEncodeGencodeTranscriptSource *ret;

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

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

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

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

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

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

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

void wgEncodeGencodeTranscriptSourceFree(struct wgEncodeGencodeTranscriptSource **pEl)
/* Free a single dynamically allocated wgEncodeGencodeTranscriptSource such as created
 * with wgEncodeGencodeTranscriptSourceLoad(). */
{
struct wgEncodeGencodeTranscriptSource *el;

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

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

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

void wgEncodeGencodeTranscriptSourceOutput(struct wgEncodeGencodeTranscriptSource *el, FILE *f, char sep, char lastSep) 
/* Print out wgEncodeGencodeTranscriptSource.  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 -------------------------------- */

