smrtlink/src/table.cpp

43 lines
879 B
C++
Raw Normal View History

2016-01-16 22:33:04 +00:00
/*
* lookupTable.h
*
* Created on: 11.10.2015
* Author: jdi
*/
#include <string>
#include "table.h"
2016-01-23 08:22:46 +00:00
2016-01-16 22:33:04 +00:00
table::table(std::initializer_list<set> l) {
2016-01-23 08:22:46 +00:00
int i = 0;
this->data.resize(l.size());
for (set s : l) {
this->data[i] = s;
this->left[s.type] = &this->data[i];
this->right[s.name] = &this->data[i];
i++;
}
}
const table::set table::operator[](std::string s){
return *this->right[s];
}
const table::set table::operator[](short n){
return *this->left[n];
2016-01-16 22:33:04 +00:00
}
2016-01-23 08:22:46 +00:00
bool table::exists(std::string s){
return !(right.find(s) == right.end());
2016-01-16 22:33:04 +00:00
}
2016-01-17 00:01:49 +00:00
bool table::exists(short n){
2016-01-23 08:22:46 +00:00
return !(left.find(n) == left.end());
}
short table::type(std::string s){
return this->right[s]->type;
}
std::string table::id(short n){
return this->left[n]->id;
2016-01-16 22:33:04 +00:00
}
2016-01-21 03:58:21 +00:00
std::string table::name(short n){
2016-01-23 08:22:46 +00:00
return this->left[n]->name;
2016-01-16 22:33:04 +00:00
}