PeerToFinderPeerLocationFindRequestPtr PeerToFinderPeerLocationFindRequest::create(ElementPtr root)
        {
          PeerToFinderPeerLocationFindRequestPtr ret(new message::PeerToFinderPeerLocationFindRequest);

          if (root)
          {
            ret->mID = IMessageHelper::getAttributeID(root);

            ElementPtr routes = root->findFirstChildElement("routes");
            if (routes)
            {
              RouteList routeLst;
              ElementPtr route = routes->findFirstChildElement("route");
              while (route)
              {
                String id = IMessageHelper::getAttributeID(route);
                routeLst.push_back(id);

                route = route->getNextSiblingElement();
              }

              if (routeLst.size() > 0)
                ret->mRoutes = routeLst;
            }

            ElementPtr exclude = root->findFirstChildElement("exclude");
            if (exclude)
            {
              ElementPtr locations = root->findFirstChildElement("locations");
              if (locations)
              {
                message::PeerToFinderPeerLocationFindRequest::ExcludedLocationList exclLst;
                ElementPtr loc = locations->findFirstChildElement("location");
                while (loc)
                {
                  String id = IMessageHelper::getAttributeID(loc);
                  exclLst.push_back(id);

                  loc = loc->getNextSiblingElement();
                }

                if (exclLst.size() > 0)
                  ret->mExcludedLocations = exclLst;
              }
            }

            ElementPtr location = root->findFirstChildElement("location");
            if (location)
            {
              ret->mLocation = MessageHelper::createLocation(location);
            }

          }

          return ret;
        }
        //---------------------------------------------------------------------
        SessionDeleteResultPtr SessionDeleteResult::create(
                                                           ElementPtr root,
                                                           IMessageSourcePtr messageSource
                                                           )
        {
          SessionDeleteResultPtr ret(new SessionDeleteResult);
          IMessageHelper::fill(*ret, root, messageSource);

          ElementPtr locations = root->findFirstChildElement("locations");
          if(locations)
          {
            StringList ll;
            ElementPtr loc = locations->findFirstChildElement("location");
            while (loc)
            {
              ll.push_back(IMessageHelper::getAttributeID(loc));

              loc = loc->getNextSiblingElement();
            }

            if (ll.size() > 0)
              ret->mLocations = ll;
          }

          return ret;
        }
        PeerToFinderPeerLocationFindResultPtr PeerToFinderPeerLocationFindResult::create(ElementPtr root)
        {
          PeerToFinderPeerLocationFindResultPtr ret(new message::PeerToFinderPeerLocationFindResult);

          ret->mID = IMessageHelper::getAttributeID(root);
          ret->mTime = IMessageHelper::getAttributeEpoch(root);

          ElementPtr locs = root->findFirstChildElement("locations");
          if (locs)
          {
            LocationList ll;
            ElementPtr loc = locs->findFirstChildElement("location");
            while (loc)
            {
              Location l = MessageHelper::createLocation(loc->findFirstChildElement("details"));
              l.mID = IMessageHelper::getAttributeID(loc);
              ll.push_back(l);

              loc = loc->getNextSiblingElement();
            }

            if (ll.size() > 0)
              ret->mLocations = ll;
          }

          return ret;
        }
        PeerToFinderSessionDeleteResultPtr PeerToFinderSessionDeleteResult::create(ElementPtr root)
        {
          PeerToFinderSessionDeleteResultPtr ret(new message::PeerToFinderSessionDeleteResult);

          ret->mID = IMessageHelper::getAttributeID(root);
          ret->mTime = IMessageHelper::getAttributeEpoch(root);

          ElementPtr locations = root->findFirstChildElement("locations");
          if(locations)
          {
            StringList ll;
            ElementPtr loc = locations->findFirstChildElement("location");
            while (loc)
            {
              ll.push_back(IMessageHelper::getAttributeID(loc));

              loc = loc->getNextSiblingElement();
            }

            if (ll.size() > 0)
              ret->mLocations = ll;
          }

          return ret;
        }
示例#5
0
 ElementPtr Node::findFirstChildElement(String elementName) const
 {
   bool caseSensative = true;
   DocumentPtr document = getDocument();
   if (document)
     caseSensative = document->isElementNameIsCaseSensative();
   
   ElementPtr element = getFirstChildElement();
   while (element)
   {
     if (caseSensative)
     {
       if (elementName == element->getValue())
         return element;
     }
     else
     {
       if (0 == elementName.compareNoCase(element->getValue()))
         return element;
     }
     element = element->getNextSiblingElement();
   }
   return ElementPtr();
 }