本文整理汇总了C++中xml_node::attribute方法的典型用法代码示例。如果您正苦于以下问题:C++ xml_node::attribute方法的具体用法?C++ xml_node::attribute怎么用?C++ xml_node::attribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xml_node
的用法示例。
在下文中一共展示了xml_node::attribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handler
ProcessResult MsgTypeIqProcessHandler::handler(SessionPtr sessionPtr, const xml_node& node){
ProcessResult result;
ostringstream os;
sessionPtr->delAllSupportType();
for(xml_node msgType = node.first_child(); msgType; msgType = msgType.next_sibling()){
if(strcmp(msgType.name(), "msgType") != 0){
continue;
}
string msgTypeStr = msgType.child_value();
boost::trim(msgTypeStr);
if(msgTypeStr == "chat"){
sessionPtr->addSupportType(MessageType::CHAT);
} else if (msgTypeStr == "feed"){
sessionPtr->addSupportType(MessageType::FEED);
} else if (msgTypeStr == "notify"){
sessionPtr->addSupportType(MessageType::NOTIFY);
}
}
string id = node.attribute("id").value();
string from = node.attribute("from").value();
result.setCode(ProcessResult::HAS_RESPONSE);
os << "<iq id='" << id << "' to='" << from << "' type='result'>"
<< "<success/></iq>";
result.setMsg(os.str());
return result;
}
示例2: parseBlackAreas
void Camera::parseBlackAreas(xml_node &cur) {
if (isTag(cur.name(), "Vertical")) {
int x = cur.attribute("x").as_int(-1);
if (x < 0) {
ThrowCME("Invalid x coordinate in vertical BlackArea of in camera %s %s", make.c_str(), model.c_str());
}
int w = cur.attribute("width").as_int(-1);
if (w < 0) {
ThrowCME("Invalid width in vertical BlackArea of in camera %s %s", make.c_str(), model.c_str());
}
blackAreas.push_back(BlackArea(x, w, true));
} else if (isTag(cur.name(), "Horizontal")) {
int y = cur.attribute("y").as_int(-1);
if (y < 0) {
ThrowCME("Invalid y coordinate in horizontal BlackArea of in camera %s %s", make.c_str(), model.c_str());
}
int h = cur.attribute("height").as_int(-1);
if (h < 0) {
ThrowCME("Invalid width in horizontal BlackArea of in camera %s %s", make.c_str(), model.c_str());
}
blackAreas.push_back(BlackArea(y, h, false));
}
}
示例3: parseCFA
void Camera::parseCFA(xml_node &cur) {
if (isTag(cur.name(), "ColorRow")) {
int y = cur.attribute("y").as_int(-1);
if (y < 0 || y >= cfa.size.y) {
ThrowCME("Invalid y coordinate in CFA array of in camera %s %s", make.c_str(), model.c_str());
}
const char* key = cur.first_child().value();
if ((int)strlen(key) != cfa.size.x) {
ThrowCME("Invalid number of colors in definition for row %d in camera %s %s. Expected %d, found %d.", y, make.c_str(), model.c_str(), cfa.size.x, strlen(key));
}
for (int x = 0; x < cfa.size.x; x++) {
char v = (char)tolower((int)key[x]);
if (v == 'g')
cfa.setColorAt(iPoint2D(x, y), CFA_GREEN);
else if (v == 'r')
cfa.setColorAt(iPoint2D(x, y), CFA_RED);
else if (v == 'b')
cfa.setColorAt(iPoint2D(x, y), CFA_BLUE);
else if (v == 'f')
cfa.setColorAt(iPoint2D(x, y), CFA_FUJI_GREEN);
else if (v == 'c')
cfa.setColorAt(iPoint2D(x, y), CFA_CYAN);
else if (v == 'm')
cfa.setColorAt(iPoint2D(x, y), CFA_MAGENTA);
else if (v == 'y')
cfa.setColorAt(iPoint2D(x, y), CFA_YELLOW);
else
supported = FALSE;
}
}
if (isTag(cur.name(), "Color")) {
int x = cur.attribute("x").as_int(-1);
if (x < 0 || x >= cfa.size.x) {
ThrowCME("Invalid x coordinate in CFA array of in camera %s %s", make.c_str(), model.c_str());
}
int y = cur.attribute("y").as_int(-1);
if (y < 0 || y >= cfa.size.y) {
ThrowCME("Invalid y coordinate in CFA array of in camera %s %s", make.c_str(), model.c_str());
}
const char* key = cur.first_child().value();
if (isTag(key, "GREEN"))
cfa.setColorAt(iPoint2D(x, y), CFA_GREEN);
else if (isTag(key, "RED"))
cfa.setColorAt(iPoint2D(x, y), CFA_RED);
else if (isTag(key, "BLUE"))
cfa.setColorAt(iPoint2D(x, y), CFA_BLUE);
else if (isTag(key, "FUJIGREEN"))
cfa.setColorAt(iPoint2D(x, y), CFA_FUJI_GREEN);
else if (isTag(key, "CYAN"))
cfa.setColorAt(iPoint2D(x, y), CFA_CYAN);
else if (isTag(key, "MAGENTA"))
cfa.setColorAt(iPoint2D(x, y), CFA_MAGENTA);
else if (isTag(key, "YELLOW"))
cfa.setColorAt(iPoint2D(x, y), CFA_YELLOW);
}
}
示例4: Configure
bool Camera::Configure(xml_node xml)
{
this->chip = xml.attribute("chip").as_string();
this->contextCount = xml.attribute("contexts").as_int(1);
this->hdr = xml.attribute("hdr").as_bool();
this->sizeByRange = xml.attribute("sizeByRange").as_bool();
this->addressSize = xml.attribute("addressSize").as_int(1);
this->bayerMode = xml.attribute("bayer").as_int(0);
for (auto &child : xml.children("register"))
{
int address = strtol(child.attribute("address").as_string("0x00"), nullptr, 0);
this->registers[address] = { child, &this->transport, this->addressSize };
}
// Two separate loops, because the population of the register list involves
// growing memory and therefore any references taken for the features would
// become invalid.
for (auto &child : xml.children("register"))
{
int address = strtol(child.attribute("address").as_string("0x00"), nullptr, 0);
for (auto &feature : child.children("feature"))
{
this->features[feature.attribute("name").as_string()] = { feature, &this->registers[address] };
}
}
for (auto &child : xml.children("alias"))
{
string key = child.attribute("name").as_string();
string feature = child.attribute("feature").as_string();
int context = child.attribute("context").as_int(-1);
if (!key.empty() && !feature.empty() && this->features.count(feature))
{
if (context < 0)
{
// If context hasn't been assigned then it should be copied across all contexts
for (int i=0; i<this->contextCount; i++)
{
this->aliases[i].Set(key, this->features[feature]);
}
}
else if (context < this->contextCount)
{
this->aliases[context].Set(key, this->features[feature]);
}
}
}
return this->features.size();
}
示例5:
/**
* Set an attribute on an XML node.
* In theory, XML nodes have an ordered collection of named attributes, duplicates
* allowed. In practice, we're using it as an unordered string=>string dictionary.
*/
template<class T> static void set_attribute(xml_node &node, const char *key, T newValue)
{
if(node.attribute(key).empty())
{
node.append_attribute(key).set_value(newValue);
}
else
{
node.attribute(key).set_value(newValue);
}
}
示例6:
hw_Button::hw_Button( xml_node button )
{
bname=button.attribute("name").value();
baction=button.attribute("action").value();
P=button.child_value("P");
DDR=button.child_value("DDR");
PIN=button.child_value("PIN");
PORT=button.child_value("PORT");
if( button.child_value("Active")=="high" )
active=high;
else
active=low;
}
示例7: loadNode
void AlphaInputBox::loadNode(xml_node node) {
TextBox::loadNode(node);
if (node.attribute("default") != NULL) {
string def = node.attribute("default").as_string();
wstringstream wss;
wss << def.c_str();
userInput = wss.str();
}
}
示例8: parseStandardMaterial
void TgcSceneParser::parseStandardMaterial(TgcMaterialData* material, const xml_node &matNode)
{
material->name = matNode.attribute("name").as_string();
material->type = matNode.attribute("type").as_string();
material->subMaterialsCount = 0;
//Material values
string ambientStr = matNode.child("ambient").child_value();
TgcParserUtils::parseFloat4Array(ambientStr, material->ambientColor);
TgcParserUtils::divFloatArrayValues(material->ambientColor, 4, 255.0f);
string diffuseStr = matNode.child("diffuse").child_value();
TgcParserUtils::parseFloat4Array(diffuseStr, material->diffuseColor);
TgcParserUtils::divFloatArrayValues(material->diffuseColor, 4, 255.0f);
string specularStr = matNode.child("specular").child_value();
TgcParserUtils::parseFloat4Array(specularStr, material->specularColor);
TgcParserUtils::divFloatArrayValues(material->specularColor, 4, 255.0f);
string opacityStr = matNode.child("opacity").child_value();
material->opacity = TgcParserUtils::parseFloat(opacityStr) / 100.0f;
xml_node alphaBlendEnableNode = matNode.child("alphaBlendEnable");
if (alphaBlendEnableNode != NULL)
{
material->alphaBlendEnable = TgcParserUtils::parseBool(alphaBlendEnableNode.child_value());
}
//Bitmap values
xml_node bitmapNode = matNode.child("bitmap");
if (bitmapNode != NULL)
{
material->fileName = bitmapNode.child_value();
//TODO: formatear correctamente TILING y OFFSET
string uvTilingStr = bitmapNode.attribute("uvTiling").as_string();
TgcParserUtils::parseFloat2Array(uvTilingStr, material->uvTiling);
string uvOffsetStr = bitmapNode.attribute("uvOffset").as_string();
TgcParserUtils::parseFloat2Array(uvOffsetStr, material->uvOffset);
}
else
{
material->fileName = "";
//material.uvTiling = null;
//material.uvOffset = null;
}
}
示例9: load_gdimm_process
void gdipp_setting::load_gdimm_process(const xpath_node_set &process_nodes)
{
// backward iterate so that first-coming process settings overwrites last-coming ones
xpath_node_set::const_iterator node_iter = process_nodes.end();
node_iter--;
for (size_t i = 0; i < process_nodes.size(); i++, node_iter--)
{
// only store the setting items which match the current process name
const xml_node curr_proc = node_iter->node();
const xml_attribute name_attr = curr_proc.attribute(L"name");
bool process_matched = name_attr.empty();
if (!process_matched)
{
const wregex name_ex(name_attr.value(), regex_flags);
process_matched = regex_match(_process_name, name_ex);
}
if (process_matched)
{
for (xml_node::iterator set_iter = node_iter->node().begin(); set_iter != node_iter->node().end(); set_iter++)
parse_gdimm_setting_node(*set_iter, _process_setting);
}
}
}
示例10: parseID
void Camera::parseID( xml_node &cur )
{
if (isTag(cur.name(), "ID")) {
pugi::xml_attribute id_make = cur.attribute("make");
if (id_make) {
canonical_make = string(id_make.as_string());
} else
ThrowCME("CameraMetadata: Could not find make for ID for %s %s camera.", make.c_str(), model.c_str());
pugi::xml_attribute id_model = cur.attribute("model");
if (id_model) {
canonical_model = string(id_model.as_string());
} else
ThrowCME("CameraMetadata: Could not find model for ID for %s %s camera.", make.c_str(), model.c_str());
canonical_id = string(cur.first_child().value());
}
}
示例11: WidgetInfo
WidgetInfo::WidgetInfo(xml_node& nodes, WidgetInfo* parent):
_w(nodes),_btree(nodes.attribute("behaviour").as_string()),_parent(parent)
{
auto i = nodes.children();
for (auto node : nodes)
{
_nextNode.push_back(new WidgetInfo(node, this));
}
}
示例12: stringAttributeFromNode
string Scene::stringAttributeFromNode(const xml_node &node, const string& attributeName)
{
xml_attribute attr = node.attribute(attributeName.c_str());
if(!attr){
stringstream ss;
ss << "node <"<< node.name() << "> has no '" << attributeName << "' attribute";
throw invalid_argument(ss.str().c_str());
}
return attr.as_string();
}
示例13: ParseItemMenu
void Settings::ParseItemMenu(const xml_node& node)
{
ItemMenu menu;
menu.Name = node.attribute("Name").value();
menu.Description = node.attribute("Description").value();
menu.Type = node.attribute("Type").value();
for (auto child : node.children("Item"))
{
ItemElement item;
item.Name = child.attribute("Name").value();
item.Value = child.attribute("Value").value();
item.Error = child.attribute("Error").value();
item.Description = child.attribute("Description").value();
menu.Items[item.Name] = item;
}
m_menus[menu.Name] = menu;
}
示例14: parseHint
void Camera::parseHint( xml_node &cur )
{
if (isTag(cur.name(), "Hint")) {
string hint_name, hint_value;
pugi::xml_attribute key = cur.attribute("name");
if (key) {
hint_name = string(key.as_string());
} else
ThrowCME("CameraMetadata: Could not find name for hint for %s %s camera.", make.c_str(), model.c_str());
key = cur.attribute("value");
if (key) {
hint_value = string(key.as_string());
} else
ThrowCME("CameraMetadata: Could not find value for hint %s for %s %s camera.", hint_name.c_str(), make.c_str(), model.c_str());
hints.insert(make_pair(hint_name, hint_value));
}
}
示例15: add_layer
void Tilemap::add_layer(std::map<unsigned, Surface>& tiles, xml_node node,
int tilewidth, int tileheight)
{
Layer layer;
int width = node.attribute("width").as_int();
int height = node.attribute("height").as_int();
if (!width || !height)
throw std::logic_error("Layer is empty.");
#if 0
std::cerr << "Adding layer:" <<
" Name: " << node.attribute("name").value() <<
" Width: " << width <<
" Height: " << height << std::endl;
#endif
Utils::xml_node_walker walk{node.child("data"), "tile", "gid"};
int index = 0;
for (auto& gid_str : walk)
{
Pos pos = Pos(index % width, index / width);
unsigned gid = Utils::stoi(gid_str);
if (gid)
{
Blit::Surface surf = tiles[gid];
surf.rect().pos = pos * Pos(tilewidth, tileheight);
layer.cluster.vec().push_back({surf, Pos()});
if (Utils::find_or_default(surf.attr(), "collision", "") == "true")
collisions.insert(pos);
}
index++;
}
layer.attr = get_attributes(node.child("properties"), "property");
layer.name = node.attribute("name").value();
m_layers.push_back(std::move(layer));
}