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

#ifndef BARCHARTCATEGORY_H
#define BARCHARTCATEGORY_H

#include "jksql.h"
#define BARCHARTCATEGORY_NUM_COLS 4

extern char *barChartCategoryCommaSepFieldNames;

struct barChartCategory
/* bar chart track category information */
    {
    struct barChartCategory *next;  /* Next in singly linked list. */
    unsigned id;	/* internal id */
    char *name;	/* short identifier */
    char *label;	/* descriptive label */
    unsigned color;	/* user assigned color */
    };

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

struct barChartCategory *barChartCategoryLoadByQuery(struct sqlConnection *conn, char *query);
/* Load all barChartCategory from table that satisfy the query given.  
 * Where query is of the form 'select * from example where something=something'
 * or 'select example.* from example, anotherTable where example.something = 
 * anotherTable.something'.
 * Dispose of this with barChartCategoryFreeList(). */

void barChartCategorySaveToDb(struct sqlConnection *conn, struct barChartCategory *el, char *tableName, int updateSize);
/* Save barChartCategory as a row to the table specified by tableName. 
 * As blob fields may be arbitrary size updateSize specifies the approx size
 * of a string that would contain the entire query. Arrays of native types are
 * converted to comma separated strings and loaded as such, User defined types are
 * inserted as NULL. This function automatically escapes quoted strings for mysql. */

struct barChartCategory *barChartCategoryLoad(char **row);
/* Load a barChartCategory from row fetched with select * from barChartCategory
 * from database.  Dispose of this with barChartCategoryFree(). */

struct barChartCategory *barChartCategoryLoadAll(char *fileName);
/* Load all barChartCategory from whitespace-separated file.
 * Dispose of this with barChartCategoryFreeList(). */

struct barChartCategory *barChartCategoryLoadAllByChar(char *fileName, char chopper);
/* Load all barChartCategory from chopper separated file.
 * Dispose of this with barChartCategoryFreeList(). */

#define barChartCategoryLoadAllByTab(a) barChartCategoryLoadAllByChar(a, '\t');
/* Load all barChartCategory from tab separated file.
 * Dispose of this with barChartCategoryFreeList(). */

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

void barChartCategoryFree(struct barChartCategory **pEl);
/* Free a single dynamically allocated barChartCategory such as created
 * with barChartCategoryLoad(). */

void barChartCategoryFreeList(struct barChartCategory **pList);
/* Free a list of dynamically allocated barChartCategory's */

void barChartCategoryOutput(struct barChartCategory *el, FILE *f, char sep, char lastSep);
/* Print out barChartCategory.  Separate fields with sep. Follow last field with lastSep. */

#define barChartCategoryTabOut(el,f) barChartCategoryOutput(el,f,'\t','\n');
/* Print out barChartCategory as a line in a tab-separated file. */

#define barChartCategoryCommaOut(el,f) barChartCategoryOutput(el,f,',',',');
/* Print out barChartCategory as a comma separated list including final comma. */

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

struct barChartCategory *barChartGetCategories(char *database, char *track);
/* Get id, labels, colors, etc. */

char *barChartGetCategoryLabel(int id, char *database, char *track);
/* Get description for a category specified by id.  
 * Use for single queries (o/w use barChartGetCategories) */

#endif /* BARCHARTCATEGORY_H */

