Added case for insert to do projected, to add more cases later.
This commit is contained in:
parent
e2718e3c91
commit
1448b0147d
2 changed files with 51 additions and 13 deletions
35
Parserv3.h
35
Parserv3.h
|
@ -188,25 +188,35 @@ class PRenaming
|
||||||
|
|
||||||
class PProjection
|
class PProjection
|
||||||
{
|
{
|
||||||
string newName;
|
string AName;
|
||||||
string oldName;
|
string RName;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PProjection()
|
PProjection()
|
||||||
{
|
{
|
||||||
newName = "~";
|
AName = "~";
|
||||||
oldName = "~";
|
RName = "~";
|
||||||
}
|
}
|
||||||
|
|
||||||
PProjection(string s1, string s2)
|
PProjection(string s1, string s2)
|
||||||
{
|
{
|
||||||
newName = s1;
|
AName = s1;
|
||||||
oldName = s2;
|
RName = s2;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setAName(string s)
|
||||||
|
{
|
||||||
|
AName = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setRName(string s)
|
||||||
|
{
|
||||||
|
RName = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
string doPProjection()
|
string doPProjection()
|
||||||
{
|
{
|
||||||
return "Projecting " + oldName + " onto " + newName;
|
return "Projecting " + AName + " onto " + RName;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -388,11 +398,22 @@ class PExpression
|
||||||
PExpression(string str)
|
PExpression(string str)
|
||||||
{
|
{
|
||||||
temp = str;
|
temp = str;
|
||||||
|
/*
|
||||||
|
if(str == "project")
|
||||||
|
{
|
||||||
|
proj.setAName("");
|
||||||
|
proj.setRName("");
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPExpression(string str)
|
void setPExpression(string str)
|
||||||
{
|
{
|
||||||
temp = str;
|
temp = str;
|
||||||
|
/*
|
||||||
|
if(proj.getAName() != "~" && proj.getRName() != "~")
|
||||||
|
{
|
||||||
|
proj.setAName()
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
string getPExpression()
|
string getPExpression()
|
||||||
|
|
29
Parserv4.cpp
29
Parserv4.cpp
|
@ -184,7 +184,9 @@ vector<string> createCMD(vector<string> input)
|
||||||
|
|
||||||
input.erase(input.begin());
|
input.erase(input.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// send create commands to DBEngine
|
||||||
|
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -251,15 +253,30 @@ vector<string> insertCMD(vector<string> input)
|
||||||
{
|
{
|
||||||
input.erase(input.begin());
|
input.erase(input.begin());
|
||||||
|
|
||||||
PExpression e;
|
//PExpression e(input[0]);
|
||||||
|
|
||||||
while(input[0] != ";")
|
//input.erase(input.begin());
|
||||||
|
|
||||||
|
if(input[0] == "project")
|
||||||
{
|
{
|
||||||
e.setPExpression(e.getPExpression() + input[0]);
|
PProjection p;
|
||||||
|
|
||||||
|
input.erase(input.begin());
|
||||||
|
|
||||||
|
if(intput[0].at(0) == "(")
|
||||||
|
{
|
||||||
|
p.setAName(input[0].substr(1, input[0].find(")")));
|
||||||
|
}
|
||||||
|
|
||||||
|
input.erase(input.begin());
|
||||||
|
|
||||||
|
p.setRName(input[0]);
|
||||||
|
|
||||||
|
input.erase(input.begin());
|
||||||
|
|
||||||
|
// send projection command to DBengine.
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "Inserting: " << e.getPExpression() << " into " << r.getName() << ".\n";
|
|
||||||
|
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue