// Project Identifier: C0F4DFE8B340D81183C208F70F9D2D797908754Ds #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "TableEntry.h" using namespace std; // Quiet mode: // Print only numerical summaries of the rows affected by the commnand // SILLY CLASS class Silly { public: bool quiet; Silly(): quiet(false){} }; // COLUMN CLASS class Column{ public: // COLTYPE: d = double, i = int, b = bool, s = string char coltype; std::string colname; std::unordered_map hash_map; std::map bst_map; std::vector col; bool hash_index; bool bst_index; Column(char type): coltype(type), colname(""), hash_index(false), bst_index(false){} }; // TABLE CLASS class Table{ public: std::string tablename; int num_cols; std::vector cols; Table(std::string t, int cols): tablename(t), num_cols(cols){} }; // UTILITY //////////////////////////////////////////////////////////////////////////////////////////////////////////// // process command line void process_cmd_line(int argc, char** argv, Silly &silly); // set command char set_command(string &cmd); // create table entry TableEntry create_entry(Column &column); // if column in table, returns column index. else, returns -1 size_t get_col_index(string &colname, Table &table); // FUNCTIONS //////////////////////////////////////////////////////////////////////////////////////////////////////////// // CREATE void create_table(string &argument, unordered_map &table_map); // INSERT void insert_into(string &argument, unordered_map &table_map); // takes coltype, operation and value, adjusts value based on coltype, and returns true if row should be deleted bool delete_check(char &coltype, TableEntry &col_entry, string &operation, string &value); // for each column in table, delete entry at col_index void execute_delete(Table &table, size_t col_index); // DELETE void delete_rows(string &argument, unordered_map &table_map); // GENERATE void generate_index(string &colname, unordered_map &table_map); // takes coltype, operation and value, adjusts value based on coltype, and returns true if row should be printed bool print_check(Table &table_map, size_t &index, string &colname, string &operation, string &value); // PRINT void print_rows(string &argument, unordered_map &table_map, Silly &silly); // print join row void print_j_row(Table &table1, Table &table2, vector &colnames, vector &table_specs, size_t &index_one, size_t &index_two); // JOIN void join_tables(string &argument, unordered_map &table_map, Silly &silly); // REMOVE void remove_table(string &argument, unordered_map &table_map); // ERRORS ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // check table already exists bool check_table_exists(string &tablename, unordered_map &table_map); // print already exists void print_table_exists(string &tablename, string command); // print table does not exist void print_table_n_exists(string &tablename, string command); // returns true if column is in table bool check_column(string &colname, Table &table); // print column not in table void print_check_column(string &colname, string command, Table &table);