Пример #1
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;
  }
Пример #2
0
    void XMLNodeList::setElementAtPosition(double index, const XMLNodeList & list)
    {
        if (list.getSize() && list.getRealNode() != parent)
        {
            int pos = (int)index;

            if (index < 1)
            {
                pos = 1;
            }
            else if (index > size)
            {
                pos = size++;
            }
            else if ((int)index != index)
            {
                pos++;
            }

            setElementAtPosition(index, XMLElement(doc, list.getRealNode()));
            for (xmlNode * cur = list.getRealNode()->next; cur; cur = cur->next)
            {
                setElementAtPosition((double)(pos++) + 0.5, XMLElement(doc, cur));
            }
        }
    }
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 XMLElement::append(const XMLElement & elem) const
{
    XMLNodeList * list = 0;
    xmlNode *cpy = xmlCopyNode(elem.getRealNode(), 1);
    xmlUnlinkNode(cpy);
    xmlAddChild(node, cpy);

    list = scope->getXMLNodeListFromLibXMLPtr(node->children);
    if (list)
    {
        list->incrementSize();
    }
}
Пример #5
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);
      }
   }
}
Пример #6
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;
 }
Пример #7
0
const XMLNodeList & XMLNode::children(const string &n) const {
	if(n.empty()) {
		if(nodelist.empty()) throw xmlerror(xml_childlist_empty);  
		return nodelist;
	}
   
	static XMLNodeList ret;
	ret.clear();
	XMLNodeListConstIterator it;
	
	for(it=nodelist.begin(); it!=nodelist.end(); it++) {	
		if((*it)->name()==n) ret.push_back(*it);
	}
	
	if(ret.empty()) throw xmlerror(xml_name_not_found, n);
   return ret;
}
Пример #8
0
void XMLElement::setChildren(const XMLNodeList & list) const
{
    xmlNode *n = list.getRealNode();
    if (n && n->parent != node)
    {
        xmlNode *cpy = xmlCopyNodeList(n);
        xmlUnlinkNode(node->children);
        xmlFreeNodeList(node->children);
        node->children = 0;
        xmlAddChildList(node, cpy);
    }
}
Пример #9
0
void XMLElement::remove() const
{
    XMLNodeList *obj = 0;

    if (node->parent && node->parent->children)
    {
        obj = scope->getXMLNodeListFromLibXMLPtr(node->parent->children);
        if (obj && node->parent->children == node)
        {
            // node->parent->children == node => we remove the first child so parent->children
            // needs to be correctly re-linked.
            obj->removeElementAtPosition(1);
            return;
        }
    }

    xmlUnlinkNode(node);
    xmlFreeNode(node);

    if (obj)
    {
        obj->revalidateSize();
    }
}
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;
}
/*--------------------------------------------------------------------------*/
int sci_percent_s_i_XMLList(char *fname, void* pvApiCtx)
{
    XMLNodeList *a;
    int lhsid;
    int row, col;
    double index;
    SciErr err;
    int *indexaddr = 0;
    int *rhsaddr = 0;
    int *lhsaddr = 0;
    int *retaddr = 0;
    char *retstr = 0;
    int iBegin = 2;
    int mrhs = 1;
    int mlhs = 1;

    CheckLhs(1, 1);
    CheckRhs(3, 3);

    err = getVarAddressFromPosition(pvApiCtx, 1, &indexaddr);
    if (err.iErr)
    {
        printError(&err, 0);
        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
        return 0;
    }

    if (!isDoubleType(pvApiCtx, indexaddr) || !checkVarDimension(pvApiCtx, indexaddr, 1, 1))
    {
        Scierror(999, gettext("%s: Wrong type for input argument #%d: A double expected.\n"), fname, 1);
        return 0;
    }

    getScalarDouble(pvApiCtx, indexaddr, &index);

    err = getVarAddressFromPosition(pvApiCtx, 2, &rhsaddr);
    if (err.iErr)
    {
        printError(&err, 0);
        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2);
        return 0;
    }

    err = getVarAddressFromPosition(pvApiCtx, 3, &lhsaddr);
    if (err.iErr)
    {
        printError(&err, 0);
        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 3);
        return 0;
    }

    lhsid = getXMLObjectId(lhsaddr, pvApiCtx);
    a = XMLObject::getFromId < XMLNodeList > (lhsid);
    if (!a)
    {
        Scierror(999, gettext("%s: XML object does not exist.\n"), fname);
        return 0;
    }

    err = getMatrixOfDouble(pvApiCtx, rhsaddr, &row, &col, 0);
    if (err.iErr)
    {
        printError(&err, 0);
        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2);
        return 0;
    }

    if (row == 0 && col == 0)
    {
        a->removeElementAtPosition((int)index);
        a->createOnStack(Rhs + 1, pvApiCtx);
        LhsVar(1) = Rhs + 1;
    }
    else if (isNamedVarExist(pvApiCtx, "%s_xmlFormat"))
    {
        callScilabFunction(pvApiCtx, "%s_xmlFormat", iBegin, mlhs, mrhs);
        //Call function directly in scilab 6 C++ api
        //Nbvars = std::max(Nbvars, Lhs + Rhs);
        //SciString(&iBegin, (char *)"%s_xmlFormat", &mlhs, &mrhs);
        //Nbvars = std::max(Nbvars, Lhs + Rhs + mlhs + mrhs);

        iBegin = nbInputArgument(pvApiCtx) + mrhs + 1;
        err = getVarAddressFromPosition(pvApiCtx, iBegin, &retaddr);
        if (err.iErr)
        {
            printError(&err, 0);
            Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, iBegin);
            return 0;
        }

        if (!isStringType(pvApiCtx, retaddr) || !checkVarDimension(pvApiCtx, retaddr, 1, 1))
        {
            Scierror(999, gettext("%s: xmlFormat must return a string.\n"), fname);
            return 0;
        }

        if (getAllocatedSingleString(pvApiCtx, retaddr, &retstr) != 0)
        {
            Scierror(999, _("%s: No more memory.\n"), fname);
            return 0;
        }
        if (retstr)
        {
            a->setElementAtPosition(index, std::string(retstr));
            freeAllocatedSingleString(retstr);
            a->createOnStack(Rhs + 1, pvApiCtx);
            LhsVar(1) = Rhs + 1;
        }
    }
    else
    {
        Scierror(999, gettext("%s: You must define %%s_xmlFormat function.\n"), fname);
        return 0;
    }

    PutLhsVar();

    return 0;
}
Пример #12
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;
   }
}