-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.h
More file actions
89 lines (63 loc) · 2.07 KB
/
utils.h
File metadata and controls
89 lines (63 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#ifndef __UTILS__
#define __UTILS__
#include <cstdlib>
#include <vector>
#include <string>
#include <fstream>
#include <sstream>
#include <iostream>
#include <pqxx/pqxx>
using std::vector;
using std::string;
/* #define PLAYER "\"PLAYER\""
#define TEAM "\"TEAM\""
#define STATE "\"STATE\""
#define COLOR "\"COLOR\"" */
using namespace std;
using namespace pqxx;
extern int last_playerID;
extern int last_teamID;
extern int last_stateID;
extern int last_colorID;
/*
* Initializes table attributes
*/
vector<pair<string, string> > getPlayerAttributes();
vector<pair<string, string> > getTeamAttributes();
vector<pair<string, string> > getStateAttributes();
vector<pair<string, string> > getColorAttributes();
/**
*
* Helper Functions
*
*/
void tokenize(string & input, string & delim, vector<string> & tokens, int start_indx);
vector<string> parse(string data, string delim);
string addSingleQuotes(string input);
vector<string> parseTextFiles(string filename, int & last_id);
/*
* Query Handlers
*/
//Create string of attributes from attribute vector
string getAttributeString(vector<pair<string, string> > & attr);
//Generates a query string to create a table based on the vector of attributes
//t_name: name of the table
//attributes: vector of attibute:domain pairs (first mapping must be the primary key)
string buildCreateQuery(string & t_name, vector<pair<string, string> > attributes);
//Generates a query string to insert a row into a table
//params:
//t_name: name of table to insert into
//attributes: vector of attibute:domain pairs
//values: string of value items to insert into table
string buildInsertQuery(string & t_name,
vector<pair<string, string> > & attributes, string & values);
stringstream buildSelectQuery(vector<string> & attributes, vector<string> & tables);
void printQueryResults(result * res, vector<string> & attributes);
/*
* Table Handlers
*/
void createDBTables(connection & db_conn);
void initDBTable(connection & db_conn, string file_name, string t_name);
void initAllTables(connection & db_conn);
void cleanupDB(connection & db_conn);
#endif