本文整理汇总了C++中XmlElement::name方法的典型用法代码示例。如果您正苦于以下问题:C++ XmlElement::name方法的具体用法?C++ XmlElement::name怎么用?C++ XmlElement::name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlElement
的用法示例。
在下文中一共展示了XmlElement::name方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PropertySet
//--------------------------------------------------------------------------------------------------
/// Create a new PropertySet from the specified XML element
///
/// The XML element passed as a parameter is assumed to be a PropertySet element
//--------------------------------------------------------------------------------------------------
ref<PropertySet> PropertyXmlSerializer::createPropertySetFromXmlElement(const XmlElement& xmlPropertySetElement)
{
CVF_ASSERT(xmlPropertySetElement.name() == "PropertySet");
String propSetClassType = xmlPropertySetElement.getAttributeString("classType");
ref<PropertySet> ps = new PropertySet(propSetClassType);
const XmlElement* xmlElem = xmlPropertySetElement.firstChildElement();
while (xmlElem)
{
Variant variant = variantFromXmlElement(*xmlElem);
if (variant.isValid())
{
String key = xmlElem->getAttributeString("key");
if (!key.isEmpty())
{
ps->setValue(key, variant);
}
}
xmlElem = xmlElem->nextSiblingElement();
}
return ps;
}
示例2: toPropertySetCollection
//--------------------------------------------------------------------------------------------------
/// Populate the PropertySet from the specified XML element
///
/// The XML element passed as a parameter is assumed to be a PropertySet element
//--------------------------------------------------------------------------------------------------
void PropertyXmlSerializer::toPropertySetCollection(const XmlElement& xmlPropertySetCollectionElement, PropertySetCollection* propertySetCollection)
{
CVF_ASSERT(xmlPropertySetCollectionElement.name() == "PropertySetCollection");
CVF_ASSERT(propertySetCollection);
const XmlElement* xmlElem = xmlPropertySetCollectionElement.firstChildElement("PropertySet");
while (xmlElem)
{
ref<PropertySet> ps = createPropertySetFromXmlElement(*xmlElem);
propertySetCollection->addPropertySet(ps.p());
xmlElem = xmlElem->nextSiblingElement("PropertySet");
}
}
示例3: arrayVariantFromXmlElement
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Variant PropertyXmlSerializer::arrayVariantFromXmlElement(const XmlElement& xmlArrayVariantElement)
{
CVF_ASSERT(xmlArrayVariantElement.name().toLower() == "array");
std::vector<Variant> arr;
const XmlElement* xmlElem = xmlArrayVariantElement.firstChildElement();
while (xmlElem)
{
Variant variant = variantFromXmlElement(*xmlElem);
if (variant.isValid())
{
arr.push_back(variant);
}
xmlElem = xmlElem->nextSiblingElement();
}
return Variant(arr);
}
示例4: variantFromXmlElement
//--------------------------------------------------------------------------------------------------
/// Create variant from the specified XML element
///
/// If the passed XML element is not recognized as a variant, an invalid variant will be returned
//--------------------------------------------------------------------------------------------------
cvf::Variant PropertyXmlSerializer::variantFromXmlElement(const XmlElement& xmlVariantElement)
{
const String elementName = xmlVariantElement.name().toLower();
const String valueText = xmlVariantElement.valueText();
if (elementName == "int")
{
bool ok = false;
int val = valueText.toInt(&ok);
if (ok)
{
return Variant(val);
}
}
else if (elementName == "uint")
{
bool ok = false;
uint val = valueText.toUInt(&ok);
if (ok)
{
return Variant(val);
}
}
else if (elementName == "double")
{
bool ok = false;
double val = valueText.toDouble(&ok);
if (ok)
{
return Variant(val);
}
}
else if (elementName == "float")
{
bool ok = false;
float val = valueText.toFloat(&ok);
if (ok)
{
return Variant(val);
}
}
else if (elementName == "bool")
{
String valStr = valueText.toLower();
bool val = (valStr == "true") ? true : false;
return Variant(val);
}
else if (elementName == "vec3d")
{
return variantFromVec3dValueText(valueText);
}
else if (elementName == "color3f")
{
return variantFromColor3fValueText(valueText);
}
else if (elementName == "string")
{
return Variant(valueText);
}
else if (elementName == "array")
{
return arrayVariantFromXmlElement(xmlVariantElement);
}
return Variant();
}
示例5: load
void FlowData::load()
{
if(!mReady)
{
Timer timer(true);
XmlDocument * pointsDoc = new XmlDocument(dataSource);
XmlElement rootNode = pointsDoc->rootNode();
if(rootNode.hasChildren())
{
XmlElement tagNode = rootNode.findChild("tag");
XmlElement drawingNode = tagNode.findChild("drawing");
// Now get all the drawingNode's children.. and only worry about the stroke nodes.
if(drawingNode.hasChildren())
{
std::vector<XmlElement> strokeNodes = drawingNode.children();
// std::vector<XmlElement> strokeNodes = rootNode.xpath("//tag/drawing//stroke");
if(strokeNodes.size() > 0)
{
int totalPoints = 0;
// Now declare some variables to reuse in our loop.
FlowPoint lastPt(Vec2f::zero(), Vec2f::zero(), -1.f);
for(std::vector<XmlElement>::iterator it = strokeNodes.begin(); it < strokeNodes.end(); it++)
{
XmlElement strokeNode = *it;
if(strokeNode.name() == "stroke")
{
// Get all the point nodes.
std::vector<XmlElement> pointNodes = strokeNode.children();
// Create a new stroke
std::vector<FlowPoint> * stroke = new std::vector<FlowPoint>;
for(std::vector<XmlElement>::iterator it2 = pointNodes.begin(); it2 < pointNodes.end(); it2++)
{
XmlElement ptNode = *it2;
if(ptNode.name() == "pt")
{
std::string xVal = ptNode.findChild("x").value();
// float x = fromString( xVal );
float x = boost::lexical_cast<float>( xVal );
std::string yVal = ptNode.findChild("y").value();
// float y = fromString( yVal );
float y = boost::lexical_cast<float>( yVal );
std::string timeVal = ptNode.findChild("time").value();
// float time = fromString( timeVal );
float time = boost::lexical_cast<float>( timeVal );
x = mRemapMinX + (mRemapMaxX - mRemapMinX) * x;
y = mRemapMinY + (mRemapMaxY - mRemapMinY) * y;
Vec2f pos(x, y);
Vec2f vel;
if(lastPt.time > -1)
{
vel.x = pos.x - lastPt.getX();
vel.y = pos.y - lastPt.getY();
}
FlowPoint pt(pos, vel, time);
bool shouldAddPoint = false;
if(ignoreRedundantPositions == true)
{
if(lastPt.time > -1)
{
if(pt.getX() != lastPt.getX() && pt.getY() != lastPt.getY())
{
shouldAddPoint = true;
}
}
else
{
shouldAddPoint = true;
}
}
else
{
shouldAddPoint = true;
}
if(shouldAddPoint)
{
totalPoints++;
stroke->push_back(pt);
lastPt = FlowPoint(pt.pos, pt.vel, pt.time);
}
}
}
// Now see if our stroke is long enough.
if(stroke->size() > minNumberOfPointsInStroke)
{
//.........这里部分代码省略.........