Пример #1
0
 XMLNodeList XMLNode::Path(const std::string& path) {
   XMLNodeList res;
   std::string::size_type name_s = 0;
   std::string::size_type name_e = path.find('/', name_s);
   if (name_e == std::string::npos)
     name_e = path.length();
   res.push_back(*this);
   for (;;) {
     if (res.size() <= 0)
       return res;
     XMLNodeList::iterator node = res.begin();
     std::string node_name = path.substr(name_s, name_e - name_s);
     int nodes_num = res.size();
     for (int n = 0; n < nodes_num; ++n) {
       for (int cn = 0;; ++cn) {
         XMLNode cnode = (*node).Child(cn);
         if (!cnode)
           break;
         if (MatchXMLName(cnode, node_name))
           res.push_back(cnode);
       }
       ++node;
     }
     res.erase(res.begin(), node);
     if (name_e >= path.length())
       break;
     name_s = name_e + 1;
     name_e = path.find('/', name_s);
     if (name_e == std::string::npos)
       name_e = path.length();
   }
   return res;
 }
Пример #2
0
  bool UNICOREClient::listTargetSystemFactories(std::list< std::pair<URL, ServiceType> >& tsf) {

    logger.msg(INFO, "Creating and sending an index service query");
    PayloadSOAP req(unicore_ns);
    XMLNode query = req.NewChild("rp:QueryResourceProperties");
    XMLNode exp = query.NewChild("rp:QueryExpression");
    exp.NewAttribute("Dialect") = "http://www.w3.org/TR/1999/REC-xpath-19991116";
    exp = "//*";
    PayloadSOAP *resp = NULL;
    client->process("http://docs.oasis-open.org/wsrf/rpw-2"
                    "/QueryResourceProperties/QueryResourcePropertiesRequest",
                    &req, &resp);
    if (resp == NULL) {
      logger.msg(VERBOSE, "There was no SOAP response");
      return false;
    }

    XMLNodeList memberServices = resp->Body().Path("QueryResourcePropertiesResponse/Entry/MemberServiceEPR");
    for (XMLNodeList::iterator it = memberServices.begin(); it != memberServices.end(); it++) {
      if (((std::string)(*it)["Metadata"]["InterfaceName"]).find("BESFactoryPortType") != std::string::npos) { // it.Metadata.InterfaceName should contain 'BESFactoryPortType'...
        tsf.push_back(std::pair<URL, ServiceType>(URL((std::string)(*it)["Address"]), COMPUTING));
      }
    }

    return true;
  }
int
KeyboardTarget::set_binding_state (const XMLNode& node)
{
	XMLNodeList nlist = node.children();
	XMLNodeConstIterator niter;
	XMLNode *child_node;

	bindings.clear ();
	keymap.clear ();

	for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
		child_node = *niter;

		if (child_node->name() == "context") {
			XMLProperty *prop;
			
			if ((prop = child_node->property ("name")) != 0) {
				if (prop->value() == _name) {
					return load_bindings (*child_node);
				}
			}
		}
	}

	return 0;
}
Пример #4
0
void loadGroup(XMLNodePtr node)
{
   XMLNodeList children = node->getChildren();
   for (XMLNodeList::iterator itr = children.begin();
        itr != children.end();
        ++itr)
   {
      XMLNodePtr node = *itr;
      if (node->getName() == "static" || node->getName() == "turret" || node->getName() == "security_droid" || node->getName() == "navNode" )
      {
         loadStatic(node);
      }
   }
}
int
KeyboardTarget::load_bindings (const XMLNode& node)
{
	XMLNodeList nlist = node.children();
	XMLNodeConstIterator niter;

	for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
		XMLProperty *keys;
		XMLProperty *action;
		
		keys = (*niter)->property ("keys");
		action = (*niter)->property ("action");

		if (!keys || !action) {
			cerr << "misformed binding node - ignored" << endl;
			continue;
		}

		add_binding (keys->value(), action->value());
			
	}

	return 0;
}
Пример #6
0
void loadLevel(const std::string& file)
{
   // Clear the existing level
   modelsInWorld.clear();

   // Read in the level file
   XMLContextPtr context(new XMLContext());
   XMLDocument doc(context);
   std::ifstream in(file.c_str());
   if (!in)
   {
      std::cerr << "bad file: " << file << std::endl;
      return;
   }

   try
   {
      doc.load(in, context);
      XMLNodePtr level_node = doc.getChild("game")->getChild("level");
      XMLNodeList groups = level_node->getChildren("group");
      for (XMLNodeList::iterator itr = groups.begin();
           itr != groups.end();
           ++itr)
      {
         loadGroup(*itr);
      }
   }
   catch (XMLError& e)
   {
      XMLLocation where( context->getLocation() );
      std::string errmsg;
      e.getStrError(errmsg);
      // print out where the error occured
      std::cout << file << ":" << std::cout << file << ":" << where.getLine() << " ";
      std::cout << "at position " << where.getPos();
      std::cout << ": error: " << errmsg.c_str();
      std::cout << std::endl;

      // print out line where the error occured
      std::ifstream errfile( file.c_str() );
      if(!errfile)
      {
         std::cerr << "Can't open file [" << file << "] to output error" << std::endl;
      }

      int linenr = where.getLine();
      char linebuffer[1024];
      for(int i=0; i<linenr && !errfile.eof(); i++)
         errfile.getline( linebuffer,1024 );

      int pos = where.getPos();
      if (pos>=80)
         pos %= 80;

      std::string err_line( linebuffer + (where.getPos()-pos) );
      if (err_line.length()>=79)
         err_line.erase(79);
      std::cout << err_line << std::flush;
      std::cout << err_line.c_str() << std::endl;
      std::cout << linebuffer << std::endl;
      for(int j=2;j<pos;j++)
         std::cout << " ";
      std::cout << '^' << std::endl;
   }
}