这篇教程C++ xml_nextNode函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中xml_nextNode函数的典型用法代码示例。如果您正苦于以下问题:C++ xml_nextNode函数的具体用法?C++ xml_nextNode怎么用?C++ xml_nextNode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了xml_nextNode函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: pfaction_load/** * @brief Loads the player's faction standings. * * @param parent Parent xml node to read from. * @return 0 on success. */int pfaction_load( xmlNodePtr parent ){ xmlNodePtr node, cur; char *str; int faction; node = parent->xmlChildrenNode; do { if (xml_isNode(node,"factions")) { cur = node->xmlChildrenNode; do { if (xml_isNode(cur,"faction")) { xmlr_attr(cur,"name",str); faction = faction_get(str); if (faction != -1) { /* Faction is valid. */ /* Must not be static. */ if (!faction_isFlag( &faction_stack[faction], FACTION_STATIC )) faction_stack[faction].player = xml_getFloat(cur); } free(str); } } while (xml_nextNode(cur)); } } while (xml_nextNode(node)); return 0;}
开发者ID:Anatolis,项目名称:naev,代码行数:36,
示例2: pfaction_load/** * @brief Loads the player's faction standings. * * @param parent Parent xml node to read from. * @return 0 on success. */int pfaction_load( xmlNodePtr parent ){ xmlNodePtr node, cur; char *str; int faction; node = parent->xmlChildrenNode; do { if (xml_isNode(node,"factions")) { cur = node->xmlChildrenNode; do { if (xml_isNode(cur,"faction")) { xmlr_attr(cur,"name",str); faction = faction_get(str); if (faction != -1) /* Faction is valid. */ faction_stack[faction].player = xml_getFloat(cur); free(str); } } while (xml_nextNode(cur)); } } while (xml_nextNode(node)); return 0;}
开发者ID:ekrumme,项目名称:naev,代码行数:31,
示例3: faction_parseSocial/** * @brief Parses the social tidbits of a faction: allies and enemies. * * @param parent Node containing the faction. */static void faction_parseSocial( xmlNodePtr parent ){ xmlNodePtr node, cur; char *buf; Faction *base; int mod; int mem; buf = xml_nodeProp(parent,"name"); base = &faction_stack[faction_get(buf)]; free(buf); node = parent->xmlChildrenNode; do { /* Grab the allies */ if (xml_isNode(node,"allies")) { cur = node->xmlChildrenNode; mem = 0; do { if (xml_isNode(cur,"ally")) { mod = faction_get(xml_get(cur)); base->nallies++; if (base->nallies > mem) { mem += CHUNK_SIZE; base->allies = realloc(base->allies, sizeof(int)*mem); } base->allies[base->nallies-1] = mod; } } while (xml_nextNode(cur)); if (base->nallies > 0) base->allies = realloc(base->allies, sizeof(int)*base->nallies); } /* Grab the enemies */ if (xml_isNode(node,"enemies")) { cur = node->xmlChildrenNode; mem = 0; do { if (xml_isNode(cur,"enemy")) { mod = faction_get(xml_get(cur)); base->nenemies++; if (base->nenemies > mem) { mem += CHUNK_SIZE; base->enemies = realloc(base->enemies, sizeof(int)*mem); } base->enemies[base->nenemies-1] = mod; } } while (xml_nextNode(cur)); if (base->nenemies > 0) base->enemies = realloc(base->enemies, sizeof(int)*base->nenemies); } } while (xml_nextNode(node));}
开发者ID:Jazzkovsky,项目名称:naev,代码行数:61,
示例4: DTYPE_parse/** * @brief Parses an xml node containing a DTYPE. * * @param temp Address to load DTYPE into. * @param parent XML Node containing the DTYPE data. * @return 0 on success. */static int DTYPE_parse( DTYPE *temp, const xmlNodePtr parent ){ xmlNodePtr node; /* Clear data. */ memset( temp, 0, sizeof(DTYPE) ); /* Get the name (mallocs). */ temp->name = xml_nodeProp(parent,"name"); /* Extract the data. */ node = parent->xmlChildrenNode; do { xml_onlyNodes(node); xmlr_float(node, "shield", temp->sdam); xmlr_float(node, "armour", temp->adam); xmlr_float(node, "knockback", temp->knock); WARN("Unknown node of type '%s' in damage node '%s'.", node->name, temp->name); } while (xml_nextNode(node));#define MELEMENT(o,s) / if (o) WARN("DTYPE '%s' invalid '"s"' element", temp->name) /**< Define to help check for data errors. */ MELEMENT(temp->sdam<0.,"shield"); MELEMENT(temp->adam<0.,"armour"); MELEMENT(temp->knock<0.,"knockback");#undef MELEMENT return 0;}
开发者ID:GunioRobot,项目名称:naev,代码行数:38,
示例5: outfit_parseSMod/** * @brief Parses the modification tidbits of the outfit. * * @param temp Outfit to finish loading. * @param parent Outfit's parent node. */static void outfit_parseSMod( Outfit* temp, const xmlNodePtr parent ){ xmlNodePtr node; node = parent->children; do { /* load all the data */ /* movement */ xmlr_float(node,"thrust",temp->u.mod.thrust); xmlr_float(node,"turn",temp->u.mod.turn); xmlr_float(node,"speed",temp->u.mod.speed); /* health */ xmlr_float(node,"armour",temp->u.mod.armour); xmlr_float(node,"shield",temp->u.mod.shield); xmlr_float(node,"energy",temp->u.mod.energy); xmlr_float(node,"fuel",temp->u.mod.fuel); if (xml_isNode(node,"armour_regen")) temp->u.mod.armour_regen = xml_getFloat(node)/60.0; else if (xml_isNode(node,"shield_regen")) temp->u.mod.shield_regen = xml_getFloat(node)/60.0; else if (xml_isNode(node,"energy_regen")) temp->u.mod.energy_regen = xml_getFloat(node)/60.0; /* misc */ xmlr_int(node,"cargo",temp->u.mod.cargo); } while (xml_nextNode(node));}
开发者ID:pegue,项目名称:naev,代码行数:31,
示例6: commodity_parse/** * @brief Loads a commodity. * * @param temp Commodity to load data into. * @param parent XML node to load from. * @return Commodity loaded from parent. */static int commodity_parse( Commodity *temp, xmlNodePtr parent ){ xmlNodePtr node; /* Clear memory. */ memset( temp, 0, sizeof(Commodity) ); temp->name = (char*)xmlGetProp(parent,(xmlChar*)"name"); if (temp->name == NULL) WARN("Commodity from "COMMODITY_DATA" has invalid or no name"); node = parent->xmlChildrenNode; do { xmlr_strd(node, "description", temp->description); xmlr_int(node, "price", temp->price); } while (xml_nextNode(node));#if 0 /* shouldn't be needed atm */#define MELEMENT(o,s) if (o) WARN("Commodity '%s' missing '"s"' element", temp->name) MELEMENT(temp->description==NULL,"description"); MELEMENT(temp->high==0,"high"); MELEMENT(temp->medium==0,"medium"); MELEMENT(temp->low==0,"low");#undef MELEMENT#endif return 0;}
开发者ID:Arakash,项目名称:naev,代码行数:35,
示例7: claim_create/** * @brief Loads a claim. * * @param parent Parent node containing the claim data. * @return The system claim. */SysClaim_t *claim_xmlLoad( xmlNodePtr parent ){ SysClaim_t *claim; xmlNodePtr node; StarSystem *sys; /* Create the claim. */ claim = claim_create(); /* Load the nodes. */ node = parent->xmlChildrenNode; do { if (xml_isNode(node,"sys")) { sys = system_get( xml_get(node) ); if (sys != NULL) claim_add( claim, system_index(sys) ); else WARN("System Claim trying to load system '%s' which doesn't exist.", xml_get(node)); } } while (xml_nextNode(node)); /* Activate the claim. */ claim_activate( claim ); return claim;}
开发者ID:Anatolis,项目名称:naev,代码行数:32,
示例8: spfx_base_parse/** * @brief Parses an xml node containing a SPFX. * * @param temp Address to load SPFX into. * @param parent XML Node containing the SPFX data. * @return 0 on success. */static int spfx_base_parse( SPFX_Base *temp, const xmlNodePtr parent ){ xmlNodePtr node; /* Clear data. */ memset( temp, 0, sizeof(SPFX_Base) ); /* Get the name (mallocs). */ temp->name = xml_nodeProp(parent,"name"); /* Extract the data. */ node = parent->xmlChildrenNode; do { xmlr_float(node, "anim", temp->anim); xmlr_float(node, "ttl", temp->ttl); if (xml_isNode(node,"gfx")) temp->gfx = xml_parseTexture( node, SPFX_GFX_PRE"%s"SPFX_GFX_SUF, 6, 5, 0 ); } while (xml_nextNode(node)); /* Convert from ms to s. */ temp->anim /= 1000.; temp->ttl /= 1000.; if (temp->ttl == 0.) temp->ttl = temp->anim;#define MELEMENT(o,s) / if (o) WARN("SPFX '%s' missing/invalid '"s"' element", temp->name) /**< Define to help check for data errors. */ MELEMENT(temp->anim==0.,"anim"); MELEMENT(temp->ttl==0.,"ttl"); MELEMENT(temp->gfx==NULL,"gfx");#undef MELEMENT return 0;}
开发者ID:zid,项目名称:naev,代码行数:42,
示例9: commodity_load/** * @brief Loads all the commodity data. * * @return 0 on success. */int commodity_load (void){ uint32_t bufsize; char *buf; xmlNodePtr node; xmlDocPtr doc; /* Load the file. */ buf = ndata_read( COMMODITY_DATA, &bufsize); if (buf == NULL) return -1; /* Handle the XML. */ doc = xmlParseMemory( buf, bufsize ); if (doc == NULL) { WARN("'%s' is not valid XML.", COMMODITY_DATA); return -1; } node = doc->xmlChildrenNode; /* Commoditys node */ if (strcmp((char*)node->name,XML_COMMODITY_ID)) { ERR("Malformed "COMMODITY_DATA" file: missing root element '"XML_COMMODITY_ID"'"); return -1; } node = node->xmlChildrenNode; /* first faction node */ if (node == NULL) { ERR("Malformed "COMMODITY_DATA" file: does not contain elements"); return -1; } do { if (xml_isNode(node, XML_COMMODITY_TAG)) { /* Make room for commodity. */ commodity_stack = realloc(commodity_stack, sizeof(Commodity)*(++commodity_nstack)); /* Load commodity. */ commodity_parse(&commodity_stack[commodity_nstack-1], node); /* See if should get added to commodity list. */ if (commodity_stack[commodity_nstack-1].price > 0.) { econ_nprices++; econ_comm = realloc(econ_comm, econ_nprices * sizeof(int)); econ_comm[econ_nprices-1] = commodity_nstack-1; } } } while (xml_nextNode(node)); xmlFreeDoc(doc); free(buf); DEBUG("Loaded %d Commodit%s", commodity_nstack, (commodity_nstack==1) ? "y" : "ies" ); return 0;}
开发者ID:Arakash,项目名称:naev,代码行数:64,
示例10: dtype_load/** * @brief Loads the dtype stack. * * @return 0 on success. */int dtype_load (void){ int mem; uint32_t bufsize; char *buf; xmlNodePtr node; xmlDocPtr doc; /* Load and read the data. */ buf = ndata_read( DTYPE_DATA, &bufsize ); doc = xmlParseMemory( buf, bufsize ); /* Check to see if document exists. */ node = doc->xmlChildrenNode; if (!xml_isNode(node,DTYPE_XML_ID)) { ERR("Malformed '"DTYPE_DATA"' file: missing root element '"DTYPE_XML_ID"'"); return -1; } /* Check to see if is populated. */ node = node->xmlChildrenNode; /* first system node */ if (node == NULL) { ERR("Malformed '"DTYPE_DATA"' file: does not contain elements"); return -1; } /* Load up the individual damage types. */ mem = 0; do { xml_onlyNodes(node); if (!xml_isNode(node,DTYPE_XML_TAG)) { WARN("'"DTYPE_DATA"' has unknown node '%s'.", node->name); continue; } dtype_ntypes++; if (dtype_ntypes > mem) { if (mem == 0) mem = DTYPE_CHUNK_MIN; else mem *= 2; dtype_types = realloc(dtype_types, sizeof(DTYPE)*mem); } DTYPE_parse( &dtype_types[dtype_ntypes-1], node ); } while (xml_nextNode(node)); /* Shrink back to minimum - shouldn't change ever. */ dtype_types = realloc(dtype_types, sizeof(DTYPE) * dtype_ntypes); /* Clean up. */ xmlFreeDoc(doc); free(buf); return 0;}
开发者ID:GunioRobot,项目名称:naev,代码行数:61,
示例11: diff_apply/** * @brief Applies a diff to the universe. * * @param name Diff to apply. * @return 0 on success. */int diff_apply( const char *name ){ xmlNodePtr node; xmlDocPtr doc; size_t bufsize; char *buf; char *diffname; /* Check if already applied. */ if (diff_isApplied(name)) return 0; buf = ndata_read( DIFF_DATA_PATH, &bufsize ); doc = xmlParseMemory( buf, bufsize ); node = doc->xmlChildrenNode; if (strcmp((char*)node->name,"unidiffs")) { ERR(_("Malformed unidiff file: missing root element 'unidiffs'")); return 0; } node = node->xmlChildrenNode; /* first system node */ if (node == NULL) { ERR(_("Malformed unidiff file: does not contain elements")); return 0; } do { if (xml_isNode(node,"unidiff")) { /* Check to see if it's the diff we're looking for. */ xmlr_attr(node,"name",diffname); if (strcmp(diffname,name)==0) { /* Apply it. */ diff_patch( node ); /* Clean up. */ free(diffname); xmlFreeDoc(doc); free(buf); economy_execQueued(); return 0; } free(diffname); } } while (xml_nextNode(node)); /* More clean up. */ xmlFreeDoc(doc); free(buf); WARN(_("UniDiff '%s' not found in %s."), name, DIFF_DATA_PATH); return -1;}
开发者ID:naev,项目名称:naev,代码行数:61,
示例12: diff_load/** * @brief Loads the diffs. * * @param parent Parent node containing diffs. * @return 0 on success. */int diff_load( xmlNodePtr parent ){ xmlNodePtr node, cur; diff_clear(); node = parent->xmlChildrenNode; do { if (xml_isNode(node,"diffs")) { cur = node->xmlChildrenNode; do { if (xml_isNode(cur,"diff")) diff_apply( xml_get(cur) ); } while (xml_nextNode(cur)); } } while (xml_nextNode(node)); return 0;}
开发者ID:naev,项目名称:naev,代码行数:26,
示例13: spfx_load/** * @brief Loads the spfx stack. * * @return 0 on success. * * @todo Make spfx not hardcoded. */int spfx_load (void){ int mem; uint32_t bufsize; char *buf; xmlNodePtr node; xmlDocPtr doc; /* Load and read the data. */ buf = ndata_read( SPFX_DATA, &bufsize ); doc = xmlParseMemory( buf, bufsize ); /* Check to see if document exists. */ node = doc->xmlChildrenNode; if (!xml_isNode(node,SPFX_XML_ID)) { ERR("Malformed '"SPFX_DATA"' file: missing root element '"SPFX_XML_ID"'"); return -1; } /* Check to see if is populated. */ node = node->xmlChildrenNode; /* first system node */ if (node == NULL) { ERR("Malformed '"SPFX_DATA"' file: does not contain elements"); return -1; } /* First pass, loads up ammunition. */ mem = 0; do { if (xml_isNode(node,SPFX_XML_TAG)) { spfx_neffects++; if (spfx_neffects > mem) { mem += CHUNK_SIZE; spfx_effects = realloc(spfx_effects, sizeof(SPFX_Base)*mem); } spfx_base_parse( &spfx_effects[spfx_neffects-1], node ); } } while (xml_nextNode(node)); /* Shrink back to minimum - shouldn't change ever. */ spfx_effects = realloc(spfx_effects, sizeof(SPFX_Base) * spfx_neffects); /* Clean up. */ xmlFreeDoc(doc); free(buf); /* * Now initialize force feedback. */ spfx_hapticInit(); return 0;}
开发者ID:zid,项目名称:naev,代码行数:61,
示例14: missions_load/** * @brief Loads all the mission data. * * @return 0 on success. */int missions_load (void){ int i, m; uint32_t bufsize; char *buf; for (i=0; i<MISSION_MAX; i++) player_missions[i] = calloc(1, sizeof(Mission)); buf = ndata_read( MISSION_DATA_PATH, &bufsize ); xmlNodePtr node; xmlDocPtr doc = xmlParseMemory( buf, bufsize ); node = doc->xmlChildrenNode; if (!xml_isNode(node,XML_MISSION_ID)) { ERR("Malformed '"MISSION_DATA_PATH"' file: missing root element '"XML_MISSION_ID"'"); return -1; } node = node->xmlChildrenNode; /* first mission node */ if (node == NULL) { ERR("Malformed '"MISSION_DATA_PATH"' file: does not contain elements"); return -1; } m = 0; do { if (xml_isNode(node,XML_MISSION_TAG)) { /* See if must grow. */ mission_nstack++; if (mission_nstack > m) { m += MISSION_CHUNK; mission_stack = realloc(mission_stack, sizeof(MissionData)*m); } /* Load it. */ mission_parse( &mission_stack[mission_nstack-1], node ); } } while (xml_nextNode(node)); /* Shrink to minimum. */ mission_stack = realloc(mission_stack, sizeof(MissionData)*mission_nstack); /* Clean up. */ xmlFreeDoc(doc); free(buf); DEBUG("Loaded %d Mission%s", mission_nstack, (mission_nstack==1) ? "" : "s" ); return 0;}
开发者ID:SiliconTally,项目名称:naev,代码行数:58,
示例15: outfit_parseSMap/** * @brief Parses the map tidbits of the outfit. * * @param temp Outfit to finish loading. * @param parent Outfit's parent node. */static void outfit_parseSMap( Outfit *temp, const xmlNodePtr parent ){ xmlNodePtr node; node = parent->children; do { xmlr_int(node,"radius",temp->u.map.radius); } while (xml_nextNode(node)); if (temp->u.map.radius==0) WARN("Outfit '%s' missing/invalid 'radius' element", temp->name);}
开发者ID:pegue,项目名称:naev,代码行数:18,
示例16: outfit_load/** * @brief Loads all the outfits. * * @return 0 on success. */int outfit_load (void){ int i, mem; uint32_t bufsize; char *buf = ndata_read( OUTFIT_DATA, &bufsize ); xmlNodePtr node; xmlDocPtr doc = xmlParseMemory( buf, bufsize ); node = doc->xmlChildrenNode; if (!xml_isNode(node,XML_OUTFIT_ID)) { ERR("Malformed '"OUTFIT_DATA"' file: missing root element '"XML_OUTFIT_ID"'"); return -1; } node = node->xmlChildrenNode; /* first system node */ if (node == NULL) { ERR("Malformed '"OUTFIT_DATA"' file: does not contain elements"); return -1; } /* First pass, loads up ammunition. */ mem = 0; do { if (xml_isNode(node,XML_OUTFIT_TAG)) { outfit_nstack++; if (outfit_nstack > mem) { mem += CHUNK_SIZE; outfit_stack = realloc(outfit_stack, sizeof(Outfit)*mem); } outfit_parse( &outfit_stack[outfit_nstack-1], node ); } } while (xml_nextNode(node)); /* Shrink back to minimum - shouldn't change ever. */ outfit_stack = realloc(outfit_stack, sizeof(Outfit) * outfit_nstack); /* Second pass, sets up ammunition relationships. */ for (i=0; i<outfit_nstack; i++) { if (outfit_isLauncher(&outfit_stack[i])) outfit_stack[i].u.lau.ammo = outfit_get( outfit_stack[i].u.lau.ammo_name ); else if (outfit_isFighterBay(&outfit_stack[i])) outfit_stack[i].u.bay.ammo = outfit_get( outfit_stack[i].u.bay.ammo_name ); } xmlFreeDoc(doc); free(buf); DEBUG("Loaded %d Outfit%s", outfit_nstack, (outfit_nstack==1) ? "" : "s" ); return 0;}
开发者ID:pegue,项目名称:naev,代码行数:57,
示例17: outfit_parseSFighter/** * @brief Parses the fighter tidbits of the outfit. * * @param temp Outfit to finish loading. * @param parent Outfit's parent node. */static void outfit_parseSFighter( Outfit *temp, const xmlNodePtr parent ){ xmlNodePtr node; node = parent->children; do { xmlr_strd(node,"ship",temp->u.fig.ship); } while (xml_nextNode(node));#define MELEMENT(o,s) /if (o) WARN("Outfit '%s' missing/invalid '"s"' element", temp->name)/**< Define to help check for data errors. */ MELEMENT(temp->u.fig.ship==NULL,"ship");#undef MELEMENT}
开发者ID:pegue,项目名称:naev,代码行数:21,
示例18: missions_loadActive/** * @brief Loads the player's active missions from a save. * * @param parent Node containing the player's active missions. * @return 0 on success. */int missions_loadActive( xmlNodePtr parent ){ xmlNodePtr node; /* cleanup old missions */ missions_cleanup(); node = parent->xmlChildrenNode; do { if (xml_isNode(node,"missions")) if (missions_parseActive( node ) < 0) return -1; } while (xml_nextNode(node)); return 0;}
开发者ID:SiliconTally,项目名称:naev,代码行数:21,
示例19: faction_parse/** * @brief Parses a single faction, but doesn't set the allies/enemies bit. * * @param temp Faction to load data into. * @param parent Parent node to extract faction from. * @return Faction created from parent node. */static int faction_parse( Faction* temp, xmlNodePtr parent ){ xmlNodePtr node; int player; char buf[PATH_MAX]; /* Clear memory. */ memset( temp, 0, sizeof(Faction) ); temp->name = xml_nodeProp(parent,"name"); if (temp->name == NULL) WARN("Faction from "FACTION_DATA" has invalid or no name"); player = 0; node = parent->xmlChildrenNode; do { /* Can be 0 or negative, so we have to take that into account. */ if (xml_isNode(node,"player")) { temp->player_def = xml_getFloat(node); player = 1; continue; } xmlr_strd(node,"longname",temp->longname); if (xml_isNode(node, "colour")) temp->colour = col_fromName(xml_raw(node)); if (xml_isNode(node,"logo")) { snprintf( buf, PATH_MAX, FACTION_LOGO_PATH"%s_small.png", xml_get(node)); temp->logo_small = gl_newImage(buf, 0); continue; } if (xml_isNode(node,"static")) { faction_setFlag(temp, FACTION_STATIC); continue; } if (xml_isNode(node,"invisible")) { faction_setFlag(temp, FACTION_INVISIBLE); continue; } } while (xml_nextNode(node)); if (player==0) DEBUG("Faction '%s' missing player tag.", temp->name); return 0;}
开发者ID:ekrumme,项目名称:naev,代码行数:55,
示例20: outfit_parseSLauncher/** * @brief Parses the specific area for a launcher and loads it into Outfit. * * @param temp Outfit to finish loading. * @param parent Outfit's parent node. */static void outfit_parseSLauncher( Outfit* temp, const xmlNodePtr parent ){ xmlNodePtr node; node = parent->xmlChildrenNode; do { /* load all the data */ xmlr_int(node,"delay",temp->u.lau.delay); xmlr_strd(node,"ammo",temp->u.lau.ammo_name); } while (xml_nextNode(node));#define MELEMENT(o,s) /if (o) WARN("Outfit '%s' missing '"s"' element", temp->name) /**< Define to help check for data errors. */ MELEMENT(temp->u.lau.ammo_name==NULL,"ammo"); MELEMENT(temp->u.lau.delay==0,"delay");#undef MELEMENT}
开发者ID:pegue,项目名称:naev,代码行数:22,
示例21: outfit_parseSFighterBay/** * @brief Parses the fighter bay tidbits of the outfit. * * @param temp Outfit to finish loading. * @param parent Outfit's parent node. */static void outfit_parseSFighterBay( Outfit *temp, const xmlNodePtr parent ){ xmlNodePtr node; node = parent->children; do { xmlr_int(node,"delay",temp->u.bay.delay); xmlr_strd(node,"ammo",temp->u.bay.ammo_name); } while (xml_nextNode(node));#define MELEMENT(o,s) /if (o) WARN("Outfit '%s' missing/invalid '"s"' element", temp->name) /**< Define to help check for data errors. */ MELEMENT(temp->u.bay.delay==0,"delay"); MELEMENT(temp->u.bay.ammo_name==NULL,"ammo");#undef MELEMENT}
开发者ID:pegue,项目名称:naev,代码行数:22,
示例22: fleet_loadFleets/** * @brief Loads all the fleets. * * @return 0 on success. */static int fleet_loadFleets (void){ int mem; uint32_t bufsize; char *buf; xmlNodePtr node; xmlDocPtr doc; /* Load the data. */ buf = ndata_read( FLEET_DATA, &bufsize); doc = xmlParseMemory( buf, bufsize ); node = doc->xmlChildrenNode; /* fleets node */ if (strcmp((char*)node->name,"Fleets")) { ERR("Malformed "FLEET_DATA" file: missing root element 'Fleets'."); return -1; } node = node->xmlChildrenNode; /* first fleet node */ if (node == NULL) { ERR("Malformed "FLEET_DATA" file: does not contain elements."); return -1; } mem = 0; do { if (xml_isNode(node,"fleet")) { /* See if memory must grow. */ nfleets++; if (nfleets > mem) { mem += CHUNK_SIZE; fleet_stack = realloc(fleet_stack, sizeof(Fleet) * mem); } /* Load the fleet. */ fleet_parse( &fleet_stack[nfleets-1], node ); } } while (xml_nextNode(node)); /* Shrink to minimum. */ fleet_stack = realloc(fleet_stack, sizeof(Fleet) * nfleets); xmlFreeDoc(doc); free(buf); return 0;}
开发者ID:Dinth,项目名称:naev,代码行数:51,
示例23: diff_patchAsset/** * @brief Patches a asset. * * @param diff Diff that is doing the patching. * @param node Node containing the asset. * @return 0 on success. */static int diff_patchAsset( UniDiff_t *diff, xmlNodePtr node ){ UniHunk_t base, hunk; xmlNodePtr cur; /* Set the target. */ memset(&base, 0, sizeof(UniHunk_t)); base.target.type = HUNK_TARGET_ASSET; xmlr_attr(node,"name",base.target.u.name); if (base.target.u.name==NULL) { WARN(_("Unidiff '%s' has an target node without a 'name' tag"), diff->name); return -1; } /* Now parse the possible changes. */ cur = node->xmlChildrenNode; do { xml_onlyNodes(cur); if (xml_isNode(cur,"faction")) { hunk.target.type = base.target.type; hunk.target.u.name = strdup(base.target.u.name); /* Outfit type is constant. */ hunk.type = HUNK_TYPE_ASSET_FACTION; /* Get the data. */ hunk.u.name = xml_getStrd(cur); /* Apply diff. */ if (diff_patchHunk( &hunk ) < 0) diff_hunkFailed( diff, &hunk ); else diff_hunkSuccess( diff, &hunk ); continue; } WARN(_("Unidiff '%s' has unknown node '%s'."), diff->name, node->name); } while (xml_nextNode(cur)); /* Clean up some stuff. */ free(base.target.u.name); base.target.u.name = NULL; return 0;}
开发者ID:naev,项目名称:naev,代码行数:51,
示例24: outfit_parseSJammer/** * @brief Parses the jammer tidbits of the outfit. * * @param temp Outfit to finish loading. * @param parent Outfit's parent node. */static void outfit_parseSJammer( Outfit *temp, const xmlNodePtr parent ){ xmlNodePtr node; node = parent->children; do { xmlr_float(node,"range",temp->u.jam.range); xmlr_float(node,"chance",temp->u.jam.chance); xmlr_float(node,"energy",temp->u.jam.energy); } while (xml_nextNode(node)); temp->u.jam.chance /= 100.; /* Put in per one, instead of percent */ temp->u.jam.energy /= 60.; /* It's per minute */#define MELEMENT(o,s) /if (o) WARN("Outfit '%s' missing/invalid '"s"' element", temp->name) /**< Define to help check for data errors. */ MELEMENT(temp->u.jam.range==0.,"range"); MELEMENT(temp->u.jam.chance==0.,"chance");#undef MELEMENT}
开发者ID:pegue,项目名称:naev,代码行数:26,
示例25: outfit_parseSAfterburner/** * @brief Parses the afterburner tidbits of the outfit. * * @param temp Outfit to finish loading. * @param parent Outfit's parent node. */static void outfit_parseSAfterburner( Outfit* temp, const xmlNodePtr parent ){ xmlNodePtr node; node = parent->children; /* must be >= 1. */ temp->u.afb.thrust_perc = 1.; temp->u.afb.speed_perc = 1.; do { /* parse the data */ xmlr_float(node,"rumble",temp->u.afb.rumble); if (xml_isNode(node,"sound")) temp->u.afb.sound = sound_get( xml_get(node) ); if (xml_isNode(node,"thrust_perc")) temp->u.afb.thrust_perc = 1. + xml_getFloat(node)/100.; xmlr_float(node,"thrust_abs",temp->u.afb.thrust_abs); if (xml_isNode(node,"speed_perc")) temp->u.afb.speed_perc = 1. + xml_getFloat(node)/100.; xmlr_float(node,"speed_abs",temp->u.afb.speed_abs); xmlr_float(node,"energy",temp->u.afb.energy); } while (xml_nextNode(node));}
开发者ID:pegue,项目名称:naev,代码行数:29,
示例26: events_load/** * @brief Loads all the events. * * @return 0 on success. */int events_load (void){ int m; uint32_t bufsize; char *buf; xmlNodePtr node; xmlDocPtr doc; /* Load the data. */ buf = ndata_read( EVENT_DATA, &bufsize ); if (buf == NULL) { WARN("Unable to read data from '%s'", EVENT_DATA); return -1; } /* Load the document. */ doc = xmlParseMemory( buf, bufsize ); if (doc == NULL) { WARN("Unable to parse document '%s'", EVENT_DATA); return -1; } /* Get the root node. */ node = doc->xmlChildrenNode; if (!xml_isNode(node,XML_EVENT_ID)) { WARN("Malformed '"EVENT_DATA"' file: missing root element '"XML_EVENT_ID"'"); return -1; } /* Get the first node. */ node = node->xmlChildrenNode; /* first mission node */ if (node == NULL) { WARN("Malformed '"EVENT_DATA"' file: does not contain elements"); return -1; } m = 0; do { if (xml_isNode(node,XML_EVENT_TAG)) { /* See if must grow. */ event_ndata++; if (event_ndata > m) { m += EVENT_CHUNK; event_data = realloc(event_data, sizeof(EventData_t)*m); } /* Load it. */ event_parse( &event_data[event_ndata-1], node ); } } while (xml_nextNode(node)); /* Shrink to minimum. */ event_data = realloc(event_data, sizeof(EventData_t)*event_ndata); /* Clean up. */ xmlFreeDoc(doc); free(buf); DEBUG("Loaded %d Event%s", event_ndata, (event_ndata==1) ? "" : "s" ); return 0;}
开发者ID:Arakash,项目名称:naev,代码行数:68,
注:本文中的xml_nextNode函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ xmlnode_free函数代码示例 C++ xml_isNode函数代码示例 |