本文整理汇总了C++中rapidxml::xml_node::value方法的典型用法代码示例。如果您正苦于以下问题:C++ xml_node::value方法的具体用法?C++ xml_node::value怎么用?C++ xml_node::value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rapidxml::xml_node
的用法示例。
在下文中一共展示了xml_node::value方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseItem
void parseItem( const rapidxml::xml_node<> &node, XmlTree *parent, XmlTree *result, const XmlTree::ParseOptions &options )
{
*result = XmlTree( node.name(), node.value(), parent );
for( const rapidxml::xml_node<> *item = node.first_node(); item; item = item->next_sibling() ) {
XmlTree::NodeType type;
switch( item->type() ) {
case rapidxml::node_element:
type = XmlTree::NODE_ELEMENT;
break;
case rapidxml::node_cdata: {
if( options.getCollapseCData() ) {
result->setValue( result->getValue() + item->value() );
continue;
}
else {
type = XmlTree::NODE_CDATA;
}
}
break;
case rapidxml::node_comment:
type = XmlTree::NODE_COMMENT;
break;
case rapidxml::node_doctype: {
result->setDocType( item->value() );
continue;
}
case rapidxml::node_data: {
if( ! options.getIgnoreDataChildren() )
type = XmlTree::NODE_DATA;
else
continue;
}
break;
default:
continue;
}
result->getChildren().push_back( unique_ptr<XmlTree>( new XmlTree ) );
parseItem( *item, result, result->getChildren().back().get(), options );
result->getChildren().back()->setNodeType( type );
}
for( rapidxml::xml_attribute<> *attr = node.first_attribute(); attr; attr = attr->next_attribute() )
result->getAttributes().push_back( XmlTree::Attr( result, attr->name(), attr->value() ) );
}
示例2: XmlException
//===========================================
// XmlNode::getString
//===========================================
inline std::string XmlNode::getString() const {
if (isNull())
throw XmlException("Node is NULL", __FILE__, __LINE__);
return std::string(m_node->value(), m_node->value_size());
}
示例3: atoi
bool Frame::parseXml(const rapidxml::xml_node<char> &node,
std::string const &rootPath)
{
//read name
rapidxml::xml_node<char> *nameNode = node.first_node("name");
if (!nameNode)
{
std::cerr << "Error: Invalid Spriter file: Frame without name!" << std::endl;
return false;
}
this->name_ = nameNode->value();
//read and create sprites
for (rapidxml::xml_node<char> *curNode = node.first_node("sprite");
curNode;
curNode = curNode->next_sibling("sprite"))
{
Sprite *sprite;
sprite = new Sprite;
if (!sprite)
return false;
//get <image>
rapidxml::xml_node<char> *node = curNode->first_node("image");
if (!node)
{
std::cerr << "Error: Invalid Spriter file: Frame \"" << this->name_ << "\" lacks <image> node!" << std::endl;
return false;
}
if (!sprite->setBitmap(node->value(), rootPath))
{
return false;
}
//get <color> [0x000000 ; 0xffffff]
node = curNode->first_node("color");
if(!node)
{
std::cerr << "Error: Invalid Spriter file: Frame \"" << this->name_ << "\" lacks <color> node!" << std::endl;
return false;
}
int intColor = atoi(node->value());
//get <opacity> [0.f ; 100.f]
node = curNode->first_node("opacity");
if(!node)
{
std::cerr << "Error: Invalid Spriter file: Frame \"" << this->name_ << "\" lacks <opacity> node!" << std::endl;
return false;
}
float opacity = atof(node->value());
int colorR = (intColor & 0xff0000) >> 16;
int colorG = (intColor & 0x00ff00) >> 8;
int colorB = (intColor & 0x0000ff) >> 0;
int colorA = opacity / 100.f * 255.f;
sprite->setColor(al_map_rgba(colorR, colorG, colorB, colorA));
//get <angle> (in degrees, around upper left corner)
node = curNode->first_node("angle");
if(!node)
{
std::cerr << "Error: Invalid Spriter file: Frame \"" << this->name_ << "\" lacks <angle> node!" << std::endl;
return false;
}
sprite->setRotation(atof(node->value()));
//get <width> (in pixels)
node = curNode->first_node("width");
if(!node)
{
std::cerr << "Error: Invalid Spriter file: Frame \"" << this->name_ << "\" lacks <width> node!" << std::endl;
return false;
}
sprite->setWidth(atoi(node->value()));
//get <height> (in pixels)
node = curNode->first_node("height");
if(!node)
{
std::cerr << "Error: Invalid Spriter file: Frame \"" << this->name_ << "\" lacks <height> node!" << std::endl;
return false;
}
sprite->setHeight(atof(node->value()));
// //get <xflip>
// node = curNode->first_node("xflip");
// if(!node)
// {
// sf::err() << "Error: Invalid Spriter file: Frame \"" << mName << "\" lacks <xflip> node!" << std::endl;
// return false;
// }
// // if(atoi(node->value())) width *= -1;
//.........这里部分代码省略.........