#ifndef _RSS_SQL_H_
#define _RSS_SQL_H_

#include "../src/sqlite3.h"
#include "../sqlitewrapped-1.3/Database.h"
#include "../sqlitewrapped-1.3/Query.h"


////////////////////////////////////////////////////////////////////
// This library provide batch create and insert functions for channelTable and itemTable
// User need to form sql command using Query class to do select functions. No helper function for select.

typedef struct _tagChannelInfo {
	char *title;
	char *pubDate;
	char *link;
	char *description;
	char *author;
	int  status;
	unsigned int cando;
} ChannelInfo;

typedef struct _tagItemInfo {
	char *title;
	char *pubDate;
	char *link;
	char *mediaURL;
	int  channelID;
	int  length;        // media file length in bytes
	int  duration;      // media total play time in seconds
	char *description;  
	char *author;
	int  status;
	unsigned int cando;	

} ItemInfo;
// create the channel table and item table
bool createChannelTable(Database &db);

bool createItemTable(Database &db);


// insert channel to channelTable of the db
// function will check channelInfo, if not exist in channelTable, channel will insert into channelTable
// If channelInfo already exist in the channelTable, the channelID will get back.
// function return channelID.
int  insertChannel(Database &db, ChannelInfo *channelInfo);


// insert to the item table in db
// function will update both channel table and item table of this db
// function will call insertChannel internally if channelInfo != 0;
// Item will insert into itemTable, with the channelID. We don't check the duplication of item.
// the channelInfo is the channel that inserted item belonging to.
// If channelID >0, we don't need to use channelInfo to fetch the channelID. This can speed up the insertion.
int insertItem(Database &db, ItemInfo *itemInfo, int channelID = -1, ChannelInfo *channelInfo = NULL);


//int insert






#endif