Merge branch 'master' into alexdev

This commit is contained in:
Alexander Huddleston 2015-09-30 20:02:21 -05:00
commit 015190f5e5
10 changed files with 163 additions and 19 deletions

0
DBAppV2.cpp Normal file → Executable file
View file

View file

@ -215,6 +215,7 @@ Relation DBEngine::setDiff(Relation r1, Relation r2){
Relation new_r = r1;
new_r.setTableName("TEMP");
vector<string> temp;
<<<<<<< HEAD
//bool duplicate = false;
int size = 0;
@ -226,6 +227,15 @@ Relation DBEngine::setDiff(Relation r1, Relation r2){
for (int i = 0; i < r2.getAttributes()[x].getSize(); ++i)
{
=======
int size = 0;
for(int x = 0; x < r2.getAttributes().size(); ++x)
{
for (int i = 0; i < r2.getAttributes()[x].getSize(); ++i)
{
>>>>>>> e3ef70bf1536697f14395063975a6376b7df6f61
temp = r2.getTuple(i);
for(int y = 0; y < new_r.getAttributes().size(); ++y)
@ -248,7 +258,11 @@ Relation DBEngine::setDiff(Relation r1, Relation r2){
}
}
}
<<<<<<< HEAD
}
=======
}
>>>>>>> e3ef70bf1536697f14395063975a6376b7df6f61
return new_r;
}
}
@ -287,4 +301,15 @@ Relation DBEngine::crossProduct(Relation r1, Relation r2){
return new_r;
<<<<<<< HEAD
=======
}
//UPDATE Senator
//SET Party = Independent
//WHERE Name = Joseph Lieberman
Relation DBEngine::update(Relation r, string attNameSet, string attSet, string attNameWhere, string attWhere){
return r;
>>>>>>> e3ef70bf1536697f14395063975a6376b7df6f61
}

View file

@ -30,5 +30,11 @@ public:
Relation rename(vector<string> newnames, Relation &r);
Relation setUnion(Relation r1, Relation r2);
Relation setDiff(Relation r1, Relation r2);
<<<<<<< HEAD
Relation crossProduct(Relation r1, Relation r2);
=======
Relation crossProduct(Relation r1, Relation r2);
Relation update(Relation r, string attNameSet, string attSet, string attNameWhere, string attWhere);
//Relation deleteCmd();
>>>>>>> e3ef70bf1536697f14395063975a6376b7df6f61
};

31
Parser.cpp Normal file → Executable file
View file

@ -581,7 +581,7 @@ tuple<vector<string>, Relation> expression(vector<string> input, DBEngine &engin
vector<string> showCMD(vector<string> input, DBEngine &engine)
{
if(engine.isRelation(input[0]))
if(engine.isRelation(input[0]) && (input[1] != "+" && input[1] != "-" && input[1] != "*"))
{
engine.getTableFromName(input[0]).display();
input.erase(input.begin());
@ -954,6 +954,7 @@ vector<string> updateCMD(vector<string> input, DBEngine &engine)
}
// send update command to DBEngine
}
@ -967,36 +968,30 @@ vector<string> deleteCMD(vector<string> input, DBEngine &engine)
input.erase(input.begin());
input.erase(input.begin());
PRelation r(input[0]);
Relation rcond = engine.getTableFromName(input[0]);
Relation rfinal = engine.getTableFromName(input[0]);
input.erase(input.begin());
vector<string> s;
if(input[0] == "WHERE")
{
input.erase(input.begin());
if(input[0] == "(")
{
//PCondition c;
PComparison c;
POperand oops1;
POperand oops2;
POp op;
input.erase(input.begin());
while(input[0] != ")")
{
oops1.setPOperand(input[0]);
s.push_back(input[0]);
input.erase(input.begin());
oops2.setPOperand(input[0]);
input.erase(input.begin());
op.setPOp(input[0]);
input.erase(input.begin());
c.setPComparison(oops1.getPOperand(), op.getPOp(), oops2.getPOperand());
}
}
}
rcond = condition();
// send delete command to DBEngine
}
else cout<<"Syntax error!"<<endl;
}

0
Parser.h Normal file → Executable file
View file

0
savefile.txt Normal file → Executable file
View file

BIN
test

Binary file not shown.

View file

@ -1,14 +1,49 @@
#include <iostream>
#include <vector>
#include "Parser.h"
<<<<<<< HEAD
//#include "Condition.h"
#include "DBEngine.h"
#include "user.h"
=======
#include "Condition.h"
#include "DBEngine.h"
>>>>>>> e3ef70bf1536697f14395063975a6376b7df6f61
using namespace std;
int main () {
DBEngine engine;
<<<<<<< HEAD
=======
DBEngine engine;
Attribute att1("Breakfast", "VARCHAR(20)", true);
Attribute att2("Lunch", "VARCHAR(20)", false);
Attribute att3("Dinner", "VARCHAR(20)", false);
att1.addCell("Pancakes");
att1.addCell("Waffles");
att1.addCell("Biscuits");
att2.addCell("Turkey Sandwich");
att2.addCell("Caesar Salad");
att2.addCell("Pizza");
att3.addCell("Steak");
att3.addCell("Shrimp");
att3.addCell("Ribs");
vector<Attribute> v;
v.push_back(att1);
v.push_back(att2);
v.push_back(att3);
engine.createTable("Food", v);
//engine.update
/*actual testing
string x;
cout << "Enter DBMS Commands: ";
while(getline(cin, x))
{
@ -16,4 +51,6 @@ int main () {
parse(x, engine);
cout << "Enter DBMS Commands: ";
}
*/
>>>>>>> e3ef70bf1536697f14395063975a6376b7df6f61
}

37
user.cpp Executable file
View file

@ -0,0 +1,37 @@
#include <iostream>
#include <vector>
#include "user.h"
User::User(){
name = "";
password = "";
phone_number = "";
fax_number = "";
postal_address = "";
is_admin = false;
}
User::User(string n, string pass, string phone, string fax, string postal, bool admin){
name = n;
password = pass;
phone_number = phone;
fax_number = fax;
postal_address = postal;
is_admin = admin;
}
string User::getName() {return name;}
string User::getPassword() {return password;}
string User::getPhoneNumber() {return phone_number;}
string User::getFaxNumber() {return fax_number;}
string User::getPostalAddress() {return postal_address;}
bool User::confirmAdmin() {return is_admin;}
bool User::checkLogin() {return is_logged_in;}
vector<string> User::getGroups(){return groups;}
vector<string> User::getMessages(){return messages;}
void User::setName(string new_name) {name = new_name;}
void User::setPassword(string new_password) {password = new_password;}
void User::setPhone(string new_phone) {phone_number = new_phone;}
void User::setFax(string new_fax) {fax_number = new_fax;}
void User::setPostal(string new_postal) {postal_address = new_postal;}

44
user.h Executable file
View file

@ -0,0 +1,44 @@
#include <fstream>
#include <iostream>
#include <vector>
class User {
string name;
string password;
string phone_number;
string fax_number;
string postal_address;
vector<string> groups;
vector<string> messages;
bool is_admin;
bool is_logged_in;
public:
User();
User(string n, string pass, string phone, string fax, string postal, bool admin);
string getName();
string getPassword();
string getPhoneNumber();
string getFaxNumber();
string getPostalAddress();
vector<string> getGroups();
vector<string> getMessages();
bool confirmAdmin();
bool checkLogin();
void setName(string new_name);
void setPassword(string new_name);
void setPhone(string new_phone);
void setFax(string new_fax);
void setPostal(string new_postal);
};
class Message {
string timestamp;
string text;
public:
Message();
Message(string time, string t);
};