本文整理汇总了C++中pugi::xml_node::child方法的典型用法代码示例。如果您正苦于以下问题:C++ xml_node::child方法的具体用法?C++ xml_node::child怎么用?C++ xml_node::child使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pugi::xml_node
的用法示例。
在下文中一共展示了xml_node::child方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void tmx::Tileset::init(pugi::xml_node tilesetNode) {
setFirstGid(tilesetNode.attribute("firstgid").as_int());
setSource(tilesetNode.attribute("source").as_string());
setName(tilesetNode.attribute("name").as_string());
setTileWidth(tilesetNode.attribute("tilewidth").as_uint());
setTileHeight(tilesetNode.attribute("tileheight").as_uint());
setSpacing(tilesetNode.attribute("spacing").as_uint());
setMargin(tilesetNode.attribute("margin").as_uint());
for(pugi::xml_node prop = tilesetNode.child("properties").first_child(); prop; prop = prop.next_sibling()) {
mProperties.insert(std::pair<std::string, std::string>(prop.attribute("name").as_string(), prop.attribute("value").as_string()));
}
mTileOffset.init(tilesetNode.child("tileoffset"));
mImage.init(tilesetNode.child("image"));
mTerrainTypes.init(tilesetNode.child("terraintypes"));
for(pugi::xml_node tile = tilesetNode.child("tile"); tile; tile = tile.next_sibling("tile")) {
tmx::Tile tempTile;
tempTile.setID(tile.attribute("id").as_uint());
tempTile.setTerrain(tile.attribute("terrain").as_string());
mTile.push_back(tempTile);
}
}
示例2:
// Called before render is available
bool j1Render::Awake(pugi::xml_node& config)
{
LOG("Create SDL rendering context");
bool ret = true;
// load flags
Uint32 flags = SDL_RENDERER_ACCELERATED;
if(config.child("vsync").attribute("value").as_bool(true) == true)
{
flags |= SDL_RENDERER_PRESENTVSYNC;
LOG("Using vsync");
}
renderer = SDL_CreateRenderer(App->win->window, -1, flags);
if(renderer == NULL)
{
LOG("Could not create the renderer! SDL_Error: %s\n", SDL_GetError());
ret = false;
}
else
{
camera.w = App->win->screen_surface->w;
camera.h = App->win->screen_surface->h;
camera.x = config.child("cam").attribute("x").as_int(0);
camera.y = config.child("cam").attribute("y").as_int(0);
}
return ret;
}
示例3: awake
// Called before render is available
bool Fonts::awake(pugi::xml_node& conf)
{
LOG("Init True Type Font library");
bool ret = true;
if (TTF_Init() == -1)
{
LOG("SDL_ttf could not initialize! SDL_ttf Error: %s\n", TTF_GetError());
ret = false;
}
else
{
const char* path = conf.child("default_font").attribute("file").as_string(DEFAULT_FONT);
int size = conf.child("default_font").attribute("size").as_int(DEFAULT_FONT_SIZE);
default = load(path, size);
pugi::xml_node node = conf.child("default_font");
node = node.next_sibling("default_font");
const char* path2 = node.attribute("file").as_string(DEFAULT_FONT);
int size2 = node.attribute("size").as_int(DEFAULT_FONT_SIZE);
default_2 = load(path2, size2);
}
return ret;
}
示例4: Load
bool Animation::Load(const pugi::xml_node& node)
{
Reset();
if (strcmp(node.name(), "animation"))
return false;
id_ = node.attribute("id").as_int();
name_ = node.attribute("name").as_string();
length_ = node.attribute("length").as_float() * 0.001f;
looping_ = node.attribute("looping").as_bool(true);
xml_node mainlineNode = node.child("mainline");
for (xml_node keyNode = mainlineNode.child("key"); !keyNode.empty(); keyNode = keyNode.next_sibling("key"))
{
mainlineKeys_.Push(new MainlineKey());
if (!mainlineKeys_.Back()->Load(keyNode))
return false;
}
for (xml_node timelineNode = node.child("timeline"); !timelineNode.empty(); timelineNode = timelineNode.next_sibling("timeline"))
{
timelines_.Push(new Timeline());
if (!timelines_.Back()->Load(timelineNode))
return false;
}
return true;
}
示例5: CreateChildren
BOOL STreeList::CreateChildren(pugi::xml_node xmlNode)
{
pugi::xml_node xmlHeader = xmlNode.child(L"headerstyle");
pugi::xml_node xmlTreectrl = xmlNode.child(L"treectrlstyle");
if(!xmlHeader || !xmlTreectrl)
return FALSE;
m_pHeader = CreateHeader();
InsertChild(m_pHeader);
m_pHeader->InitFromXml(xmlHeader);
m_pHeader->GetEventSet()->subscribeEvent(EventHeaderItemChanging::EventID, Subscriber(&STreeList::OnHeaderSizeChanging,this));
m_pHeader->GetEventSet()->subscribeEvent(EventHeaderItemSwap::EventID, Subscriber(&STreeList::OnHeaderSwap,this));
m_pTreeCtrl = CreateMcTreeCtrl();
InsertChild(m_pTreeCtrl);
m_pTreeCtrl->InitFromXml(xmlTreectrl);
m_pTreeCtrl->GetEventSet()->subscribeEvent(EventScroll::EventID,Subscriber(&STreeList::OnScrollEvent,this));
m_pHeader->InsertItem(0,m_strTreeLabel,m_pTreeCtrl->m_nTreeWidth,ST_NULL,0);
for(int i=1;i<m_pHeader->GetItemCount();i++)
{
int nWid = m_pHeader->GetItemWidth(i);
m_pTreeCtrl->InsertColumn(i-1,nWid);
}
return TRUE;
}
示例6: parse_predicates
void parse_predicates(pugi::xml_node node, config::config & conf) {
size_t size = node.child("size").text().as_uint();
//cout << "predicates size: " << size << endl;
conf.predicates.resize(size);
conf.predicate_distribution = parse_distribution(node.child("distribution"));
for (pugi::xml_node alias_node : node.children("alias")) {
size_t id = alias_node.attribute("symbol").as_uint();//
string name = alias_node.text().get();
//cout << "alias " << id << ", " << name << endl;
if (id < 0 || id >= size) {
cerr << "id " << id << " is out of range" << endl;
continue;
}
conf.predicates[id].alias = name;
}
for (pugi::xml_node proportion_node : node.children("proportion")) {
size_t id = proportion_node.attribute("symbol").as_uint();
double proportion = proportion_node.text().as_double();
if (id < 0 || id >= size) {
cerr << "id " << id << " is out of range" << endl;
continue;
}
conf.predicates[id].proportion = proportion;
conf.predicates[id].size = (size_t) (proportion * conf.nb_edges);
}
}
示例7:
//Load/Save
bool j1Render::Load(pugi::xml_node& state)
{
camera.x = state.child("camera").attribute("width").as_int();
camera.y = state.child("camera").attribute("height").as_int();
return true;
}
示例8: _configure
void IDMEFExporter::_configure(const pugi::xml_node& n)
{
// Closes the export method if any
close_export_method();
// XML configuration
pugi::xml_node export_node = n.child("export");
pugi::xml_node file_node = n.child("file");
if (export_node)
{
m_export_method = EXP_TCP;
if (!export_node.attribute("host") || !export_node.attribute("port"))
throw std::runtime_error("Export specification incomplete");
std::string host = export_node.attribute("host").value();
m_host = inet_addr(host.c_str());
m_port = std::atoi(export_node.attribute("port").value());
}
else if (file_node)
{
m_export_method = EXP_FILE;
if (!file_node.attribute("name"))
throw std::runtime_error("File specification missing name");
m_filename = file_node.attribute("name").value();
}
else
{
throw std::runtime_error("No output specified");
}
// Opens the export method
open_export_method();
}
示例9: LoadRace
//Создаем новый _род_ и распихиваем по его полям значения из файла
void LoadRace(pugi::xml_node RaceNode, PlayerKinPtr KinPtr)
{
pugi::xml_node CurNode;
PlayerRacePtr TmpRace(new PlayerRace);
TmpRace->SetRaceNum(RaceNode.attribute("racenum").as_int());
TmpRace->SetEnabledFlag(RaceNode.attribute("enabled").as_bool());
TmpRace->SetRaceMenuStr(RaceNode.child("menu").child_value());
CurNode = RaceNode.child("racename");
TmpRace->SetRaceItName(CurNode.child("itname").child_value());
TmpRace->SetRaceHeName(CurNode.child("hename").child_value());
TmpRace->SetRaceSheName(CurNode.child("shename").child_value());
TmpRace->SetRacePluralName(CurNode.child("pluralname").child_value());
//Add race features
for (CurNode = RaceNode.child("feature"); CurNode; CurNode = CurNode.next_sibling("feature"))
{
TmpRace->AddRaceFeature(CurNode.attribute("featnum").as_int());
}
//Добавляем родовые места "появления на свет" новых персонажей
for (CurNode = RaceNode.child("birthplace"); CurNode; CurNode = CurNode.next_sibling("birthplace"))
{
TmpRace->AddRaceBirthPlace(CurNode.attribute("id").as_int());
}
//Add new race in list
KinPtr->PlayerRaceList.push_back(TmpRace);
}
示例10: initialize
void ViewTransform::initialize(pugi::xml_node node)
{
pugi::xml_text txt;
txt = node.child("FieldOfView").text();
if (txt)
m_fov = txt.as_float();
txt = node.child("Angle").text();
if (txt)
m_angle = txt.as_float();
pugi::xml_node coordinates_node = node.child("Coordinates");
txt = coordinates_node.child("x").text();
if (txt)
m_position.x = txt.as_float();
txt = coordinates_node.child("y").text();
if (txt)
m_position.y = txt.as_float();
txt = coordinates_node.child("z").text();
if (txt)
m_position.z = txt.as_float();
m_view_matrix = glm::rotate(m_view_matrix,glm::radians(m_angle),glm::vec3(1,0,0));
m_view_matrix = glm::translate(m_view_matrix, glm::vec3(m_position.x,m_position.y,m_position.z));
m_projection_matrix = glm::perspective(glm::radians(m_fov), m_viewport.x/m_viewport.y, 1.f, 1000.f);
示例11: initialize
void PhysicsManager::initialize(pugi::xml_node node)
{
m_next_update = g_app->getCurrentTime();
if (!node)
return;
pugi::xml_text txt;
txt = node.child("UpdatePerSecond").text();
if (txt)
m_timestep = 1.f/(txt.as_float());
pugi::xml_node iterations = node.child("Iterations");
txt = iterations.child("Velocity").text();
if (txt)
m_velocity_iterations = txt.as_uint();
txt = iterations.child("Position").text();
if (txt)
m_position_iterations = txt.as_uint();
txt = node.child("PixelPhysicsRatio").text();
if (txt)
m_pixel_physics_ratio = txt.as_float();
}
示例12: parse_distribution
distribution parse_distribution(pugi::xml_node node) {
distribution dist;
if (!node.empty()) {
string type = node.attribute("type").value();
if (type == "uniform") {
size_t min = node.child("min").text().as_uint();
size_t max = node.child("max").text().as_uint();
dist.type = DISTRIBUTION::UNIFORM;
dist.arg1 = min;
dist.arg2 = max;
} else if (type == "zipfian") {
size_t n = node.child("n").text().as_uint();
double alpha = node.child("alpha").text().as_double();
dist.type = DISTRIBUTION::ZIPFIAN;
dist.arg1 = n;
dist.arg2 = alpha;
} else if (type == "normal" or type == "gaussian") {
double mean = node.child("mu").text().as_double();
double stddev = node.child("sigma").text().as_double();
dist.type = DISTRIBUTION::NORMAL;
dist.arg1 = mean;
dist.arg2 = stddev;
}
}
return dist;
}
示例13: LoadKin
//Создаем новую расу и заполняем ее поля значениями из файлда
void LoadKin(pugi::xml_node KinNode)
{
pugi::xml_node CurNode;
PlayerKinPtr TmpKin(new PlayerKin);
//Parse kin's parameters
TmpKin->KinNum = KinNode.attribute("kinnum").as_int();
TmpKin->Enabled = KinNode.attribute("enabled").as_bool();
CurNode = KinNode.child("menu");
TmpKin->KinMenuStr = CurNode.child_value();
CurNode = KinNode.child("kinname");
TmpKin->KinItName = CurNode.child("itname").child_value();
TmpKin->KinHeName = CurNode.child("hename").child_value();
TmpKin->KinSheName = CurNode.child("shename").child_value();
TmpKin->KinPluralName = CurNode.child("pluralname").child_value();
//Parce kin races
CurNode = KinNode.child("kinraces");
for (CurNode = CurNode.child("race"); CurNode; CurNode = CurNode.next_sibling("race"))
{
LoadRace(CurNode, TmpKin);
}
//Add new kin in kin list
PlayerRace::PlayerKinList.push_back(TmpKin);
}
示例14: parseDispersion
void Init::parseDispersion(const pugi::xml_node &node)
{
cout << "Dispersion:" << endl;
string filename = node.child_value("filename");
string filetype = node.child_value("filetype");
SpinWaveDispersion Dispersion;
Dispersion.setFilename(filename);
SpinWaveDispersion::Options PrintOptions;
string temp;
bool value;
temp = node.child("filetype").child_value("printposition");
value = boost::lexical_cast<bool, std::string>(temp);
PrintOptions = SpinWaveDispersion::Options::PrintPosition;
cout << "print position: "<< value << endl;
Dispersion.setOptions(PrintOptions,value);
temp = node.child("filetype").child_value("printfrequency");
value = boost::lexical_cast<bool, std::string>(temp);
PrintOptions = SpinWaveDispersion::Options::PrintFrequency;
cout << "print frequency: "<< value << endl;
Dispersion.setOptions(PrintOptions,value);
temp = node.child("filetype").child_value("printintensity");
value = boost::lexical_cast<bool, std::string>(temp);
PrintOptions = SpinWaveDispersion::Options::PrintIntensity;
cout << "print intensity: "<< value << endl;
Dispersion.setOptions(PrintOptions,value);
pugi::xml_node lines = node.child("lines");
for (pugi::xml_node group = lines.child("group");group; group = group.next_sibling("group"))
{
double x0,y0,z0,x1,y1,z1,NumberPoints;
NumberPoints = stringToDouble(group.child_value("numberpoints"));
x0 = stringToDouble(group.child("firstpoint").child_value("x"));
y0 = stringToDouble(group.child("firstpoint").child_value("y"));
z0 = stringToDouble(group.child("firstpoint").child_value("z"));
x1 = stringToDouble(group.child("lastpoint").child_value("x"));
y1 = stringToDouble(group.child("lastpoint").child_value("y"));
z1 = stringToDouble(group.child("lastpoint").child_value("z"));
cout << x0 << " " << y0 << " " << z0 << " " << x1 << " " << y1 << " " << z1 << endl;
PointsAlongLine Line;
Line.setFirstPoint(x0,y0,z0);
Line.setFinalPoint(x1,y1,z1);
Line.setNumberPoints(NumberPoints);
Dispersion.setPoints(Line.getPoints());
}
Dispersion.setGenie(builder.createElement());
Dispersion.save();
}
示例15:
eIG::eIG(pugi::xml_node& node) {
//RouteID
this->RouteID = node.child("RouteID").text().as_int();
//TerrainName
this->TerrainName = node.child("TerrainName").text().as_string();
//FeatureID
this->FeatureID = node.child("FeatureID").text().as_int();
}