made parser.h look less awful
This commit is contained in:
parent
949f846931
commit
5f020e60ed
2 changed files with 71 additions and 210 deletions
267
Parser.h
267
Parser.h
|
@ -12,24 +12,10 @@ class PRelation
|
||||||
string name;
|
string name;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PRelation()
|
PRelation() { name = "~"; }
|
||||||
{
|
PRelation(string str) { name = str; }
|
||||||
name = "~";
|
void setPRelation(string str) { name = str; }
|
||||||
}
|
string getName() { return name; }
|
||||||
|
|
||||||
PRelation(string str)
|
|
||||||
{
|
|
||||||
name = str;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setPRelation(string str)
|
|
||||||
{
|
|
||||||
name = str;
|
|
||||||
}
|
|
||||||
string getName()
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class PAttribute
|
class PAttribute
|
||||||
|
@ -40,69 +26,35 @@ class PAttribute
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PAttribute()
|
PAttribute() {
|
||||||
{
|
|
||||||
name = "~";
|
name = "~";
|
||||||
type = "~";
|
type = "~";
|
||||||
key = false;
|
key = false;
|
||||||
size = 0;
|
size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
PAttribute(string str, string t)
|
PAttribute(string str, string t) {
|
||||||
{
|
|
||||||
name = str;
|
name = str;
|
||||||
type = t;
|
type = t;
|
||||||
key = false;
|
key = false;
|
||||||
size = 0;
|
size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
PAttribute(string str, string t, int s)
|
PAttribute(string str, string t, int s) {
|
||||||
{
|
|
||||||
name = str;
|
name = str;
|
||||||
type = t;
|
type = t;
|
||||||
key = false;
|
key = false;
|
||||||
size = s;
|
size = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPAttributeName(string str)
|
void setPAttributeName(string str) { name = str; }
|
||||||
{
|
void setPAttributeType(string t) { type = t; }
|
||||||
name = str;
|
void setPAttributeKey() { key = true; }
|
||||||
}
|
void setPAttributeSize(int s) { size = s; }
|
||||||
|
string getPAttribute() { return name; }
|
||||||
void setPAttributeType(string t)
|
string getPAttributeType() { return type; }
|
||||||
{
|
bool getPAttributeKey() { return key; }
|
||||||
type = t;
|
int getPAttributeSize() { return size; }
|
||||||
}
|
|
||||||
|
|
||||||
void setPAttributeKey()
|
|
||||||
{
|
|
||||||
key = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setPAttributeSize(int s)
|
|
||||||
{
|
|
||||||
size = s;
|
|
||||||
}
|
|
||||||
|
|
||||||
string getPAttribute()
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
string getPAttributeType()
|
|
||||||
{
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool getPAttributeKey()
|
|
||||||
{
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getPAttributeSize()
|
|
||||||
{
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class PUnion
|
class PUnion
|
||||||
|
@ -111,20 +63,17 @@ class PUnion
|
||||||
string Un2;
|
string Un2;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PUnion()
|
PUnion() {
|
||||||
{
|
|
||||||
Un1 = "~";
|
Un1 = "~";
|
||||||
Un2 = "~";
|
Un2 = "~";
|
||||||
}
|
}
|
||||||
|
|
||||||
PUnion (string s1, string s2)
|
PUnion(string s1, string s2) {
|
||||||
{
|
|
||||||
Un1 = s1;
|
Un1 = s1;
|
||||||
Un2 = s2;
|
Un2 = s2;
|
||||||
}
|
}
|
||||||
|
|
||||||
string getPUnion()
|
string getPUnion() {
|
||||||
{
|
|
||||||
return "Union of " + Un1 + " and " + Un2;
|
return "Union of " + Un1 + " and " + Un2;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -135,20 +84,17 @@ class PProduct
|
||||||
string Pr2;
|
string Pr2;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PProduct()
|
PProduct() {
|
||||||
{
|
|
||||||
Pr1 = "~";
|
Pr1 = "~";
|
||||||
Pr2 = "~";
|
Pr2 = "~";
|
||||||
}
|
}
|
||||||
|
|
||||||
PProduct(string s1, string s2)
|
PProduct(string s1, string s2) {
|
||||||
{
|
|
||||||
Pr1 = s1;
|
Pr1 = s1;
|
||||||
Pr2 = s2;
|
Pr2 = s2;
|
||||||
}
|
}
|
||||||
|
|
||||||
string getPProduct()
|
string getPProduct() {
|
||||||
{
|
|
||||||
return "Product of " + Pr1 + " and " + Pr2;
|
return "Product of " + Pr1 + " and " + Pr2;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -159,20 +105,17 @@ class PDifference
|
||||||
string D2;
|
string D2;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PDifference()
|
PDifference() {
|
||||||
{
|
|
||||||
D1 = "~";
|
D1 = "~";
|
||||||
D2 = "~";
|
D2 = "~";
|
||||||
}
|
}
|
||||||
|
|
||||||
PDifference(string s1, string s2)
|
PDifference(string s1, string s2) {
|
||||||
{
|
|
||||||
D1 = s1;
|
D1 = s1;
|
||||||
D2 = s2;
|
D2 = s2;
|
||||||
}
|
}
|
||||||
|
|
||||||
string getPDifference()
|
string getPDifference() {
|
||||||
{
|
|
||||||
return "Difference of " + D1 + " and " + D2;
|
return "Difference of " + D1 + " and " + D2;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -183,20 +126,17 @@ class PRenaming
|
||||||
string oldName;
|
string oldName;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PRenaming()
|
PRenaming() {
|
||||||
{
|
|
||||||
newName = "~";
|
newName = "~";
|
||||||
oldName = "~";
|
oldName = "~";
|
||||||
}
|
}
|
||||||
|
|
||||||
PRenaming(string s1, string s2)
|
PRenaming(string s1, string s2) {
|
||||||
{
|
|
||||||
newName = s1;
|
newName = s1;
|
||||||
oldName = s2;
|
oldName = s2;
|
||||||
}
|
}
|
||||||
|
|
||||||
string doRename()
|
string doRename() {
|
||||||
{
|
|
||||||
return "Renaming " + oldName + " to " + newName;
|
return "Renaming " + oldName + " to " + newName;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -207,20 +147,17 @@ class PProjection
|
||||||
string oldName;
|
string oldName;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PProjection()
|
PProjection() {
|
||||||
{
|
|
||||||
newName = "~";
|
newName = "~";
|
||||||
oldName = "~";
|
oldName = "~";
|
||||||
}
|
}
|
||||||
|
|
||||||
PProjection(string s1, string s2)
|
PProjection(string s1, string s2) {
|
||||||
{
|
|
||||||
newName = s1;
|
newName = s1;
|
||||||
oldName = s2;
|
oldName = s2;
|
||||||
}
|
}
|
||||||
|
|
||||||
string doPProjection()
|
string doPProjection() {
|
||||||
{
|
|
||||||
return "Projecting " + oldName + " onto " + newName;
|
return "Projecting " + oldName + " onto " + newName;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -230,26 +167,10 @@ class POperand
|
||||||
string op;
|
string op;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
POperand() { op = "~"; }
|
||||||
POperand()
|
POperand(string str) { op = str; }
|
||||||
{
|
void setPOperand(string str) { op = str; }
|
||||||
op = "~";
|
string getPOperand() { return op; }
|
||||||
}
|
|
||||||
|
|
||||||
POperand(string str)
|
|
||||||
{
|
|
||||||
op = str;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setPOperand(string str)
|
|
||||||
{
|
|
||||||
op = str;
|
|
||||||
}
|
|
||||||
|
|
||||||
string getPOperand()
|
|
||||||
{
|
|
||||||
return op;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class POp
|
class POp
|
||||||
|
@ -257,25 +178,10 @@ class POp
|
||||||
string op;
|
string op;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
POp()
|
POp() { op = "~"; }
|
||||||
{
|
POp(string str) { op = str; }
|
||||||
op = "~";
|
void setPOp(string str) { op = str; }
|
||||||
}
|
string getPOp() { return op; }
|
||||||
|
|
||||||
POp(string str)
|
|
||||||
{
|
|
||||||
op = str;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setPOp(string str)
|
|
||||||
{
|
|
||||||
op = str;
|
|
||||||
}
|
|
||||||
|
|
||||||
string getPOp()
|
|
||||||
{
|
|
||||||
return op;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class PComparison
|
class PComparison
|
||||||
|
@ -285,29 +191,25 @@ class PComparison
|
||||||
POperand operand2;
|
POperand operand2;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PComparison()
|
PComparison() {
|
||||||
{
|
|
||||||
op.setPOp("~");
|
op.setPOp("~");
|
||||||
operand1.setPOperand("~");
|
operand1.setPOperand("~");
|
||||||
operand2.setPOperand("~");
|
operand2.setPOperand("~");
|
||||||
}
|
}
|
||||||
|
|
||||||
PComparison(string str1, string str2, string str3)
|
PComparison(string str1, string str2, string str3) {
|
||||||
{
|
|
||||||
operand1.setPOperand(str1);
|
operand1.setPOperand(str1);
|
||||||
op.setPOp(str2);
|
op.setPOp(str2);
|
||||||
operand2.setPOperand(str3);
|
operand2.setPOperand(str3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPComparison(string str1, string str2, string str3)
|
void setPComparison(string str1, string str2, string str3) {
|
||||||
{
|
|
||||||
operand1.setPOperand(str1);
|
operand1.setPOperand(str1);
|
||||||
op.setPOp(str2);
|
op.setPOp(str2);
|
||||||
operand2.setPOperand(str3);
|
operand2.setPOperand(str3);
|
||||||
}
|
}
|
||||||
|
|
||||||
string getPComparison()
|
string getPComparison() {
|
||||||
{
|
|
||||||
return operand1.getPOperand() + " " + op.getPOp() + " " + operand2.getPOperand();
|
return operand1.getPOperand() + " " + op.getPOp() + " " + operand2.getPOperand();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -316,25 +218,10 @@ class PConjunction
|
||||||
{
|
{
|
||||||
string conj;
|
string conj;
|
||||||
public:
|
public:
|
||||||
PConjunction()
|
PConjunction() { conj = "~"; }
|
||||||
{
|
PConjunction(string str) { conj = str; }
|
||||||
conj = "~";
|
void setPConjunction(string str) { conj = str; }
|
||||||
}
|
string getPConjunction() { return conj; }
|
||||||
|
|
||||||
PConjunction(string str)
|
|
||||||
{
|
|
||||||
conj = str;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setPConjunction(string str)
|
|
||||||
{
|
|
||||||
conj = str;
|
|
||||||
}
|
|
||||||
|
|
||||||
string getPConjunction()
|
|
||||||
{
|
|
||||||
return conj;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class PCondition
|
class PCondition
|
||||||
|
@ -342,45 +229,19 @@ class PCondition
|
||||||
string cond;
|
string cond;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
PCondition()
|
PCondition() { cond = "~"; }
|
||||||
{
|
PCondition(string str) { cond = str; }
|
||||||
cond = "~";
|
void setPCondition(string str) { cond = str; }
|
||||||
}
|
string getPCondition() { return cond; }
|
||||||
|
|
||||||
PCondition(string str)
|
|
||||||
{
|
|
||||||
cond = str;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setPCondition(string str)
|
|
||||||
{
|
|
||||||
cond = str;
|
|
||||||
}
|
|
||||||
|
|
||||||
string getPCondition()
|
|
||||||
{
|
|
||||||
return cond;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class PSelection
|
class PSelection
|
||||||
{
|
{
|
||||||
string select;
|
string select;
|
||||||
public:
|
public:
|
||||||
PSelection()
|
PSelection() { select = "~"; }
|
||||||
{
|
PSelection(string str) { select = str; }
|
||||||
select = "~";
|
string getPSelection() { return select; }
|
||||||
}
|
|
||||||
|
|
||||||
PSelection(string str)
|
|
||||||
{
|
|
||||||
select = str;
|
|
||||||
}
|
|
||||||
|
|
||||||
string getPSelection()
|
|
||||||
{
|
|
||||||
return select;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class PExpression
|
class PExpression
|
||||||
|
@ -396,24 +257,10 @@ class PExpression
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
PExpression()
|
PExpression() { select = "~"; }
|
||||||
{
|
PExpression(string str) { temp = str; }
|
||||||
}
|
void setPExpression(string str) { temp = str; }
|
||||||
|
string getPExpression() { return temp; }
|
||||||
PExpression(string str)
|
|
||||||
{
|
|
||||||
temp = str;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setPExpression(string str)
|
|
||||||
{
|
|
||||||
temp = str;
|
|
||||||
}
|
|
||||||
|
|
||||||
string getPExpression()
|
|
||||||
{
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void parse(string s, DBEngine &e);
|
void parse(string s, DBEngine &e);
|
14
parsertest.cpp
Executable file
14
parsertest.cpp
Executable file
|
@ -0,0 +1,14 @@
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
#include "Parser.h"
|
||||||
|
//#include "Condition.h"
|
||||||
|
#include "DBEngine.h"
|
||||||
|
//#include "user.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main () {
|
||||||
|
DBEngine engine;
|
||||||
|
|
||||||
|
//
|
||||||
|
}
|
Reference in a new issue