2015-09-17 18:30:45 -05:00
|
|
|
#include <iostream>
|
|
|
|
#include <vector>
|
|
|
|
#include "Attribute.h"
|
|
|
|
|
2015-09-21 16:27:23 -05:00
|
|
|
Attribute::Attribute(){
|
|
|
|
name = "";
|
|
|
|
type = "";
|
|
|
|
key = 0;
|
|
|
|
size = 0;
|
2015-09-28 17:02:04 -05:00
|
|
|
limit = 0;
|
2015-09-21 16:27:23 -05:00
|
|
|
}
|
|
|
|
|
2015-09-17 18:30:45 -05:00
|
|
|
Attribute::Attribute(string n, string t, bool k){
|
|
|
|
name = n;
|
|
|
|
type = t;
|
|
|
|
key = k;
|
|
|
|
size = 0;
|
2015-09-28 17:02:04 -05:00
|
|
|
limit = 20;
|
2015-09-17 18:30:45 -05:00
|
|
|
}
|
|
|
|
|
2015-09-27 23:24:02 -05:00
|
|
|
Attribute::Attribute(string n, string t, bool k, int s){
|
|
|
|
name = n;
|
|
|
|
type = t;
|
|
|
|
key = k;
|
2015-09-28 17:02:04 -05:00
|
|
|
size = 0;
|
|
|
|
limit = s;
|
2015-09-27 23:24:02 -05:00
|
|
|
}
|
|
|
|
|
2015-09-17 18:30:45 -05:00
|
|
|
void Attribute::addCell(string v){
|
|
|
|
values.push_back(v);
|
|
|
|
size++;
|
|
|
|
}
|
|
|
|
|
2015-09-26 23:24:24 -05:00
|
|
|
void Attribute::removeCell(int index){
|
|
|
|
values.erase(values.begin() + index);
|
|
|
|
size--;
|
|
|
|
}
|
|
|
|
|
2015-09-17 18:30:45 -05:00
|
|
|
string Attribute::operator[](int i){
|
|
|
|
return values[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
vector<string> Attribute::getValues(){
|
|
|
|
return values;
|
|
|
|
}
|
|
|
|
|
|
|
|
string Attribute::getName(){
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2015-09-21 16:27:23 -05:00
|
|
|
void Attribute::setName(string s){
|
|
|
|
name = s;
|
|
|
|
}
|
|
|
|
|
2015-10-05 16:50:19 -05:00
|
|
|
void Attribute::setValue(string s, int index) {
|
2015-09-29 23:51:50 -05:00
|
|
|
values[index] = s;
|
|
|
|
}
|
|
|
|
|
2015-09-17 18:30:45 -05:00
|
|
|
string Attribute::getType(){
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Attribute::isKey(){
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Attribute::getSize(){
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Attribute::display(){
|
|
|
|
cout << "-------------\n";
|
2015-09-27 23:24:02 -05:00
|
|
|
cout << name << "\n" << type;
|
|
|
|
if(type == "VARCHAR")
|
|
|
|
{
|
2015-09-29 12:00:37 -05:00
|
|
|
cout << "(" << limit << ")";
|
2015-09-27 23:24:02 -05:00
|
|
|
}
|
|
|
|
cout << "\n\n";
|
2015-09-17 18:30:45 -05:00
|
|
|
|
|
|
|
vector<string>::iterator it = values.begin();
|
|
|
|
while (it != values.end()){
|
|
|
|
cout << *it << "\n";
|
|
|
|
it++;
|
|
|
|
}
|
|
|
|
|
|
|
|
cout << "-------------\n";
|
2015-09-26 23:24:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void Attribute::clearAllValues(){
|
|
|
|
values.clear();
|
2015-10-05 16:50:19 -05:00
|
|
|
size = 0;
|
2015-09-17 18:30:45 -05:00
|
|
|
}
|