diff options
Diffstat (limited to 'project2/json')
-rw-r--r-- | project2/json/couchSession.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/project2/json/couchSession.cpp b/project2/json/couchSession.cpp index 60acefa..51d466c 100644 --- a/project2/json/couchSession.cpp +++ b/project2/json/couchSession.cpp @@ -8,7 +8,6 @@ #include <scriptLoader.h> #include <sessionContainer.h> #include <boost/bind.hpp> -#include <boost/foreach.hpp> #include <boost/lexical_cast.hpp> #include <boost/uuid/uuid_io.hpp> #include <boost/uuid/uuid_generators.hpp> @@ -28,7 +27,7 @@ class CouchSessionContainer : public SessionContainer { json::Object obj = getSessionFromServer(uuid); if (boost::get<json::Number>(*safeMapLookup<Session::VariableNotFound>(obj, ExpiryKey)) > time(NULL)) { SessionPtr s = new Session(uuid); - BOOST_FOREACH(const json::Object::value_type & v, obj) { + for (const json::Object::value_type & v : obj) { s->SetValue(v.first, boost::apply_visitor(JsonToProject2(), *v.second)); } return s; @@ -49,7 +48,7 @@ class CouchSessionContainer : public SessionContainer { Glib::ustring out = json::serializeObject(obj, "utf-8"); c->setopt(CURLOPT_INFILESIZE_LARGE, (curl_off_t)out.size()); unsigned int off = 0; - BOOST_FOREACH(const std::string & b, baseUrls) { + for (const std::string & b : baseUrls) { c->setopt(CURLOPT_URL, (b + boost::lexical_cast<std::string>(s->ID())).c_str()); try { c->performSend(boost::bind(send, &out, &off, _1, _2)); @@ -65,7 +64,7 @@ class CouchSessionContainer : public SessionContainer { CurlPtr c = new Curl(); c->setopt(CURLOPT_FAILONERROR, 1); Glib::ustring msg; - BOOST_FOREACH(const std::string & b, baseUrls) { + for (const std::string & b : baseUrls) { try { c->setopt(CURLOPT_URL, (b + boost::lexical_cast<std::string>(uuid)).c_str()); c->performRead(boost::bind(append, &msg, _1, _2)); @@ -131,7 +130,7 @@ class CustomCouchSessionLoader : public SessionContainerLoader::For<CouchSession CurlPtr c = new Curl(); c->setopt(CURLOPT_POST, 1); c->appendHeader("Content-Type: application/json"); - BOOST_FOREACH(const std::string & b, CouchSessionContainer::baseUrls) { + for (const std::string & b : CouchSessionContainer::baseUrls) { c->setopt(CURLOPT_URL, (b + "_compact").c_str()); c->performRead(boost::bind(discard, _2)); } @@ -151,13 +150,13 @@ class CustomCouchSessionLoader : public SessionContainerLoader::For<CouchSession c->setopt(CURLOPT_POST, 1); c->setopt(CURLOPT_POSTFIELDS, mapStr.c_str()); c->setopt(CURLOPT_POSTFIELDSIZE, mapStr.bytes()); - BOOST_FOREACH(const std::string & b, CouchSessionContainer::baseUrls) { + for (const std::string & b : CouchSessionContainer::baseUrls) { Glib::ustring msg; try { c->setopt(CURLOPT_URL, (b + "_temp_view").c_str()); c->performRead(boost::bind(CouchSessionContainer::append, &msg, _1, _2)); json::Object o = json::parseObject(msg); - BOOST_FOREACH(const json::Array::value_type & v, boost::get<json::Array>(*safeMapLookup<ParamNotFound>(o, "rows"))) { + for (const json::Array::value_type & v : boost::get<json::Array>(*safeMapLookup<ParamNotFound>(o, "rows"))) { json::Object rec = boost::get<json::Object>(*v); boost::uuids::uuid u = boost::uuids::string_generator()(boost::get<json::String>(*safeMapLookup<ParamNotFound>(rec, "id")).raw()); Glib::ustring & rev = boost::get<json::String>(*safeMapLookup<ParamNotFound>(rec, "value")); @@ -173,7 +172,7 @@ class CustomCouchSessionLoader : public SessionContainerLoader::For<CouchSession void deleteSession(const boost::uuids::uuid & sid, const Glib::ustring & rev) const { CurlPtr c = new Curl(); c->setopt(CURLOPT_CUSTOMREQUEST, "DELETE"); - BOOST_FOREACH(const std::string & b, CouchSessionContainer::baseUrls) { + for (const std::string & b : CouchSessionContainer::baseUrls) { c->setopt(CURLOPT_URL, (b + boost::lexical_cast<std::string>(sid) + "?rev=" + rev).c_str()); c->performRead(boost::bind(discard, _2)); return; |