This repository has been archived on 2025-04-11. You can view files and clone it, but cannot push or open issues or pull requests.
dmspine64backup/Attribute.cpp

92 lines
1.4 KiB
C++
Raw Permalink Normal View History

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
}
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-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) {
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";
cout << name << "\n" << type;
if(type == "VARCHAR")
{
cout << "(" << limit << ")";
}
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
}