aboutsummaryrefslogtreecommitdiff
path: root/enginedata.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'enginedata.cpp')
-rw-r--r--enginedata.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/enginedata.cpp b/enginedata.cpp
index 43a50ce..ecb4c82 100644
--- a/enginedata.cpp
+++ b/enginedata.cpp
@@ -1,5 +1,7 @@
#include "enginedata.h"
+#include "util.h"
#include <iostream>
+#include <list>
#include <cassert>
using namespace std;
@@ -41,24 +43,26 @@ Table::Table(Table &&other):name(move(other.name)),nc(other.nc),header(other.hea
other.header=nullptr;
}
-void Table::insert(Row &&row){
+bool Table::insert(Row &&row){
string key=serialise(this->header[0],row.items[0]);
- cerr<<"Inserting into table '"<<this->name<<"' key="<<key<<" row="<<row<<endl;
- rows.emplace(key,move(row));
+ cerr<<debug<<"Inserting into table '"<<this->name<<"' key="<<key<<" row="<<row<<endl;
+ return rows.emplace(key,move(row)).second;
}
-void Table::insert(Row &row){
+bool Table::insert(Row &row){
string key=serialise(this->header[0],row.items[0]);
- cerr<<"Inserting into table '"<<this->name<<"' key="<<key<<" row="<<row<<endl;
- rows.emplace(key,row);
+ cerr<<debug<<"Inserting into table '"<<this->name<<"' key="<<key<<" row="<<row<<endl;
+ return rows.emplace(key,row).second;
}
-Maybe<Row> Table::find(const string &key){
+list<Row> Table::find(const string &key){
typedef map<string,Row>::const_iterator cit_t;
cit_t end=rows.cend();
+ list<Row> ret;
for(cit_t it=rows.cbegin();it!=end;it++){
- if(serialise(it->second.table->header[0],it->second.items[0])==key)return Maybe<Row>(it->second);
+ if(serialise(it->second.table->header[0],it->second.items[0])==key)
+ ret.emplace_back(it->second);
}
- return Maybe<Row>();
+ return ret;
}