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



char *gencodeToPubMedCommaSepFieldNames = "transcriptId,pubMedId";

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

ret->transcriptId = row[0];
ret->pubMedId = sqlSigned(row[1]);
}

struct gencodeToPubMed *gencodeToPubMedLoad(char **row)
/* Load a gencodeToPubMed from row fetched with select * from gencodeToPubMed
 * from database.  Dispose of this with gencodeToPubMedFree(). */
{
struct gencodeToPubMed *ret;

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

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

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

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

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

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

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

void gencodeToPubMedFree(struct gencodeToPubMed **pEl)
/* Free a single dynamically allocated gencodeToPubMed such as created
 * with gencodeToPubMedLoad(). */
{
struct gencodeToPubMed *el;

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

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

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

void gencodeToPubMedOutput(struct gencodeToPubMed *el, FILE *f, char sep, char lastSep) 
/* Print out gencodeToPubMed.  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);
fprintf(f, "%d", el->pubMedId);
fputc(lastSep,f);
}

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

