diff options
Diffstat (limited to 'project2/json')
-rw-r--r-- | project2/json/Jamfile.jam | 2 | ||||
-rw-r--r-- | project2/json/couchSession.cpp | 17 |
2 files changed, 10 insertions, 9 deletions
diff --git a/project2/json/Jamfile.jam b/project2/json/Jamfile.jam index 88bf92e..e9ae7b5 100644 --- a/project2/json/Jamfile.jam +++ b/project2/json/Jamfile.jam @@ -17,12 +17,10 @@ lib p2json : <library>glibmm <library>../common//p2common <library>../lib//p2lib - <library>../uuid//p2uuid <library>../url//p2url <library>boost_filesystem <library>boost_date_time : : - <library>../uuid//p2uuid <include>. ; diff --git a/project2/json/couchSession.cpp b/project2/json/couchSession.cpp index 2fe2ae6..ab7a7be 100644 --- a/project2/json/couchSession.cpp +++ b/project2/json/couchSession.cpp @@ -8,6 +8,9 @@ #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> #include "json.h" #include "safeMapFind.h" #include "conversion.h" @@ -19,7 +22,7 @@ class CouchSessionContainer : public SessionContainer { public: CouchSessionContainer() { } - virtual SessionPtr getSession(const UUID & uuid) const { + virtual SessionPtr getSession(const boost::uuids::uuid & uuid) const { try { json::Object obj = getSessionFromServer(uuid); if (boost::get<json::Number>(*safeMapLookup<Session::VariableNotFound>(obj, ExpiryKey)) > time(NULL)) { @@ -46,7 +49,7 @@ class CouchSessionContainer : public SessionContainer { c->setopt(CURLOPT_INFILESIZE_LARGE, (curl_off_t)out.size()); unsigned int off = 0; BOOST_FOREACH(const std::string & b, baseUrls) { - c->setopt(CURLOPT_URL, (b + s->ID().str()).c_str()); + c->setopt(CURLOPT_URL, (b + boost::lexical_cast<std::string>(s->ID())).c_str()); try { c->performSend(boost::bind(send, &out, &off, _1, _2)); return; @@ -57,13 +60,13 @@ class CouchSessionContainer : public SessionContainer { throw CouchDBFailure(); } - json::Object getSessionFromServer(const UUID & uuid) const { + json::Object getSessionFromServer(const boost::uuids::uuid & uuid) const { CurlPtr c = new Curl(); c->setopt(CURLOPT_FAILONERROR, 1); Glib::ustring msg; BOOST_FOREACH(const std::string & b, baseUrls) { try { - c->setopt(CURLOPT_URL, (b + uuid.str()).c_str()); + c->setopt(CURLOPT_URL, (b + boost::lexical_cast<std::string>(uuid)).c_str()); c->performRead(boost::bind(append, &msg, _1, _2)); json::Object o = json::parseObject(msg); return o; @@ -165,7 +168,7 @@ class CustomCouchSessionLoader : public SessionContainerLoader::For<CouchSession json::Object o = json::parseObject(msg); BOOST_FOREACH(const json::Array::value_type & v, boost::get<json::Array>(*safeMapLookup<ParamNotFound>(o, "rows"))) { json::Object rec = boost::get<json::Object>(*v); - UUID u = boost::get<json::String>(*safeMapLookup<ParamNotFound>(rec, "id")).raw(); + 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")); deleteSession(u, rev); } @@ -176,11 +179,11 @@ class CustomCouchSessionLoader : public SessionContainerLoader::For<CouchSession } } - void deleteSession(const UUID & sid, const Glib::ustring & rev) const { + 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) { - c->setopt(CURLOPT_URL, (b + sid.str() + "?rev=" + rev).c_str()); + c->setopt(CURLOPT_URL, (b + boost::lexical_cast<std::string>(sid) + "?rev=" + rev).c_str()); c->performRead(boost::bind(discard, _2)); return; } |