本文整理汇总了C++中node::NodeList::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeList::begin方法的具体用法?C++ NodeList::begin怎么用?C++ NodeList::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类node::NodeList
的用法示例。
在下文中一共展示了NodeList::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse_file
void parse_file( bool do_html, istream& input_stream, ostream& output_stream )
{
DomParser parser;
parser.set_substitute_entities( true );
parser.parse_stream( input_stream );
if ( parser )
{
/* if succesfull create output */
const Element * rootNode = parser.get_document()->get_root_node();
if ( rootNode == NULL )
{
throw runtime_error( "get_root_node() failed" );
}
OutputBuilder* b;
if ( do_html )
{
b = new HtmlBuilder( output_stream );
} else
{
b = new LatexBuilder( output_stream );
}
/* do stuff */
{
const Element & root_in = dynamic_cast<const Element &>( *rootNode );
if ( root_in.get_name() != "document" )
{
throw runtime_error( "root node must be document" );
}
OutputState * s = b->create_root();
Node::NodeList list = root_in.get_children();
for ( Node::NodeList::iterator iter = list.begin(); iter != list.end(); ++iter )
{
if ( *iter != NULL )
{
parse_node( **iter, * s );
}
}
s->finish();
delete s;
}
delete b;
}
}
示例2: loadLabels
bool PinotSettings::loadLabels(const Element *pElem)
{
if (pElem == NULL)
{
return false;
}
Node::NodeList childNodes = pElem->get_children();
if (childNodes.empty() == true)
{
return false;
}
// Load the label's properties
for (Node::NodeList::iterator iter = childNodes.begin(); iter != childNodes.end(); ++iter)
{
Node *pNode = (*iter);
Element *pElem = dynamic_cast<Element*>(pNode);
if (pElem == NULL)
{
continue;
}
string nodeName = pElem->get_name();
string nodeContent = getElementContent(pElem);
if (nodeName == "name")
{
m_labels.insert(nodeContent);
}
// Labels used to have colours...
}
return true;
}
示例3: fromXML
void CharacterList::fromXML(const xmlpp::Element &root)
{
using namespace xmlpp;
clear();
Node::NodeList node = root.get_children("character");
for (Node::NodeList::const_iterator it = node.begin(); it != node.end(); it++)
{
Element *elem = dynamic_cast<Element*>(*it);
string name;
Attribute *attr = elem->get_attribute("name");
if (attr != NULL)
{
name = attr->get_value();
}
string playerName="";
attr = elem->get_attribute("playername");
if (attr != NULL)
{
playerName = attr->get_value();
}
Character character = Character(name,playerName);
character.fromXML(*elem);
vCharacters.push_back(character);
}
}
示例4: loadFilePatterns
bool PinotSettings::loadFilePatterns(const Element *pElem)
{
if (pElem == NULL)
{
return false;
}
Node::NodeList childNodes = pElem->get_children();
if (childNodes.empty() == true)
{
return false;
}
// Load the file patterns list
for (Node::NodeList::iterator iter = childNodes.begin(); iter != childNodes.end(); ++iter)
{
Node *pNode = (*iter);
Element *pElem = dynamic_cast<Element*>(pNode);
if (pElem == NULL)
{
continue;
}
string nodeName = pElem->get_name();
string nodeContent = getElementContent(pElem);
if (nodeName == "pattern")
{
m_filePatternsBlackList.insert(nodeContent);
}
}
return true;
}
示例5: loadUi
bool PinotSettings::loadUi(const Element *pElem)
{
if (pElem == NULL)
{
return false;
}
Node::NodeList childNodes = pElem->get_children();
if (childNodes.empty() == true)
{
return false;
}
for (Node::NodeList::iterator iter = childNodes.begin(); iter != childNodes.end(); ++iter)
{
Node *pNode = (*iter);
Element *pElem = dynamic_cast<Element*>(pNode);
if (pElem == NULL)
{
continue;
}
string nodeName = pElem->get_name();
string nodeContent = getElementContent(pElem);
if (nodeName == "xpos")
{
m_xPos = atoi(nodeContent.c_str());
}
else if (nodeName == "ypos")
{
m_yPos = atoi(nodeContent.c_str());
}
else if (nodeName == "width")
{
m_width = atoi(nodeContent.c_str());
}
else if (nodeName == "height")
{
m_height = atoi(nodeContent.c_str());
}
else if (nodeName == "panepos")
{
m_panePos = atoi(nodeContent.c_str());
}
else if (nodeName == "expandqueries")
{
if (nodeContent == "YES")
{
m_expandQueries = true;
}
else
{
m_expandQueries = false;
}
}
}
return true;
}
示例6: loadMailAccounts
bool PinotSettings::loadMailAccounts(const Element *pElem)
{
if (pElem == NULL)
{
return false;
}
Node::NodeList childNodes = pElem->get_children();
if (childNodes.empty() == true)
{
return false;
}
MailAccount mailAccount;
// Load the mail account's properties
for (Node::NodeList::iterator iter = childNodes.begin(); iter != childNodes.end(); ++iter)
{
Node *pNode = (*iter);
Element *pElem = dynamic_cast<Element*>(pNode);
if (pElem == NULL)
{
continue;
}
string nodeName = pElem->get_name();
string nodeContent = getElementContent(pElem);
if (nodeName == "name")
{
mailAccount.m_name = nodeContent;
}
else if (nodeName == "type")
{
mailAccount.m_type = nodeContent;
}
else if (nodeName == "mtime")
{
mailAccount.m_modTime = (time_t)atoi(nodeContent.c_str());
}
else if (nodeName == "mindate")
{
mailAccount.m_lastMessageTime = (time_t)atoi(nodeContent.c_str());
}
else if (nodeName == "size")
{
mailAccount.m_size = (off_t)atoi(nodeContent.c_str());
}
}
if (mailAccount.m_name.empty() == false)
{
m_mailAccounts.insert(mailAccount);
}
return true;
}
示例7: loadLabels
bool PinotSettings::loadLabels(const Element *pElem)
{
if (pElem == NULL)
{
return false;
}
Node::NodeList childNodes = pElem->get_children();
if (childNodes.empty() == true)
{
return false;
}
Label label;
// Load the label's properties
for (Node::NodeList::iterator iter = childNodes.begin(); iter != childNodes.end(); ++iter)
{
Node *pNode = (*iter);
Element *pElem = dynamic_cast<Element*>(pNode);
if (pElem == NULL)
{
continue;
}
string nodeName = pElem->get_name();
string nodeContent = getElementContent(pElem);
if (nodeName == "name")
{
label.m_name = nodeContent;
}
else if (nodeName == "red")
{
label.m_red = (unsigned short)atoi(nodeContent.c_str());
}
else if (nodeName == "green")
{
label.m_green = (unsigned short)atoi(nodeContent.c_str());
}
else if (nodeName == "blue")
{
label.m_blue = (unsigned short)atoi(nodeContent.c_str());
}
}
if (label.m_name.empty() == false)
{
m_labels.insert(label);
}
return true;
}
示例8: p
intg pascal_dataset<Tdata>::count_samples() {
total_difficult = 0;
total_truncated = 0;
total_occluded = 0;
total_ignored = 0;
total_samples = 0;
std::string xmlpath;
boost::filesystem::path p(annroot);
if (!boost::filesystem::exists(p))
eblthrow("Annotation path " << annroot << " does not exist.");
std::cout << "Counting number of samples in " << annroot << " ..."
<< std::endl;
// find all xml files recursively
std::list<std::string> *files = find_fullfiles(annroot, XML_PATTERN, NULL,
false, true);
if (!files || files->size() == 0)
eblthrow("no xml files found in " << annroot << " using file pattern "
<< XML_PATTERN);
std::cout << "Found " << files->size() << " xml files." << std::endl;
for (std::list<std::string>::iterator i = files->begin(); i != files->end(); ++i) {
xmlpath = *i;
// parse xml
DomParser parser;
parser.parse_file(xmlpath);
if (parser) {
// initialize root node and list
const Node* pNode = parser.get_document()->get_root_node();
Node::NodeList list = pNode->get_children();
// parse all objects in image
for(Node::NodeList::iterator iter = list.begin();
iter != list.end(); ++iter) {
if (!strcmp((*iter)->get_name().c_str(), "object")) {
// check for difficult flag in object node
Node::NodeList olist = (*iter)->get_children();
count_sample(olist);
}
}
}
}
if (files) delete files;
std::cout << "Found: " << total_samples << " samples, including ";
std::cout << total_difficult << " difficult, " << total_truncated;
std::cout << " truncated and " << total_occluded << " occluded." << std::endl;
ignore_difficult ? std::cout << "Ignoring" : std::cout << "Using";
std::cout << " difficult samples." << std::endl;
ignore_truncated ? std::cout << "Ignoring" : std::cout << "Using";
std::cout << " truncated samples." << std::endl;
ignore_occluded ? std::cout << "Ignoring" : std::cout << "Using";
std::cout << " occluded samples." << std::endl;
total_samples = total_samples - total_ignored;
return total_samples;
}
示例9: loadIndexableLocations
bool PinotSettings::loadIndexableLocations(const Element *pElem)
{
if (pElem == NULL)
{
return false;
}
Node::NodeList childNodes = pElem->get_children();
if (childNodes.empty() == true)
{
return false;
}
IndexableLocation location;
// Load the indexable location's properties
for (Node::NodeList::iterator iter = childNodes.begin(); iter != childNodes.end(); ++iter)
{
Node *pNode = (*iter);
Element *pElem = dynamic_cast<Element*>(pNode);
if (pElem == NULL)
{
continue;
}
string nodeName = pElem->get_name();
string nodeContent = getElementContent(pElem);
if (nodeName == "name")
{
location.m_name = nodeContent;
}
else if (nodeName == "monitor")
{
if (nodeContent == "YES")
{
location.m_monitor = true;
}
else
{
location.m_monitor = false;
}
}
}
if (location.m_name.empty() == false)
{
m_indexableLocations.insert(location);
}
return true;
}
示例10: loadProxy
bool PinotSettings::loadProxy(const Element *pElem)
{
if (pElem == NULL)
{
return false;
}
Node::NodeList childNodes = pElem->get_children();
if (childNodes.empty() == true)
{
return false;
}
for (Node::NodeList::iterator iter = childNodes.begin(); iter != childNodes.end(); ++iter)
{
Node *pNode = (*iter);
Element *pChildElem = dynamic_cast<Element*>(pNode);
if (pChildElem == NULL)
{
continue;
}
string nodeName(pChildElem->get_name());
string nodeContent(getElementContent(pChildElem));
if (nodeName == "address")
{
m_proxyAddress = nodeContent;
}
else if (nodeName == "port")
{
m_proxyPort = (unsigned int)atoi(nodeContent.c_str());
}
else if (nodeName == "type")
{
m_proxyType = nodeContent;
}
else if (nodeName == "enable")
{
if (nodeContent == "YES")
{
m_proxyEnabled = true;
}
else
{
m_proxyEnabled = false;
}
}
}
return true;
}
示例11: fromXML
void Character::fromXML(const xmlpp::Element &root)
{
using namespace xmlpp;
clearSkills();
Node::NodeList list = root.get_children("skill");
for (Node::NodeList::const_iterator it = list.begin(); it != list.end(); it++)
{
Element *elem = dynamic_cast<Element *>(*it);
string value;
Attribute *attr = elem->get_attribute("value");
if (attr != NULL)
{
value = attr->get_value();
}
vSkills.push_back(value);
}
}
示例12: loadIndexes
bool PinotSettings::loadIndexes(const Element *pElem)
{
if (pElem == NULL)
{
return false;
}
Node::NodeList childNodes = pElem->get_children();
if (childNodes.empty() == true)
{
return false;
}
string indexName, indexLocation;
for (Node::NodeList::iterator iter = childNodes.begin(); iter != childNodes.end(); ++iter)
{
Node *pNode = (*iter);
Element *pElem = dynamic_cast<Element*>(pNode);
if (pElem == NULL)
{
continue;
}
string nodeName = pElem->get_name();
string nodeContent = getElementContent(pElem);
if (nodeName == "name")
{
indexName = nodeContent;
}
else if (nodeName == "location")
{
indexLocation = nodeContent;
}
}
if ((indexName.empty() == false) &&
(indexLocation.empty() == false))
{
addIndex(indexName, indexLocation);
}
return true;
}
示例13: loadResults
bool PinotSettings::loadResults(const Element *pElem)
{
if (pElem == NULL)
{
return false;
}
Node::NodeList childNodes = pElem->get_children();
if (childNodes.empty() == true)
{
return false;
}
for (Node::NodeList::iterator iter = childNodes.begin(); iter != childNodes.end(); ++iter)
{
Node *pNode = (*iter);
Element *pElem = dynamic_cast<Element*>(pNode);
if (pElem == NULL)
{
continue;
}
string nodeName = pElem->get_name();
string nodeContent = getElementContent(pElem);
if (nodeName == "viewmode")
{
if (nodeContent == "SOURCE")
{
m_browseResults = false;
}
else
{
m_browseResults = true;
}
}
else if (nodeName == "browser")
{
m_browserCommand = nodeContent;
}
}
return true;
}
示例14: loadColour
bool PinotSettings::loadColour(const Element *pElem)
{
if (pElem == NULL)
{
return false;
}
Node::NodeList childNodes = pElem->get_children();
if (childNodes.empty() == true)
{
return false;
}
// Load the colour RGB components
for (Node::NodeList::iterator iter = childNodes.begin(); iter != childNodes.end(); ++iter)
{
Node *pNode = (*iter);
Element *pElem = dynamic_cast<Element*>(pNode);
if (pElem == NULL)
{
continue;
}
string nodeName = pElem->get_name();
string nodeContent = getElementContent(pElem);
gushort value = (gushort)atoi(nodeContent.c_str());
if (nodeName == "red")
{
m_newResultsColourRed = value;
}
else if (nodeName == "green")
{
m_newResultsColourGreen = value;
}
else if (nodeName == "blue")
{
m_newResultsColourBlue = value;
}
}
return true;
}
示例15: getNodeContent
static ustring getNodeContent(const Node *pNode)
{
if (pNode == NULL)
{
return "";
}
// Is it an element ?
const Element *pElem = dynamic_cast<const Element*>(pNode);
if (pElem != NULL)
{
#ifdef HAS_LIBXMLPP026
const TextNode *pText = pElem->get_child_content();
#else
const TextNode *pText = pElem->get_child_text();
#endif
if (pText == NULL)
{
// Maybe the text is given as CDATA
const Node::NodeList childNodes = pNode->get_children();
if (childNodes.size() == 1)
{
// Is it CDATA ?
const CdataNode *pContent = dynamic_cast<const CdataNode*>(*childNodes.begin());
if (pContent != NULL)
{
return pContent->get_content();
}
}
return "";
}
return pText->get_content();
}
return "";
}