Example #1
0
bool CrpcBase::rpcArray(CXmlNodePtr param, const char *name, CXmlNodePtr& node)
{
	CXmlNodePtr val = param->Clone();

	if(!strcmp(val->GetName(),"param"))
		val->GetChild();
	if(!strcmp(val->GetName(),"array"))
		return false;

	if(!node)
	{
		if(!val->GetChild())
			return false;
		if(!strcmp(val->GetName(),"data"))
			return false;
		node = val->Clone();
		return true;
	}
	else
	{
		if(!node->GetParent()) return false;
		if(!node->GetSibling()) return false;
		if(!strcmp(node->GetName(),"data"))
			return false;
		if(!node->GetChild()) return false;
		return true;
	}
}
Example #2
0
bool CrpcBase::rpcInt(CXmlNodePtr param, const char *name, int& value)
{
	cvs::string fnd;
	CXmlNodePtr val;

	val = param->Clone();
	if(!strcmp(val->GetName(),"param")) 
		val->GetChild();
	if(!strcmp(val->GetName(),"struct"))
	{
		if(name)
		{
			cvs::sprintf(fnd,64,"member[@name='%s']",name);
			if(!val->Lookup(fnd.c_str()))
				return false;
			if(!val->XPathResultNext())
				return false;
		}
		else
			val->GetChild();
		val->GetChild("value");
	}
	if(strcmp(val->GetName(),"value"))
		return false;
	if(!val->GetChild())
		return false;
	if(strcmp(val->GetName(),"i4"))
		return false;
	value = atoi(val->GetValue());
	return true;
}
Example #3
0
bool CrpcBase::rpcObj(CXmlNodePtr param, const char *name, rpcObject *rpcObj)
{
	cvs::string fnd;
	CXmlNodePtr val;

	val = param->Clone();
	if(!strcmp(val->GetName(),"param")) 
		val->GetChild();
	if(!strcmp(val->GetName(),"struct"))
	{
		if(name)
		{
			cvs::sprintf(fnd,64,"member[@name='%s']",name);
			if(!val->Lookup(fnd.c_str()))
				return false;
			if(!val->XPathResultNext())
				return false;
		}
		else
			val->GetChild();
		val->GetChild("value");
	}
	if(strcmp(val->GetName(),"value"))
		return false;
	if(!val->GetChild())
		return false;
	if(strcmp(val->GetName(),"struct"))
		return false;
	return rpcObj->Marshall(val);
}
Example #4
0
bool CrpcBase::addParam(CXmlNodePtr params, const char *name, rpcObject *obj)
{
	CXmlNodePtr param = params->Clone();

	if(!strcmp(param->GetName(),"params"))
		param->NewNode("param", NULL);
	else if(!strcmp(param->GetName(),"struct"))
	{
		param->NewNode("member", NULL);
		if(name)
			param->NewNode("name",name,false);
	}
	param->NewNode("value",NULL);

	return obj->Marshall(param);
}
Example #5
0
bool CrpcBase::addParam(CXmlNodePtr params, const char *name, const char *value)
{
	CXmlNodePtr param = params->Clone();

	if(!strcmp(param->GetName(),"params"))
		param->NewNode("param", NULL);
	else if(!strcmp(param->GetName(),"struct"))
	{
		param->NewNode("member", NULL);
		if(name)
			param->NewNode("name",name,false);
	}
	param->NewNode("value",NULL);
	param->NewNode("string",value);
	return true;
}
Example #6
0
bool CrpcBase::addParam(CXmlNodePtr params, const char *name, int value)
{
	char tmp[32];
	snprintf(tmp,sizeof(tmp),"%d",value);
	CXmlNodePtr param = params->Clone();

	if(!strcmp(param->GetName(),"params"))
		param->NewNode("param", NULL);
	else if(!strcmp(param->GetName(),"struct"))
	{
		param->NewNode("member", NULL);
		if(name)
			param->NewNode("name",name,false);
	}
	param->NewNode("value",NULL);
	param->NewNode("i4",tmp);
	return true;
}