本文整理汇总了C++中TiXmlNode::NoChildren方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlNode::NoChildren方法的具体用法?C++ TiXmlNode::NoChildren怎么用?C++ TiXmlNode::NoChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlNode
的用法示例。
在下文中一共展示了TiXmlNode::NoChildren方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildTreeFrom
bool ProjectPanel::buildTreeFrom(TiXmlNode *projectRoot, HTREEITEM hParentItem)
{
for (TiXmlNode *childNode = projectRoot->FirstChildElement();
childNode ;
childNode = childNode->NextSibling())
{
const TCHAR *v = childNode->Value();
if (lstrcmp(TEXT("Folder"), v) == 0)
{
HTREEITEM addedItem = _treeView.addItem((childNode->ToElement())->Attribute(TEXT("name")), hParentItem, INDEX_CLOSED_NODE);
if (!childNode->NoChildren())
{
bool isOK = buildTreeFrom(childNode, addedItem);
if (!isOK)
return false;
}
}
else if (lstrcmp(TEXT("File"), v) == 0)
{
const TCHAR *strValue = (childNode->ToElement())->Attribute(TEXT("name"));
generic_string fullPath = getAbsoluteFilePath(strValue);
TCHAR *strValueLabel = ::PathFindFileName(strValue);
int iImage = ::PathFileExists(fullPath.c_str())?INDEX_LEAF:INDEX_LEAF_INVALID;
_treeView.addItem(strValueLabel, hParentItem, iImage, fullPath.c_str());
}
}
return true;
}
示例2: set_value
void XMLConfiguration::set_value(const string& section, const string& object, const string& value)
{
bool section_found = false;
bool object_found = false;
TiXmlNode* child = 0;
TiXmlNode* nephew = 0;
if(m_document->NoChildren()==false)
{
while((!section_found) && ( child = m_document->IterateChildren( child ) ))
{
if(string(child->Value())==section)
{
section_found = true;
}
}
}
if(section_found == false)
{
LOG_INFO("XMLConfiguration: no section "<<section<<" found, creating.");
child = new TiXmlElement( section.c_str() );
m_document->LinkEndChild( child );
}
if(child->NoChildren()==false)
{
while((!object_found) &&( nephew = child->IterateChildren( nephew ) ))
{
if(string(nephew->Value())==object)
{
object_found = true;
}
}
}
if(object_found == false)
{
LOG_INFO("XMLConfiguration: no object "<<section<<"/"<<object<<" found, creating.");
nephew = new TiXmlElement( object.c_str() );
child->LinkEndChild( nephew );
}
nephew->Clear();
TiXmlText* text_element = new TiXmlText( value.c_str() );
nephew->LinkEndChild( text_element );
}
示例3: remove_object
void XMLConfiguration::remove_object(const string& section_name, const string& object_name)
{
bool section_found = false;
bool object_found = false;
TiXmlNode* child = 0;
TiXmlNode* nephew = 0;
if(m_document->NoChildren()==false)
{
while((!section_found) && ( child = m_document->IterateChildren( child ) ))
{
if(string(child->Value())==section_name)
{
section_found = true;
}
}
}
if(section_found == false)
{
return;
}
if(child->NoChildren()==false)
{
while((!object_found) && ( nephew = child->IterateChildren( nephew ) ))
{
if(string(nephew->Value())==object_name)
{
object_found = true;
}
}
}
if(object_found == false)
{
return;
}
child->RemoveChild(nephew);
}
示例4: GetNewsItems
void CRssReader::GetNewsItems(TiXmlElement* channelXmlNode, int iFeed)
{
HTML::CHTMLUtil html;
TiXmlElement * itemNode = channelXmlNode->FirstChildElement("item");
std::map<std::string, std::wstring> mTagElements;
typedef std::pair<std::string, std::wstring> StrPair;
std::list<std::string>::iterator i;
// Add the title tag in if we didn't pass any tags in at all
// Represents default behaviour before configurability
if (m_tagSet.empty())
AddTag("title");
while (itemNode > 0)
{
TiXmlNode* childNode = itemNode->FirstChild();
mTagElements.clear();
while (childNode > 0)
{
std::string strName = childNode->ValueStr();
for (i = m_tagSet.begin(); i != m_tagSet.end(); ++i)
{
if (!childNode->NoChildren() && *i == strName)
{
std::string htmlText = childNode->FirstChild()->ValueStr();
// This usually happens in right-to-left languages where they want to
// specify in the RSS body that the text should be RTL.
// <title>
// <div dir="RTL">��� ����: ���� �� �����</div>
// </title>
if (htmlText == "div" || htmlText == "span")
htmlText = childNode->FirstChild()->FirstChild()->ValueStr();
std::wstring unicodeText, unicodeText2;
g_charsetConverter.utf8ToW(htmlText, unicodeText2, m_rtlText);
html.ConvertHTMLToW(unicodeText2, unicodeText);
mTagElements.insert(StrPair(*i, unicodeText));
}
}
childNode = childNode->NextSibling();
}
int rsscolour = RSS_COLOR_HEADLINE;
for (i = m_tagSet.begin(); i != m_tagSet.end(); ++i)
{
std::map<std::string, std::wstring>::iterator j = mTagElements.find(*i);
if (j == mTagElements.end())
continue;
std::wstring& text = j->second;
AddString(text, rsscolour, iFeed);
rsscolour = RSS_COLOR_BODY;
text = L" - ";
AddString(text, rsscolour, iFeed);
}
itemNode = itemNode->NextSiblingElement("item");
}
}