Added a key bool to PAttribute, made sure CreateCMD saves which are keys.

This commit is contained in:
Alexander Huddleston 2015-09-24 13:13:39 -05:00
parent c2cb81d31d
commit 1f004caf3f
3 changed files with 17 additions and 10 deletions

View file

@ -37,6 +37,7 @@ class PAttribute
string name;
string type;
string size;
bool key;
public:
PAttribute()
@ -44,6 +45,7 @@ class PAttribute
name = "~";
type = "~";
size = "~";
key = false;
}
PAttribute(string str, string t)
@ -51,6 +53,7 @@ class PAttribute
name = str;
type = t;
size = "~";
key = false;
}
PAttribute(string str, string t, string s)
@ -58,6 +61,7 @@ class PAttribute
name = str;
type = t;
size = s;
key = false;
}
void setPAttributeName(string str)
@ -75,6 +79,11 @@ class PAttribute
size = s;
}
void setPAttributeKey()
{
key = true;
}
string getPAttribute()
{
return name;

View file

@ -127,8 +127,6 @@ vector<string> createCMD(vector<string> input)
{
input.erase(input.begin());
//vector <PExpression> e1;
vector <PAttribute> a;
while(input[0] != ")") //inserting all values to relation
@ -159,8 +157,6 @@ vector<string> createCMD(vector<string> input)
a.push_back(temp);
}
vector <PAttribute> apk; //save primary keys temp storage
if(input[0] == "PRIMARY" && input[1] == "KEY")
{
input.erase(input.begin());
@ -171,21 +167,23 @@ vector<string> createCMD(vector<string> input)
while(input[0] != ")") //inserting all values to relation
{
PAttribute temp;
if (input[0] == ",")
{
input.erase(input.begin());
}
temp.setPAttributeName(input[0]);
apk.push_back(temp);
for(int i = 0; i < a.size(); ++i)
{
if(input[0] == a[i].getPAttribute())
{
a[i].setPAttributeKey();
break;
}
}
input.erase(input.begin());
}
return input;
}

BIN
a.out

Binary file not shown.