Fixed merge issues. Everything compiles and runs again.
This commit is contained in:
parent
b0aaaf902f
commit
3436a00452
6 changed files with 37 additions and 128 deletions
46
DBEngine.cpp
46
DBEngine.cpp
|
@ -45,13 +45,6 @@ vector<Relation> DBEngine::getRelations(){
|
|||
return tables;
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
=======
|
||||
>>>>>>> master
|
||||
|
||||
>>>>>>> master
|
||||
Relation& DBEngine::getTableFromName(string n){
|
||||
for(int i = 0; i < tables.size(); i++){
|
||||
if (tables[i].getTableName() == n){
|
||||
|
@ -64,7 +57,7 @@ Relation DBEngine::selection(string attName, string s, Relation r){
|
|||
equality(attName, s, r);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Relation DBEngine::selection(string attName, string s, Relation r){
|
||||
equality(attName, s, r);
|
||||
}
|
||||
|
@ -73,6 +66,7 @@ Relation DBEngine::selection(string attName, string s, Relation r){
|
|||
Relation DBEngine::selection(string attName, string s, Relation r){
|
||||
equality(attName, s, r);
|
||||
}
|
||||
*/
|
||||
|
||||
//assumes that all attribute titles are unique
|
||||
Relation DBEngine::projection(vector<string> input, Relation r){
|
||||
|
@ -90,8 +84,6 @@ Relation DBEngine::projection(vector<string> input, Relation r){
|
|||
|
||||
Relation temp(new_name, v);
|
||||
return temp;
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
|
||||
Relation DBEngine::product(string new_name, Relation r1, Relation r2){
|
||||
|
@ -114,10 +106,6 @@ Relation DBEngine::product(string new_name, Relation r1, Relation r2){
|
|||
vector<string> result_tuple;
|
||||
|
||||
return temp;
|
||||
=======
|
||||
>>>>>>> master
|
||||
=======
|
||||
>>>>>>> master
|
||||
}
|
||||
|
||||
//test error matching
|
||||
|
@ -139,11 +127,9 @@ void DBEngine::rename(Relation& r, vector<string> oldnames, vector<string> newna
|
|||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
|
||||
|
||||
/*Relation DBEngine::setUnion(Relation r1, Relation r2){
|
||||
/*
|
||||
Relation DBEngine::setUnion(Relation r1, Relation r2){
|
||||
if (r1.getAttributeNames() != r2.getAttributeNames()){
|
||||
cout << "Failure to union: the relations are not union-compatible";
|
||||
return;
|
||||
|
@ -151,9 +137,7 @@ void DBEngine::rename(Relation& r, vector<string> oldnames, vector<string> newna
|
|||
|
||||
else {
|
||||
vector<Attribute> r1_atts = r1.getAttributes();
|
||||
=======
|
||||
=======
|
||||
>>>>>>> master
|
||||
*/
|
||||
Relation DBEngine::setUnion(Relation r1, Relation r2){
|
||||
if (r1.getAttributeNames() != r2.getAttributeNames()){
|
||||
cout << "Failure to union: the relations are not union-compatible.\nreturning the first relation.\n";
|
||||
|
@ -187,13 +171,9 @@ Relation DBEngine::setUnion(Relation r1, Relation r2){
|
|||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
/*vector<Attribute> r1_atts = r1.getAttributes();
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> master
|
||||
=======
|
||||
>>>>>>> master
|
||||
vector<Attribute> r1_atts = r1.getAttributes();
|
||||
vector<Attribute> r2_atts = r2.getAttributes();
|
||||
vector<Attribute> new_atts = r1_atts;
|
||||
|
||||
|
@ -214,18 +194,6 @@ Relation DBEngine::setUnion(Relation r1, Relation r2){
|
|||
|
||||
//currently all returned relations are called TEMP
|
||||
Relation new_r("TEMP", new_atts);
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
return new_r;
|
||||
}
|
||||
}*/
|
||||
=======
|
||||
return new_r;*/
|
||||
}
|
||||
}
|
||||
>>>>>>> master
|
||||
=======
|
||||
return new_r;*/
|
||||
}
|
||||
}
|
||||
>>>>>>> master
|
||||
|
|
|
@ -23,17 +23,9 @@ public:
|
|||
Relation projection(vector<string> input, Relation r);
|
||||
Relation product(string s1, Relation r1, Relation r2);
|
||||
void rename(Relation& r, vector<string> oldnames, vector<string> newnames);
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
void save();
|
||||
void storeCommands(string s);
|
||||
//Relation setUnion(Relation r1, Relation r2);
|
||||
=======
|
||||
Relation setUnion(Relation r1, Relation r2);
|
||||
>>>>>>> master
|
||||
=======
|
||||
Relation setUnion(Relation r1, Relation r2);
|
||||
>>>>>>> master
|
||||
//void setDiff();
|
||||
//void crossProduct();
|
||||
};
|
||||
|
|
52
Parserv3.h
52
Parserv3.h
|
@ -7,13 +7,6 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> master
|
||||
=======
|
||||
>>>>>>> master
|
||||
class PRelation
|
||||
{
|
||||
string name;
|
||||
|
@ -269,18 +262,6 @@ class PComparison
|
|||
|
||||
public:
|
||||
PComparison()
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
{
|
||||
op.setPOp("~");
|
||||
operand1.setPOperand("~");
|
||||
operand2.setPOperand("~");
|
||||
}
|
||||
|
||||
PComparison(string str1, string str2, string str3)
|
||||
=======
|
||||
=======
|
||||
>>>>>>> master
|
||||
{
|
||||
op.setPOp("~");
|
||||
operand1.setPOperand("~");
|
||||
|
@ -295,19 +276,6 @@ class PComparison
|
|||
}
|
||||
|
||||
void setPComparison(string str1, string str2, string str3)
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> master
|
||||
=======
|
||||
>>>>>>> master
|
||||
{
|
||||
operand1.setPOperand(str1);
|
||||
op.setPOp(str2);
|
||||
operand2.setPOperand(str3);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
void setPComparison(string str1, string str2, string str3)
|
||||
{
|
||||
operand1.setPOperand(str1);
|
||||
op.setPOp(str2);
|
||||
|
@ -316,14 +284,6 @@ class PComparison
|
|||
|
||||
string getPComparison()
|
||||
{
|
||||
=======
|
||||
string getPComparison()
|
||||
{
|
||||
>>>>>>> master
|
||||
=======
|
||||
string getPComparison()
|
||||
{
|
||||
>>>>>>> master
|
||||
return operand1.getPOperand() + " " + op.getPOp() + " " + operand2.getPOperand();
|
||||
}
|
||||
};
|
||||
|
@ -431,10 +391,8 @@ class PExpression
|
|||
return temp;
|
||||
}
|
||||
};
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
|
||||
|
||||
/*
|
||||
vector<string> tokenize(string ss)
|
||||
{
|
||||
|
||||
|
@ -835,7 +793,7 @@ void par_line(vector<string> input) //calls par_command() or par_query() dependi
|
|||
• Match the first item in the token list and determine weather this is a command or a query.
|
||||
• Call functions par_command() or par_query();
|
||||
• After either par_command() or par_query() returns, make sure the line ends properly with “;” token
|
||||
*/
|
||||
|
||||
string tempChar = input.back();
|
||||
|
||||
if (tempChar != ";")
|
||||
|
@ -921,8 +879,6 @@ void parse(string input, DBEngine &engine)
|
|||
vector<string> listOfTokens = tokenize(input);
|
||||
par_line(listOfTokens);
|
||||
}
|
||||
*/
|
||||
|
||||
=======
|
||||
>>>>>>> master
|
||||
=======
|
||||
>>>>>>> master
|
||||
void parse(string s, DBEngine &e);
|
|
@ -486,6 +486,13 @@ void par_line(vector<string> input) //calls par_command() or par_query() dependi
|
|||
}
|
||||
}
|
||||
|
||||
void parse(string input, DBEngine &engine)
|
||||
{
|
||||
engine.storeCommands(input);
|
||||
vector<string> listOfTokens = tokenize(input);
|
||||
par_line(listOfTokens);
|
||||
}
|
||||
/*
|
||||
int main () {
|
||||
|
||||
|
||||
|
@ -503,3 +510,4 @@ int main () {
|
|||
|
||||
|
||||
}
|
||||
*/
|
25
test.cpp
25
test.cpp
|
@ -1,14 +1,7 @@
|
|||
#include <iostream>
|
||||
#include <vector>
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
#include "Parserv3.h"
|
||||
=======
|
||||
#include "Condition.h"
|
||||
>>>>>>> master
|
||||
=======
|
||||
#include "Condition.h"
|
||||
>>>>>>> master
|
||||
//#include "Condition.h"
|
||||
#include "DBEngine.h"
|
||||
|
||||
using namespace std;
|
||||
|
@ -36,8 +29,6 @@ int main() {
|
|||
v.push_back(att2);
|
||||
v.push_back(att3);
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
Relation r("Food", v);
|
||||
//r.renameAttribute("Breakfast", "BFST");
|
||||
//r.display();
|
||||
|
@ -101,13 +92,10 @@ int main () {
|
|||
parse(ss3, engine);
|
||||
|
||||
engine.save();
|
||||
/*
|
||||
|
||||
|
||||
=======
|
||||
engine.createTable("Food", v);
|
||||
=======
|
||||
engine.createTable("Food", v);
|
||||
>>>>>>> master
|
||||
//engine.createTable("Food", v);
|
||||
//engine.createTable("Food", v);
|
||||
|
||||
Attribute att4("Breakfast", "VARCHAR(20)", true);
|
||||
Attribute att5("Lunch", "VARCHAR(20)", false);
|
||||
|
@ -131,8 +119,5 @@ int main () {
|
|||
engine.createTable("MoarFood", v2);
|
||||
|
||||
engine.setUnion(engine.getTableFromName("Food"), engine.getTableFromName("MoarFood")).display();
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> master
|
||||
=======
|
||||
>>>>>>> master
|
||||
*/
|
||||
}
|
||||
|
|
Reference in a new issue