GitLab maintenance scheduled for Today, 2019-12-05, from 17:00 to 18:00 CT - Services will be unavailable during this time.

Commit ec1a1d40 authored by Matthieu Dorier's avatar Matthieu Dorier

added operator[]

parent b23286ea
......@@ -24,6 +24,8 @@ class DataStore {
~DataStore();
DataSet operator[](const std::string& datasetName) const;
class iterator;
class const_iterator;
......
......@@ -271,6 +271,11 @@ DataStore::iterator DataStore::find(const std::string& datasetName) {
return iterator(*this, DataSet(*this, 1, datasetName));
}
DataSet DataStore::operator[](const std::string& datasetName) const {
auto it = find(datasetName);
return std::move(*it);
}
DataStore::const_iterator DataStore::find(const std::string& datasetName) const {
DataStore::iterator it = const_cast<DataStore*>(this)->find(datasetName);
return it;
......
......@@ -58,5 +58,7 @@ int main(int argc, char** argv) {
dataset4.load(key, value);
std::cout << "load(\"matthieu\") = " << value << std::endl;
}
std::cout << "====== Testing operator[] =========" << std::endl;
std::cout << "datastore[\"myproject\"].fullname() = " << datastore["myproject"].fullname() << std::endl;
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment