本文整理汇总了C++中xml_node::children方法的典型用法代码示例。如果您正苦于以下问题:C++ xml_node::children方法的具体用法?C++ xml_node::children怎么用?C++ xml_node::children使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xml_node
的用法示例。
在下文中一共展示了xml_node::children方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: switch
void Editor_Html2Usfm::processNode (xml_node node)
{
switch (node.type ()) {
case node_element:
{
openElementNode (node);
for (xml_node child : node.children()) {
processNode (child);
}
closeElementNode (node);
break;
}
case node_pcdata:
{
// Add the text to the current USFM line.
string text = node.text ().get ();
currentLine += text;
break;
}
default:
{
string nodename = node.name ();
Database_Logs::log ("Unknown XML node " + nodename + " while saving editor text");
break;
}
}
}
示例3: 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));
}
}
示例4: related_logic_search_related
// Internal function that searches related passages in the XML DOM.
void related_logic_search_related (const string & bookname, int input_chapter, const string & input_verse,
const xml_node & node, vector <int> & passages)
{
for (xml_node set : node.children ()) {
bool match = false;
for (xml_node reference : set.children ()) {
// If a match was found, skip further processing.
if (match) continue;
// Match on book.
string book = reference.attribute ("book").value ();
match = (book == bookname);
// Match on chapter.
if (match) {
int chapter = convert_to_int (reference.attribute ("chapter").value ());
match = (chapter == input_chapter);
}
// Match on verse(s).
if (match) {
string verse = reference.attribute ("verse").value ();
vector <int> verses;
if (usfm_handle_verse_range (verse, verses)) {
match = in_array (convert_to_int (input_verse), verses);
} else {
match = (verse == input_verse);
}
}
// Store all related passages.
if (match) {
for (xml_node reference : set.children ()) {
string bookname = reference.attribute ("book").value ();
int book = Database_Books::getIdFromEnglish (bookname);
int chapter = convert_to_int (reference.attribute ("chapter").value ());
string verse = reference.attribute ("verse").value ();
vector <int> verses;
if (usfm_handle_verse_range (verse, verses));
else verses.push_back (convert_to_int (verse));
for (auto verse : verses) {
if (book && chapter) {
Passage passage ("", book, chapter, convert_to_string (verse));
int i = filter_passage_to_integer (passage);
// No duplicate passages to be included.
if (!in_array (i, passages)) {
passages.push_back (i);
}
}
}
}
}
}
}
}
示例5: LoadFromXml
void Settings::LoadFromXml(xml_node& node) {
settings = map<string, Setting>();
for (auto settingNode : node.children("setting")) {
auto set = Setting();
set.LoadFromXml(settingNode);
settings[set.name] = set;
}
}
示例6: 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;
}
示例7:
// Retrieves a pointer to a relevant footnote element in the XML.
// Sample footnote element:
// <a href="#citation1" id="note1">x</a>
xml_node Editor_Html2Usfm::get_note_pointer (xml_node node, string id)
{
if (node) {
string name = node.name ();
if (name == "a") {
string note_id = node.attribute ("id").value ();
if (id == note_id) return node;
}
for (xml_node child : node.children ()) {
xml_node note = get_note_pointer (child, id);
if (note) return note;
}
}
xml_node null_node;
return null_node;
}