示例#1
0
文件: rpcBase.cpp 项目: acml/cvsnt
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;
}
示例#2
0
文件: XmlTree.cpp 项目: acml/cvsnt
bool CXmlTree::CreateCache(unsigned cacheId, const char *path, const char *attribute /*= NULL*/, CacheFlags flags /*= cacheDefault*/)
{
	CXmlNodePtr node = GetRoot();
	if(!node->Lookup(path))
	{
		CServerIo::trace(3,"CreateCache node lookup failed");
		return false;
	}

	cache_t& cache = m_Cache[cacheId];
	cache.flags = flags;
	if(flags&cacheFilename)
	{
		if(cache.filenameMap) delete cache.filenameMap;
		cache.filenameMap = new std::map<cvs::filename, xmlNodePtr>;
	}
	else if(flags&cacheUsername)
	{
		if(cache.usernameMap) delete cache.usernameMap;
		cache.usernameMap = new std::map<cvs::username, xmlNodePtr>;
	}
	else
	{
		if(cache.standardMap) delete cache.standardMap;
		cache.standardMap = new std::map<cvs::string, xmlNodePtr>;
	}
	while(node->XPathResultNext())
	{
		const char *value;
		if(attribute)
		{
			if(attribute[0]=='@')
				value = node->GetAttrValue(attribute+1);
			else
				value = node->GetNodeValue(attribute);
		}
		else
			value = node->GetValue();
		if(value)
		{
			if(flags&cacheFilename)
				(*cache.filenameMap)[value]=node->Object();
			else if(flags&cacheUsername)
				(*cache.usernameMap)[value]=node->Object();
			else
				(*cache.standardMap)[value]=node->Object();
		}
	}	
	return true;
}