当前位置: 首页>>代码示例>>C++>>正文


C++ XMLAttribute::getValue方法代码示例

本文整理汇总了C++中XMLAttribute::getValue方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLAttribute::getValue方法的具体用法?C++ XMLAttribute::getValue怎么用?C++ XMLAttribute::getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XMLAttribute的用法示例。


在下文中一共展示了XMLAttribute::getValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: hexparser

/** helper function to return the real value of the string (HEX or normal) */
static std::string getRealValue(XMLElement* e)
{
	std::string str = e->getFirstText();
	XMLAttribute* a = e->getAttribute("type");

	if (a && a->getValue() == "HEX")
		return StringFilter::hexparser(str);

	return str;
}
开发者ID:BackupTheBerlios,项目名称:vermont-svn,代码行数:11,代码来源:PacketFilterCfg.cpp

示例2: getTimeInUnit

unsigned int CfgBase::getTimeInUnit(const std::string& name, timeUnit unit, uint32_t def, XMLElement* elem)
{
	unsigned int time;
	if (!elem)
		elem = _elem;

	XMLNode::XMLSet<XMLElement*> set = elem->getElementChildren();
	XMLNode::XMLSet<XMLElement*>::const_iterator it = set.begin();
	for (; it != set.end(); it++) {
		XMLElement* e = *it;

		try {
			if (e->getName() != name)
				continue;
		} catch (IllegalEntry ie) {

		}

		time = atoi(e->getFirstText().c_str());

		XMLAttribute* a = e->getAttribute("unit");
		if (!a)
			continue;

		if (a->getValue() == "sec")
			return time*unit/SEC;
		else if (a->getValue() == "msec")
			return time*unit/mSEC;
		else if (a->getValue() == "usec")
			return time*unit/uSEC;
		else
			THROWEXCEPTION("Unkown time unit '%s'", a->getValue().c_str());
	}

	// we didn't find the element, return default
	return def;
}
开发者ID:BackupTheBerlios,项目名称:vermont-svn,代码行数:37,代码来源:Cfg.cpp

示例3: String

String
XMLNodeImpl::getAttribute(const String& name, bool throwException) const
{
	int arraySize = m_XMLAttributeArray.size();

	for (int i = 0; i < arraySize; i++)
	{
		XMLAttribute attr = m_XMLAttributeArray[i];

		// Should this be case insensentive? NO
		if (attr.getName().equals(name))
		{
			return attr.getValue();
		}
	}
	if (throwException)
	{
		OW_THROWCIMMSG(CIMException::INVALID_PARAMETER,
				Format("Failed to find "
					"attribute: %1 in node: %2", name, m_strName).c_str() );
	}

	return String();
}
开发者ID:kkaempf,项目名称:openwbem,代码行数:24,代码来源:OW_XMLNode.cpp

示例4: getID

unsigned int Cfg::getID()
{
	XMLAttribute* attr = _elem->getAttribute("id");
	assert(attr != NULL);
	return atoi(attr->getValue().c_str());
}
开发者ID:BackupTheBerlios,项目名称:vermont-svn,代码行数:6,代码来源:Cfg.cpp

示例5: parseNode

void SceneGraphResource::parseNode( XMLNode &xmlNode, SceneNodeTpl *parentTpl )
{
	SceneNodeTpl *nodeTpl = 0x0;

	if( xmlNode.getName() != 0x0 )	// Ignore clear tags like DOCTYPE
	{
		if( strcmp( xmlNode.getName(), "Reference" ) == 0 )
		{
			if( strcmp( xmlNode.getAttribute( "sceneGraph", "" ), "" ) != 0 )
			{
				Resource *res = Modules::resMan().resolveResHandle( Modules::resMan().addResource(
					ResourceTypes::SceneGraph, xmlNode.getAttribute( "sceneGraph" ), 0, false ) );
				if (res != 0x0 ) nodeTpl = new ReferenceNodeTpl( "", (SceneGraphResource *)res );
			}
		}
		else
		{
			NodeRegEntry *entry = Modules::sceneMan().findType( xmlNode.getName() );
			if( entry != 0x0 )
			{
				map< string, string > attribs;
				
				// Parse custom attributes
				XMLAttribute attrib = xmlNode.getFirstAttrib();
				while( !attrib.isEmpty() )
				{
					if( strcmp( attrib.getName(), "name" ) != 0 &&
						strcmp( attrib.getName(), "tx" ) != 0 &&
						strcmp( attrib.getName(), "ty" ) != 0 &&
						strcmp( attrib.getName(), "tz" ) != 0 &&
						strcmp( attrib.getName(), "rx" ) != 0 &&
						strcmp( attrib.getName(), "ry" ) != 0 &&
						strcmp( attrib.getName(), "rz" ) != 0 &&
						strcmp( attrib.getName(), "sx" ) != 0 &&
						strcmp( attrib.getName(), "sy" ) != 0 &&
						strcmp( attrib.getName(), "sz" ) != 0 )
					{
						attribs[attrib.getName()] = attrib.getValue();
					}
					attrib = attrib.getNextAttrib();
				}

				// Call function pointer
				nodeTpl = (*entry->parsingFunc)( attribs );
			}
		}
		
		if( nodeTpl != 0x0 )
		{
			// Parse base attributes
			parseBaseAttributes( xmlNode, *nodeTpl );
			
			// Add to parent
			if( parentTpl != 0x0 )
			{
				parentTpl->children.push_back( nodeTpl );
			}
			else
			{	
				delete _rootNode;	// Delete default root
				_rootNode = nodeTpl;
			}
		}
		else if( strcmp( xmlNode.getName(), "Attachment" ) != 0 )
		{
			Modules::log().writeWarning( "SceneGraph resource '%s': Unknown node type or missing attribute for '%s'",
										 _name.c_str(), xmlNode.getName() );
			return;
		}
	}
	
	// Parse children
	XMLNode xmlNode1 = xmlNode.getFirstChild();
	while( !xmlNode1.isEmpty() )
	{	
		if( xmlNode1.getName() == 0x0 || strcmp( xmlNode1.getName(), "Attachment" ) != 0 )			
			parseNode( xmlNode1, nodeTpl );

		xmlNode1 = xmlNode1.getNextSibling();
	}
}
开发者ID:okard,项目名称:td,代码行数:81,代码来源:egSceneGraphRes.cpp

示例6: getInt

IDSLoadbalancerCfg::IDSLoadbalancerCfg(XMLElement* elem)
	: CfgHelper<IDSLoadbalancer, IDSLoadbalancerCfg>(elem, "IDSLoadbalancer"),
	selector(NULL),
	updateInterval(0)
{
	if (!elem) return;

	XMLNode::XMLSet<XMLElement*> set = elem->getElementChildren();
	for (XMLNode::XMLSet<XMLElement*>::iterator it = set.begin(); it != set.end(); it++) {
		XMLElement* e = *it;

		if (e->matches("updateinterval")) {
			updateInterval = getInt("updateinterval", 0, e);
		} else if (e->matches("PacketSelector")) {
			XMLAttribute *a = e->getAttribute("type");
			if (!a)
				THROWEXCEPTION("no PacketSelector specified");
			string _selector = a->getValue();

			if (_selector == "HashPacketSelector") {
				if (!selector) {
					selector = new HashPacketSelector();
				} else
					THROWEXCEPTION("IDSLoadBalancerCfg: multiple packet selectors specified! This is not allowed.");
			} else if (_selector == "IpPacketSelector") {
				msg(MSG_DEBUG, "IpPacketSelector");
				XMLNode::XMLSet<XMLElement*> set = e->getElementChildren();
				for (XMLNode::XMLSet<XMLElement*>::iterator it = set.begin(); it != set.end(); it++) {
					XMLElement* e = *it;
					if (e->matches("DestinationIp")){
						XMLAttribute *a = e->getAttribute("queueno");
						if (!a)
							THROWEXCEPTION("No queue number specified");
						int queueno = 0;
						std::string tmp = a->getValue();
						try {
							queueno = boost::lexical_cast<int>(tmp);
						}catch (boost::bad_lexical_cast &){
							THROWEXCEPTION("bad value for queue number: %s", tmp.c_str());
						}
						std::string ip = e->getFirstText();
						dst[parseIp(ip)] = queueno;
					}else if (e->matches("SourceIp")){
						XMLElement* e = *it;
						XMLAttribute *a = e->getAttribute("queueno");
						if (!a)
							THROWEXCEPTION("No queue number specified");
						int queueno = 0;
						std::string tmp = a->getValue();
						try {
							queueno = boost::lexical_cast<int>(tmp);
						}catch (boost::bad_lexical_cast &){
							THROWEXCEPTION("bad value for queue number: %s", tmp.c_str());
						}
						std::string ip = e->getFirstText();
						src[parseIp(ip)] = queueno;
					}
				}
				if (!selector) {
					selector = new IpPacketSelector();
					if (src.empty() && dst.empty())
						THROWEXCEPTION("IDSLoadBalancerCfg: packet selector IpPacketSelector was defined, but no source or destination IPs!");
				} else
					THROWEXCEPTION("IDSLoadBalancerCfg: multiple packet selectors specified! This is not allowed.");

			} else if (_selector == "PriorityPacketSelector") {
				float startprio = getDouble("startPriority", 1.0, e);
				uint32_t minmontime = getInt("minimumMonitoringTime", 10000, e);
				uint32_t maxspeed = getInt("maxSpeed", 0, e);
				list<PriorityNetConfig> config;
				list<WeightModifierConfig> weightmods;
				XMLNode::XMLSet<XMLElement*> set = e->getElementChildren();
				for (XMLNode::XMLSet<XMLElement*>::iterator it = set.begin(); it != set.end(); it++) {
					XMLElement* e = *it;
					if (e->matches("networks")) {
						XMLNode::XMLSet<XMLElement*> netset = e->getElementChildren();
						for (XMLNode::XMLSet<XMLElement*>::iterator nit = netset.begin(); nit != netset.end(); nit++) {
							XMLElement* e = *nit;
							if (e->matches("network")) {
								XMLAttribute* a = e->getAttribute("address");
								if (!a) THROWEXCEPTION("IDSLoadBalancerCfg: no attribute 'address' in configuration element 'network'!");
								string cidr = a->getFirstText();
								size_t pos = cidr.find("/");
								string ip = cidr.substr(0, pos);
								string sbits = cidr.substr(pos+1);
								int maskbits = atoi(sbits.c_str());
								if (maskbits<0 || maskbits>32)
									THROWEXCEPTION("IDSLoadBalancerCfg: attribute 'address' has invalid number of mask bits in configuration (%s)!", sbits.c_str());
								in_addr_t ipaddr = inet_addr(ip.c_str());
								if (ipaddr==(in_addr_t)-1)
									THROWEXCEPTION("IDSLoadBalancerCfg: attribute 'address' has invalid ip subnet in configuration (%s)!", ip.c_str());
								a = e->getAttribute("weight");
								if (!a) THROWEXCEPTION("IDSLoadBalancerCfg: no attribute 'weight' in configuration element 'network'!");
								char* res;
								float weight = strtof(a->getFirstText().c_str(), &res);
								if (weight<=0 || res==a->getFirstText().c_str())
									THROWEXCEPTION("IDSLoadBalancerCfg: attribute 'weight' in configuration element 'network' contains invalid value (%s)!", a->getFirstText().c_str());
								config.push_back(PriorityNetConfig(ntohl((uint32_t)ipaddr), ((1<<(32-maskbits))-1)^0xFFFFFFFF, maskbits, weight));
							}
						}
//.........这里部分代码省略.........
开发者ID:felixe,项目名称:vermont-OPF,代码行数:101,代码来源:IDSLoadbalancerCfg.cpp


注:本文中的XMLAttribute::getValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。