diff options
Diffstat (limited to 'project2/sessionXml.cpp')
-rw-r--r-- | project2/sessionXml.cpp | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/project2/sessionXml.cpp b/project2/sessionXml.cpp index 3b42924..9e78aec 100644 --- a/project2/sessionXml.cpp +++ b/project2/sessionXml.cpp @@ -1,17 +1,16 @@ #include "sessionXml.h" +#include "uuid.h" #include <libxml++/nodes/element.h> #include <libxml++/parsers/domparser.h> #include <libxml++/nodes/textnode.h> #include <set> +#include <stdio.h> #include <boost/foreach.hpp> -#include <boost/uuid/uuid_generators.hpp> #include <boost/lexical_cast.hpp> -#include <boost/uuid/uuid_io.hpp> -using namespace boost::uuids; class SessionXml : public Session { public: - SessionXml(boost::uuids::uuid & sid); + SessionXml(UUID & sid); SessionXml(const xmlpp::Element *); virtual ~SessionXml(); @@ -22,7 +21,7 @@ class SessionXml : public Session { time_t ExpiryTime() const; void ExpiryTime(time_t); - const uuid sessionID; + const UUID sessionID; private: Values vars; @@ -56,7 +55,7 @@ SessionContainerXml::CleanUp() doc = parser.get_document(); char xpath[200]; snprintf(xpath, 200, "/sessions/session[@id='%s' or @expires < %lu]", - boost::lexical_cast<std::string>(currentSession->sessionID).c_str(), time(NULL)); + currentSession->sessionID.str().c_str(), time(NULL)); xmlpp::NodeSet sess = doc->get_root_node()->find(xpath); BOOST_FOREACH(xmlpp::Node * n, sess) { n->get_parent()->remove_child(n); @@ -67,7 +66,7 @@ SessionContainerXml::CleanUp() doc->create_root_node("sessions"); } xmlpp::Element * sess = doc->get_root_node()->add_child("session"); - sess->set_attribute("id", boost::lexical_cast<Glib::ustring>(currentSession->sessionID)); + sess->set_attribute("id", currentSession->sessionID.str()); sess->set_attribute("expires", boost::lexical_cast<Glib::ustring>(currentSession->expires)); BOOST_FOREACH(const SessionXml::Values::value_type & nvp, currentSession->vars) { xmlpp::Element * v = sess->add_child("var"); @@ -83,14 +82,14 @@ SessionContainerXml::CleanUp() } SessionPtr -SessionContainerXml::getSession(boost::uuids::uuid & sid) +SessionContainerXml::getSession(UUID & sid) { if (!currentSession || currentSession->sessionID != sid) { try { xmlpp::DomParser sessions(xmlFile); char xpath[200]; snprintf(xpath, 200, "/sessions/session[@id='%s' and @expires > %lu]", - boost::lexical_cast<std::string>(sid).c_str(), time(NULL)); + sid.str().c_str(), time(NULL)); xmlpp::NodeSet sess = sessions.get_document()->get_root_node()->find(xpath); if (sess.size() == 1) { currentSession = new SessionXml(dynamic_cast<const xmlpp::Element *>(sess[0])); @@ -106,13 +105,13 @@ SessionContainerXml::getSession(boost::uuids::uuid & sid) return currentSession; } -SessionXml::SessionXml(boost::uuids::uuid & sid) : - sessionID(sid.is_nil() ? sid = boost::uuids::random_generator()() : sid) +SessionXml::SessionXml(UUID & sid) : + sessionID(sid.is_nil() ? sid = UUID::generate_random() : sid) { } SessionXml::SessionXml(const xmlpp::Element * p) : - sessionID(boost::lexical_cast<uuid>(p->get_attribute_value("id"))), + sessionID(p->get_attribute_value("id")), expires(boost::lexical_cast<time_t>(p->get_attribute_value("expires"))) { xmlpp::NodeSet xvars = p->find("var"); |