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
Rebecca Schofield 20fec486b6 update works
2015-10-05 16:50:19 -05:00

92 lines
No EOL
1.4 KiB
C++
Executable file

#include <iostream>
#include <vector>
#include "Attribute.h"
Attribute::Attribute(){
name = "";
type = "";
key = 0;
size = 0;
limit = 0;
}
Attribute::Attribute(string n, string t, bool k){
name = n;
type = t;
key = k;
size = 0;
limit = 20;
}
Attribute::Attribute(string n, string t, bool k, int s){
name = n;
type = t;
key = k;
size = 0;
limit = s;
}
void Attribute::addCell(string v){
values.push_back(v);
size++;
}
void Attribute::removeCell(int index){
values.erase(values.begin() + index);
size--;
}
string Attribute::operator[](int i){
return values[i];
}
vector<string> Attribute::getValues(){
return values;
}
string Attribute::getName(){
return name;
}
void Attribute::setName(string s){
name = s;
}
void Attribute::setValue(string s, int index) {
values[index] = s;
}
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";
vector<string>::iterator it = values.begin();
while (it != values.end()){
cout << *it << "\n";
it++;
}
cout << "-------------\n";
}
void Attribute::clearAllValues(){
values.clear();
size = 0;
}