本文整理汇总了C++中pugi::xml_node::attribute方法的典型用法代码示例。如果您正苦于以下问题:C++ xml_node::attribute方法的具体用法?C++ xml_node::attribute怎么用?C++ xml_node::attribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pugi::xml_node
的用法示例。
在下文中一共展示了xml_node::attribute方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadValue
void loadValue(pugi::xml_node attrib, const BoundSetter<T>& setValue)
{
T value = T();
decodeValue(attrib.attribute("value").value(), value);
setValue(value);
}
示例2: registerEvent
bool MoveEvents::registerEvent(Event* event, const pugi::xml_node& node)
{
MoveEvent* moveEvent = reinterpret_cast<MoveEvent*>(event);
const MoveEvent_t eventType = moveEvent->getEventType();
if (eventType == MOVE_EVENT_ADD_ITEM || eventType == MOVE_EVENT_REMOVE_ITEM) {
pugi::xml_attribute tileItemAttribute = node.attribute("tileitem");
if (tileItemAttribute && pugi::cast<uint16_t>(tileItemAttribute.value()) == 1) {
switch (eventType) {
case MOVE_EVENT_ADD_ITEM:
moveEvent->setEventType(MOVE_EVENT_ADD_ITEM_ITEMTILE);
break;
case MOVE_EVENT_REMOVE_ITEM:
moveEvent->setEventType(MOVE_EVENT_REMOVE_ITEM_ITEMTILE);
break;
default:
break;
}
}
}
pugi::xml_attribute attr;
if ((attr = node.attribute("itemid"))) {
int32_t id = pugi::cast<int32_t>(attr.value());
addEvent(moveEvent, id, m_itemIdMap);
if (moveEvent->getEventType() == MOVE_EVENT_EQUIP) {
ItemType& it = Item::items.getItemType(id);
it.wieldInfo = moveEvent->getWieldInfo();
it.minReqLevel = moveEvent->getReqLevel();
it.minReqMagicLevel = moveEvent->getReqMagLv();
it.vocationString = moveEvent->getVocationString();
}
} else if ((attr = node.attribute("fromid"))) {
uint32_t id = pugi::cast<uint32_t>(attr.value());
uint32_t endId = pugi::cast<uint32_t>(node.attribute("toid").value());
addEvent(moveEvent, id, m_itemIdMap);
if (moveEvent->getEventType() == MOVE_EVENT_EQUIP) {
ItemType& it = Item::items.getItemType(id);
it.wieldInfo = moveEvent->getWieldInfo();
it.minReqLevel = moveEvent->getReqLevel();
it.minReqMagicLevel = moveEvent->getReqMagLv();
it.vocationString = moveEvent->getVocationString();
while (++id <= endId) {
addEvent(moveEvent, id, m_itemIdMap);
ItemType& tit = Item::items.getItemType(id);
tit.wieldInfo = moveEvent->getWieldInfo();
tit.minReqLevel = moveEvent->getReqLevel();
tit.minReqMagicLevel = moveEvent->getReqMagLv();
tit.vocationString = moveEvent->getVocationString();
}
} else {
while (++id <= endId) {
addEvent(moveEvent, id, m_itemIdMap);
}
}
} else if ((attr = node.attribute("uniqueid"))) {
addEvent(moveEvent, pugi::cast<int32_t>(attr.value()), m_uniqueIdMap);
} else if ((attr = node.attribute("fromuid"))) {
uint32_t id = pugi::cast<uint32_t>(attr.value());
uint32_t endId = pugi::cast<uint32_t>(node.attribute("touid").value());
addEvent(moveEvent, id, m_uniqueIdMap);
while (++id <= endId) {
addEvent(moveEvent, id, m_uniqueIdMap);
}
} else if ((attr = node.attribute("actionid"))) {
addEvent(moveEvent, pugi::cast<int32_t>(attr.value()), m_actionIdMap);
} else if ((attr = node.attribute("fromaid"))) {
uint32_t id = pugi::cast<uint32_t>(attr.value());
uint32_t endId = pugi::cast<uint32_t>(node.attribute("toaid").value());
addEvent(moveEvent, id, m_actionIdMap);
while (++id <= endId) {
addEvent(moveEvent, id, m_actionIdMap);
}
} else if ((attr = node.attribute("pos"))) {
std::vector<int32_t> posList = vectorAtoi(explodeString(attr.as_string(), ";"));
if (posList.size() < 3) {
return false;
}
Position pos(posList[0], posList[1], posList[2]);
addEvent(moveEvent, pos, m_positionMap);
} else {
return false;
}
return true;
}
示例3: configureEvent
bool MoveEvent::configureEvent(const pugi::xml_node& node)
{
pugi::xml_attribute eventAttr = node.attribute("event");
if (!eventAttr) {
std::cout << "[Error - MoveEvent::configureMoveEvent] Missing event" << std::endl;
return false;
}
std::string tmpStr = asLowerCaseString(eventAttr.as_string());
if (tmpStr == "stepin") {
m_eventType = MOVE_EVENT_STEP_IN;
} else if (tmpStr == "stepout") {
m_eventType = MOVE_EVENT_STEP_OUT;
} else if (tmpStr == "equip") {
m_eventType = MOVE_EVENT_EQUIP;
} else if (tmpStr == "deequip") {
m_eventType = MOVE_EVENT_DEEQUIP;
} else if (tmpStr == "additem") {
m_eventType = MOVE_EVENT_ADD_ITEM;
} else if (tmpStr == "removeitem") {
m_eventType = MOVE_EVENT_REMOVE_ITEM;
} else {
std::cout << "Error: [MoveEvent::configureMoveEvent] No valid event name " << eventAttr.as_string() << std::endl;
return false;
}
if (m_eventType == MOVE_EVENT_EQUIP || m_eventType == MOVE_EVENT_DEEQUIP) {
pugi::xml_attribute slotAttribute = node.attribute("slot");
if (slotAttribute) {
tmpStr = asLowerCaseString(slotAttribute.as_string());
if (tmpStr == "head") {
slot = SLOTP_HEAD;
} else if (tmpStr == "necklace") {
slot = SLOTP_NECKLACE;
} else if (tmpStr == "backpack") {
slot = SLOTP_BACKPACK;
} else if (tmpStr == "armor") {
slot = SLOTP_ARMOR;
} else if (tmpStr == "right-hand") {
slot = SLOTP_RIGHT;
} else if (tmpStr == "left-hand") {
slot = SLOTP_LEFT;
} else if (tmpStr == "hand" || tmpStr == "shield") {
slot = SLOTP_RIGHT | SLOTP_LEFT;
} else if (tmpStr == "legs") {
slot = SLOTP_LEGS;
} else if (tmpStr == "feet") {
slot = SLOTP_FEET;
} else if (tmpStr == "ring") {
slot = SLOTP_RING;
} else if (tmpStr == "ammo") {
slot = SLOTP_AMMO;
} else {
std::cout << "[Warning - MoveEvent::configureMoveEvent] Unknown slot type: " << slotAttribute.as_string() << std::endl;
}
}
wieldInfo = 0;
pugi::xml_attribute levelAttribute = node.attribute("level");
if (levelAttribute) {
reqLevel = pugi::cast<uint32_t>(levelAttribute.value());
if (reqLevel > 0) {
wieldInfo |= WIELDINFO_LEVEL;
}
}
pugi::xml_attribute magLevelAttribute = node.attribute("maglevel");
if (magLevelAttribute) {
reqMagLevel = pugi::cast<uint32_t>(magLevelAttribute.value());
if (reqMagLevel > 0) {
wieldInfo |= WIELDINFO_MAGLV;
}
}
pugi::xml_attribute premiumAttribute = node.attribute("premium");
if (premiumAttribute) {
premium = premiumAttribute.as_bool();
if (premium) {
wieldInfo |= WIELDINFO_PREMIUM;
}
}
//Gather vocation information
std::list<std::string> vocStringList;
for (pugi::xml_node vocationNode = node.first_child(); vocationNode; vocationNode = vocationNode.next_sibling()) {
pugi::xml_attribute vocationNameAttribute = vocationNode.attribute("name");
if (!vocationNameAttribute) {
continue;
}
int32_t vocationId = g_vocations.getVocationId(vocationNameAttribute.as_string());
if (vocationId != -1) {
vocEquipMap[vocationId] = true;
if (vocationNode.attribute("showInDescription").as_bool(true)) {
vocStringList.push_back(asLowerCaseString(vocationNameAttribute.as_string()));
}
}
}
//.........这里部分代码省略.........
示例4: load
bool WallBrush::load(pugi::xml_node node, wxArrayString& warnings)
{
pugi::xml_attribute attribute;
if((attribute = node.attribute("lookid"))) {
look_id = pugi::cast<uint16_t>(attribute.value());
}
if((attribute = node.attribute("server_lookid"))) {
look_id = item_db[pugi::cast<uint16_t>(attribute.value())].clientID;
}
for(pugi::xml_node childNode = node.first_child(); childNode; childNode = childNode.next_sibling()) {
const std::string& childName = as_lower_str(childNode.name());
if(childName == "wall") {
const std::string& typeString = childNode.attribute("type").as_string();
if(typeString.empty()) {
warnings.push_back(wxT("Could not read type tag of wall node\n"));
continue;
}
uint32_t alignment;
if(typeString == "vertical") {
alignment = WALL_VERTICAL;
} else if(typeString == "horizontal") {
alignment = WALL_HORIZONTAL;
} else if(typeString == "corner") {
alignment = WALL_NORTHWEST_DIAGONAL;
} else if(typeString == "pole") {
alignment = WALL_POLE;
} else if(typeString == "south end") {
alignment = WALL_SOUTH_END;
} else if(typeString == "east end") {
alignment = WALL_EAST_END;
} else if(typeString == "north end") {
alignment = WALL_NORTH_END;
} else if(typeString == "west end") {
alignment = WALL_WEST_END;
} else if(typeString == "south T") {
alignment = WALL_SOUTH_T;
} else if(typeString == "east T") {
alignment = WALL_EAST_T;
} else if(typeString == "west T") {
alignment = WALL_WEST_T;
} else if(typeString == "north T") {
alignment = WALL_NORTH_T;
} else if(typeString == "northwest diagonal") {
alignment = WALL_NORTHWEST_DIAGONAL;
} else if(typeString == "northeast diagonal") {
alignment = WALL_NORTHEAST_DIAGONAL;
} else if(typeString == "southwest diagonal") {
alignment = WALL_SOUTHWEST_DIAGONAL;
} else if(typeString == "southeast diagonal") {
alignment = WALL_SOUTHEAST_DIAGONAL;
} else if(typeString == "intersection") {
alignment = WALL_INTERSECTION;
} else if(typeString == "untouchable") {
alignment = WALL_UNTOUCHABLE;
} else {
warnings.push_back(wxT("Unknown wall alignment '") + wxstr(typeString) + wxT("'\n"));
continue;
}
for(pugi::xml_node subChildNode = childNode.first_child(); subChildNode; subChildNode = subChildNode.next_sibling()) {
const std::string& subChildName = as_lower_str(subChildNode.name());
if(subChildName == "item") {
uint16_t id = pugi::cast<uint16_t>(subChildNode.attribute("id").value());
if(id == 0) {
warnings.push_back(wxT("Could not read id tag of item node\n"));
break;
}
ItemType& it = item_db[id];
if(it.id == 0) {
warnings.push_back(wxT("There is no itemtype with id ") + std::to_string(id));
return false;
} else if(it.brush && it.brush != this) {
warnings.push_back(wxT("Itemtype id ") + std::to_string(id) + wxT(" already has a brush"));
return false;
}
it.isWall = true;
it.brush = this;
it.border_alignment = ::BorderType(alignment);
WallType wt;
wt.id = id;
wall_items[alignment].total_chance += pugi::cast<int32_t>(subChildNode.attribute("chance").value());
wt.chance = wall_items[alignment].total_chance;
wall_items[alignment].items.push_back(wt);
} else if(subChildName == "door") {
uint16_t id = pugi::cast<uint16_t>(subChildNode.attribute("id").value());
if(id == 0) {
warnings.push_back(wxT("Could not read id tag of door node\n"));
break;
}
const std::string& type = subChildNode.attribute("type").as_string();
if(type.empty()) {
//.........这里部分代码省略.........
示例5: configureEvent
bool GlobalEvent::configureEvent(const pugi::xml_node& node)
{
pugi::xml_attribute nameAttribute = node.attribute("name");
if (!nameAttribute) {
std::cout << "[Error - GlobalEvent::configureEvent] Missing name for a globalevent" << std::endl;
return false;
}
m_name = nameAttribute.as_string();
m_eventType = GLOBALEVENT_NONE;
pugi::xml_attribute attr;
if ((attr = node.attribute("time"))) {
std::vector<int32_t> params = vectorAtoi(explodeString(attr.as_string(), ":"));
int32_t hour = params.front();
if (hour < 0 || hour > 23) {
std::cout << "[Error - GlobalEvent::configureEvent] Invalid hour \"" << attr.as_string() << "\" for globalevent with name: " << m_name << std::endl;
return false;
}
m_interval |= hour << 16;
int32_t min = 0;
int32_t sec = 0;
if (params.size() > 1) {
min = params[1];
if (min < 0 || min > 59) {
std::cout << "[Error - GlobalEvent::configureEvent] Invalid minute \"" << attr.as_string() << "\" for globalevent with name: " << m_name << std::endl;
return false;
}
if (params.size() > 2) {
sec = params[2];
if (sec < 0 || sec > 59) {
std::cout << "[Error - GlobalEvent::configureEvent] Invalid second \"" << attr.as_string() << "\" for globalevent with name: " << m_name << std::endl;
return false;
}
}
}
time_t current_time = time(nullptr);
tm* timeinfo = localtime(¤t_time);
timeinfo->tm_hour = hour;
timeinfo->tm_min = min;
timeinfo->tm_sec = sec;
time_t difference = static_cast<time_t>(difftime(mktime(timeinfo), current_time));
if (difference < 0) {
difference += 86400;
}
m_nextExecution = current_time + difference;
m_eventType = GLOBALEVENT_TIMER;
} else if ((attr = node.attribute("type"))) {
std::string tmpStrValue = asLowerCaseString(attr.as_string());
if (tmpStrValue == "startup" || tmpStrValue == "start" || tmpStrValue == "load") {
m_eventType = GLOBALEVENT_STARTUP;
} else if (tmpStrValue == "shutdown" || tmpStrValue == "quit" || tmpStrValue == "exit") {
m_eventType = GLOBALEVENT_SHUTDOWN;
} else if (tmpStrValue == "record" || tmpStrValue == "playersrecord") {
m_eventType = GLOBALEVENT_RECORD;
} else {
std::cout << "[Error - GlobalEvent::configureEvent] No valid type \"" << attr.as_string() << "\" for globalevent with name " << m_name << std::endl;
return false;
}
} else if ((attr = node.attribute("interval"))) {
m_interval = std::max<int32_t>(SCHEDULER_MINTICKS, pugi::cast<int32_t>(attr.value()));
m_nextExecution = OTSYS_TIME() + m_interval;
} else {
std::cout << "[Error - GlobalEvent::configureEvent] No interval for globalevent with name " << m_name << std::endl;
return false;
}
return true;
}
示例6: deserializeSpell
bool Monsters::deserializeSpell(const pugi::xml_node& node, spellBlock_t& sb, const std::string& description)
{
std::string name;
std::string scriptName;
bool isScripted;
pugi::xml_attribute attr;
if ((attr = node.attribute("script"))) {
scriptName = attr.as_string();
isScripted = true;
} else if ((attr = node.attribute("name"))) {
name = attr.as_string();
isScripted = false;
} else {
return false;
}
if ((attr = node.attribute("speed")) || (attr = node.attribute("interval"))) {
sb.speed = std::max<int32_t>(1, pugi::cast<int32_t>(attr.value()));
}
if ((attr = node.attribute("chance"))) {
uint32_t chance = pugi::cast<uint32_t>(attr.value());
if (chance > 100) {
chance = 100;
}
sb.chance = chance;
}
if ((attr = node.attribute("range"))) {
uint32_t range = pugi::cast<uint32_t>(attr.value());
if (range > (Map::maxViewportX * 2)) {
range = Map::maxViewportX * 2;
}
sb.range = range;
}
if ((attr = node.attribute("min"))) {
sb.minCombatValue = pugi::cast<int32_t>(attr.value());
}
if ((attr = node.attribute("max"))) {
sb.maxCombatValue = pugi::cast<int32_t>(attr.value());
//normalize values
if (std::abs(sb.minCombatValue) > std::abs(sb.maxCombatValue)) {
int32_t value = sb.maxCombatValue;
sb.maxCombatValue = sb.minCombatValue;
sb.minCombatValue = value;
}
}
if (auto spell = g_spells->getSpellByName(name)) {
sb.spell = spell;
return true;
}
CombatSpell* combatSpell = nullptr;
bool needTarget = false;
bool needDirection = false;
if (isScripted) {
if ((attr = node.attribute("direction"))) {
needDirection = attr.as_bool();
}
if ((attr = node.attribute("target"))) {
needTarget = attr.as_bool();
}
std::unique_ptr<CombatSpell> combatSpellPtr(new CombatSpell(nullptr, needTarget, needDirection));
if (!combatSpellPtr->loadScript("data/" + g_spells->getScriptBaseName() + "/scripts/" + scriptName)) {
return false;
}
if (!combatSpellPtr->loadScriptCombat()) {
return false;
}
combatSpell = combatSpellPtr.release();
combatSpell->getCombat()->setPlayerCombatValues(COMBAT_FORMULA_DAMAGE, sb.minCombatValue, 0, sb.maxCombatValue, 0);
} else {
Combat* combat = new Combat;
if ((attr = node.attribute("length"))) {
int32_t length = pugi::cast<int32_t>(attr.value());
if (length > 0) {
int32_t spread = 3;
//need direction spell
if ((attr = node.attribute("spread"))) {
spread = std::max<int32_t>(0, pugi::cast<int32_t>(attr.value()));
}
AreaCombat* area = new AreaCombat();
area->setupArea(length, spread);
combat->setArea(area);
needDirection = true;
}
}
//.........这里部分代码省略.........
示例7: HandleError
void RosterMaintaner::HandleError(pugi::xml_node Node)
{
JID From(Node.attribute("from").value());
std::cerr << "Received error presence from " << From.GetFullJID() << std::endl;
}
示例8: route
ProcessResult IqRouter::route(mtalk::talk::SessionPtr sessionPtr, const pugi::xml_node& node){
std::string toStr = node.attribute("to").value();
std::string fromStr = node.attribute("from").value();
JID to(toStr);
JID from(fromStr);
if(to.getEndpoint() == "muc.m.renren.com"){
long fromid = from.getUserId();
string sessionid = sessionPtr->getSessionId();
stringstream ss;
node.print(ss,"\t",pugi::format_raw);
string message=ss.str();
bool forward = MY_INSTANCE(ProxyRegister).getProxy<MucServiceProxy>("mucProxy")->forwardIq(fromid,sessionid,message); //推给muc服务器
// 如果forward成功,返回ok,否则返回error
if(forward){
ProcessResult result(ProcessResult::OK, "<success/>");
return result;
}else {
ProcessResult result(ProcessResult::ERROR, "forward muc fail");
return result;
}
}
//单聊信息
if(to.getEndpoint() == "talk.sixin.com" || to.getEndpoint() == "renren.sixin.com" || to.getEndpoint() == "talk.m.renren.com" ||to.getEndpoint() ==""){
if(node.child("msgType")){
return msgTypeHandlerPtr_->handler(sessionPtr, node);
}
stringstream os;
node.print(os,"\t",pugi::format_raw);
MY_INSTANCE(TalkServer).remotePush(from.getUserId(), to.getUserId(), os.str(), MessageType::ENTITY);
ProcessResult result;
return result;
} else {
long fromid = from.getUserId();
long toid = to.getUserId();
//string sessionid = sessionPtr->getSessionId();
stringstream ss;
node.print(ss,"\t",pugi::format_raw);
string message=ss.str();
string router=to.getRouter();
LOG_DEBUG("IqRoute::route forward "<< router<<"iq msg = "<<message);
router.append("ServiceProxy");
ProcessResult result;
bool forward = 0;
if(MY_INSTANCE(ProxyRegister).getProxy<RouterServiceProxy>(router).get()!=0){
LOG_DEBUG("IqRoute::get RouterServiceProxy and forward"<<router<<" iq msg = "<<message);
forward = MY_INSTANCE(ProxyRegister).getProxy<RouterServiceProxy>(router)->forwardIq(fromid,toid,message);
}
// 如果forward成功,返回ok,否则返回error
string id = node.attribute("id").value();
string type=node.attribute("type").value();
if(forward){
result.setCode(ProcessResult::OK);
stringstream ss;
ss<<"<success id='";
ss<<id;
ss << "' from='";
ss << from.toString();
ss << "' to='";
ss << to.toString();
ss<<"' type='";
ss<<type;
ss<<"'/>";
result.setMsg(ss.str());
return result;
}else {
ProcessResult result(ProcessResult::ERROR);
stringstream s;
s<<"<error id='";
s<<id;
s<<"'>fail to ";
s<<to.getEndpoint();
s<<" error</error>";
result.setMsg(s.str());
result.setMsg("<error>talk internal error</error>");
return result;
}
}
}
示例9: CMapNode
CArenaMapNode::CArenaMapNode(const pugi::xml_node &config) : CMapNode(config)
{
initialize(config.attribute("path").as_string(""));
}
示例10: registerEvent
bool Actions::registerEvent(Event* event, const pugi::xml_node& node)
{
Action* action = dynamic_cast<Action*>(event);
if (!action) {
return false;
}
pugi::xml_attribute attr;
if ((attr = node.attribute("itemid"))) {
uint16_t id = pugi::cast<uint16_t>(attr.value());
if (useItemMap.find(id) != useItemMap.end()) {
std::cout << "[Warning - Actions::registerEvent] Duplicate registered item with id: " << id << std::endl;
return false;
}
useItemMap[id] = action;
} else if ((attr = node.attribute("fromid"))) {
pugi::xml_attribute toIdAttribute = node.attribute("toid");
if (toIdAttribute) {
uint16_t fromId = pugi::cast<uint16_t>(attr.value());
uint16_t iterId = fromId;
uint16_t toId = pugi::cast<uint16_t>(toIdAttribute.value());
bool success = false;
if (useItemMap.find(iterId) != useItemMap.end()) {
std::cout << "[Warning - Actions::registerEvent] Duplicate registered item with id: " << iterId << " in fromid: " << fromId << ", toid: " << toId << std::endl;
} else {
useItemMap[iterId] = action;
success = true;
}
while (++iterId <= toId) {
if (useItemMap.find(iterId) != useItemMap.end()) {
std::cout << "[Warning - Actions::registerEvent] Duplicate registered item with id: " << iterId << " in fromid: " << fromId << ", toid: " << toId << std::endl;
continue;
}
useItemMap[iterId] = action;
success = true;
}
return success;
} else {
std::cout << "[Warning - Actions::registerEvent] Missing toid in fromid: " << attr.as_string() << std::endl;
return false;
}
} else if ((attr = node.attribute("uniqueid"))) {
uint16_t uid = pugi::cast<uint16_t>(attr.value());
if (uniqueItemMap.find(uid) != uniqueItemMap.end()) {
std::cout << "[Warning - Actions::registerEvent] Duplicate registered item with uniqueid: " << uid << std::endl;
return false;
}
uniqueItemMap[uid] = action;
} else if ((attr = node.attribute("fromuid"))) {
pugi::xml_attribute toUidAttribute = node.attribute("touid");
if (toUidAttribute) {
uint16_t fromUid = pugi::cast<uint16_t>(attr.value());
uint16_t iterUid = fromUid;
uint16_t toUid = pugi::cast<uint16_t>(toUidAttribute.value());
bool success = false;
if (uniqueItemMap.find(iterUid) != uniqueItemMap.end()) {
std::cout << "[Warning - Actions::registerEvent] Duplicate registered item with unique id: " << iterUid << " in fromuid: " << fromUid << ", touid: " << toUid << std::endl;
} else {
uniqueItemMap[iterUid] = action;
success = true;
}
while (++iterUid <= toUid) {
if (uniqueItemMap.find(iterUid) != uniqueItemMap.end()) {
std::cout << "[Warning - Actions::registerEvent] Duplicate registered item with unique id: " << iterUid << " in fromuid: " << fromUid << ", touid: " << toUid << std::endl;
continue;
}
uniqueItemMap[iterUid] = action;
success = true;
}
return success;
} else {
std::cout << "[Warning - Actions::registerEvent] Missing touid in fromuid: " << attr.as_string() << std::endl;
return false;
}
} else if ((attr = node.attribute("actionid"))) {
uint16_t aid = pugi::cast<uint16_t>(attr.value());
if (actionItemMap.find(aid) != actionItemMap.end()) {
std::cout << "[Warning - Actions::registerEvent] Duplicate registered item with actionid: " << aid << std::endl;
return false;
}
actionItemMap[aid] = action;
} else if ((attr = node.attribute("fromaid"))) {
pugi::xml_attribute toAidAttribute = node.attribute("toaid");
if (toAidAttribute) {
uint16_t fromAid = pugi::cast<uint16_t>(attr.value());
uint16_t iterAid = fromAid;
uint16_t toAid = pugi::cast<uint16_t>(toAidAttribute.value());
bool success = false;
if (actionItemMap.find(iterAid) != actionItemMap.end()) {
std::cout << "[Warning - Actions::registerEvent] Duplicate registered item with action id: " << iterAid << " in fromaid: " << fromAid << ", toaid: " << toAid << std::endl;
} else {
actionItemMap[iterAid] = action;
success = true;
}
//.........这里部分代码省略.........