Added a key bool to PAttribute, made sure CreateCMD saves which are keys.
This commit is contained in:
parent
c2cb81d31d
commit
1f004caf3f
3 changed files with 17 additions and 10 deletions
|
@ -37,6 +37,7 @@ class PAttribute
|
||||||
string name;
|
string name;
|
||||||
string type;
|
string type;
|
||||||
string size;
|
string size;
|
||||||
|
bool key;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PAttribute()
|
PAttribute()
|
||||||
|
@ -44,6 +45,7 @@ class PAttribute
|
||||||
name = "~";
|
name = "~";
|
||||||
type = "~";
|
type = "~";
|
||||||
size = "~";
|
size = "~";
|
||||||
|
key = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PAttribute(string str, string t)
|
PAttribute(string str, string t)
|
||||||
|
@ -51,6 +53,7 @@ class PAttribute
|
||||||
name = str;
|
name = str;
|
||||||
type = t;
|
type = t;
|
||||||
size = "~";
|
size = "~";
|
||||||
|
key = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PAttribute(string str, string t, string s)
|
PAttribute(string str, string t, string s)
|
||||||
|
@ -58,6 +61,7 @@ class PAttribute
|
||||||
name = str;
|
name = str;
|
||||||
type = t;
|
type = t;
|
||||||
size = s;
|
size = s;
|
||||||
|
key = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPAttributeName(string str)
|
void setPAttributeName(string str)
|
||||||
|
@ -75,6 +79,11 @@ class PAttribute
|
||||||
size = s;
|
size = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setPAttributeKey()
|
||||||
|
{
|
||||||
|
key = true;
|
||||||
|
}
|
||||||
|
|
||||||
string getPAttribute()
|
string getPAttribute()
|
||||||
{
|
{
|
||||||
return name;
|
return name;
|
||||||
|
|
18
Parserv4.cpp
18
Parserv4.cpp
|
@ -127,8 +127,6 @@ vector<string> createCMD(vector<string> input)
|
||||||
{
|
{
|
||||||
input.erase(input.begin());
|
input.erase(input.begin());
|
||||||
|
|
||||||
//vector <PExpression> e1;
|
|
||||||
|
|
||||||
vector <PAttribute> a;
|
vector <PAttribute> a;
|
||||||
|
|
||||||
while(input[0] != ")") //inserting all values to relation
|
while(input[0] != ")") //inserting all values to relation
|
||||||
|
@ -159,8 +157,6 @@ vector<string> createCMD(vector<string> input)
|
||||||
a.push_back(temp);
|
a.push_back(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector <PAttribute> apk; //save primary keys temp storage
|
|
||||||
|
|
||||||
if(input[0] == "PRIMARY" && input[1] == "KEY")
|
if(input[0] == "PRIMARY" && input[1] == "KEY")
|
||||||
{
|
{
|
||||||
input.erase(input.begin());
|
input.erase(input.begin());
|
||||||
|
@ -171,22 +167,24 @@ vector<string> createCMD(vector<string> input)
|
||||||
|
|
||||||
while(input[0] != ")") //inserting all values to relation
|
while(input[0] != ")") //inserting all values to relation
|
||||||
{
|
{
|
||||||
PAttribute temp;
|
|
||||||
|
|
||||||
if (input[0] == ",")
|
if (input[0] == ",")
|
||||||
{
|
{
|
||||||
input.erase(input.begin());
|
input.erase(input.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
temp.setPAttributeName(input[0]);
|
for(int i = 0; i < a.size(); ++i)
|
||||||
|
{
|
||||||
apk.push_back(temp);
|
if(input[0] == a[i].getPAttribute())
|
||||||
|
{
|
||||||
|
a[i].setPAttributeKey();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
input.erase(input.begin());
|
input.erase(input.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
BIN
a.out
BIN
a.out
Binary file not shown.
Reference in a new issue