本文整理汇总了C++中DOMNode::hasChildNodes方法的典型用法代码示例。如果您正苦于以下问题:C++ DOMNode::hasChildNodes方法的具体用法?C++ DOMNode::hasChildNodes怎么用?C++ DOMNode::hasChildNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMNode
的用法示例。
在下文中一共展示了DOMNode::hasChildNodes方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: previousNode
DOMNode* DOMNodeIteratorImpl::previousNode (DOMNode* node) {
if (fDetached)
throw DOMException(DOMException::INVALID_STATE_ERR, 0, GetDOMNodeIteratorMemoryManager);
DOMNode* result = 0;
// if we're at the root, return 0.
if (node == fRoot)
return 0;
// get sibling
result = node->getPreviousSibling();
if (!result) {
//if 1st sibling, return parent
result = node->getParentNode();
return result;
}
// if sibling has children, keep getting last child of child.
if (result->hasChildNodes()) {
while ((fExpandEntityReferences || result->getNodeType()!=DOMNode::ENTITY_REFERENCE_NODE) &&
result->hasChildNodes()) {
result = result->getLastChild();
}
}
return result;
}
示例2: ParseDevices
bool CConfigParser::ParseDevices(DOMNodeList* deviceNodeList, ADeviceListener& configClass)
{
ASSERT(deviceNodeList->getLength() >= 1);
DOMNode* deviceNode = deviceNodeList->item(0);
DOMNodeList* devices = deviceNode->getChildNodes();
for(unsigned long idx = 0; idx < devices->getLength(); idx++)
{
DOMNode* currentDevice = devices->item(idx);
wstring deviceNodeName = currentDevice->getNodeName();
if(deviceNodeName.compare(L"#text") == 0)
continue;
wstring deviceName = currentDevice->getAttributes()->getNamedItem(L"name")->getNodeValue();
//wstring deviceType = currentDevice->getAttributes()->getNamedItem(L"type")->getNodeValue();
wstring deviceType = deviceNodeName;
if(deviceType.compare(L"mouse") == 0)
{
configClass.AddDevice(deviceName, new CMouseProc());
}
else
{
CWin32SpaceNavigatorHIDCapture* deviceToAdd = new CWin32SpaceNavigatorHIDCapture();
if(currentDevice->hasChildNodes())
{
if(!ParseHIDDeviceCommands(currentDevice->getChildNodes(), deviceToAdd))
return false;
}
configClass.AddDevice(deviceName, deviceToAdd);
}
}
return true;
}
示例3: getPreviousSibling
DOMNode* DOMTreeWalkerImpl::getPreviousSibling (DOMNode* node) {
if (!node || node == fRoot) return 0;
DOMNode* newNode = node->getPreviousSibling();
if (!newNode) {
newNode = node->getParentNode();
if (!newNode || node == fRoot) return 0;
short parentAccept = acceptNode(newNode);
if (parentAccept == DOMNodeFilter::FILTER_SKIP) {
return getPreviousSibling(newNode);
}
return 0;
}
short accept = acceptNode(newNode);
if (accept == DOMNodeFilter::FILTER_ACCEPT)
return newNode;
else
if (accept == DOMNodeFilter::FILTER_SKIP) {
DOMNode* fChild = getLastChild(newNode);
if (!fChild && !newNode->hasChildNodes()) {
return getPreviousSibling(newNode);
}
return fChild;
}
return getPreviousSibling(newNode);
}
示例4: ParseDeviceContexts
bool CConfigParser::ParseDeviceContexts(DOMNodeList* deviceContextNodes, ADeviceListener& configClass)
{
ASSERT(deviceContextNodes->getLength() == 1);
DOMNode* deviceContextNode = deviceContextNodes->item(0);
DOMNodeList* deviceContexts = deviceContextNode->getChildNodes();
for(unsigned long idx = 0; idx < deviceContexts->getLength(); idx++)
{
DOMNode* currentDeviceContext = deviceContexts->item(idx);
wstring deviceContextNodeName = currentDeviceContext->getNodeName();
if(deviceContextNodeName.compare(L"#text") == 0)
continue;
if(deviceContextNodeName.compare(L"#comment") == 0)
continue;
wstring deviceContextName = currentDeviceContext->getAttributes()->getNamedItem(L"name")->getNodeValue();
wstring deviceName = currentDeviceContext->getAttributes()->getNamedItem(L"device")->getNodeValue();
bool gestures = false;
if(currentDeviceContext->getAttributes()->getNamedItem(L"gestures") != NULL)
gestures = true;
// Create the device context to add
CDeviceContext* deviceContextToAdd = NULL;
if(configClass.GetDevices()[deviceName]->GetType().compare("mouse") == 0)
deviceContextToAdd = new CMouseDeviceContext(gestures, deviceName);
else
deviceContextToAdd = new CDeviceContext(gestures, deviceName);
// Get the device contexts axis and buttons added
if(currentDeviceContext->hasChildNodes())
{
unsigned char axeIdx = 0;
DOMNodeList* children = currentDeviceContext->getChildNodes();
unsigned long childCount = children->getLength();
for(unsigned long idx = 0; idx < childCount; idx++)
{
DOMNode* childNode = children->item(idx);
wstring nodeName = childNode->getNodeName();
if(nodeName.compare(L"axe") == 0)
{
ParseAxe(childNode, configClass.GetActions(), deviceContextToAdd, axeIdx);
axeIdx++;
}
if(nodeName.compare(L"buttons") == 0)
ParseButtons(childNode, configClass.GetActions(), deviceContextToAdd);
if(nodeName.compare(L"gesture") == 0)
ParseGesture(childNode, configClass.GetActions(), deviceContextToAdd);
}
}
configClass.AddDeviceContext(deviceContextName, deviceContextToAdd);
TRACE("Device Context <%S> is 0x%X\r\n", deviceContextName.c_str(), deviceContextToAdd);
}
return true;
}
示例5: Subtree_Insert
void DeltaApplyEngine::Subtree_Insert( DOMNode *insertSubtreeRoot, XID_t parentXID, int position, const char *xidmapStr ) {
vddprintf(( " insert xidmap=%s at (parent=%d, pos=%d)\n", xidmapStr, (int)parentXID, position));
DOMNode* contentNode = xiddoc->importNode( insertSubtreeRoot, true );
DOMNode* parentNode = xiddoc->getXidMap().getNodeWithXID( parentXID );
if (parentNode==NULL) THROW_AWAY(("parent node with XID=%d not found",(int)parentXID));
int actual_pos = 1 ;
if ((position!=1)&&(!parentNode->hasChildNodes())) THROW_AWAY(("parent has no children but position is %d",position));
DOMNode* brother = parentNode->getFirstChild();
while (actual_pos < position) {
brother = brother->getNextSibling();
actual_pos++;
if ((brother==NULL)&&(actual_pos<position)) THROW_AWAY(("parent has %d children but position is %d",actual_pos-1, position));
}
// Add node to the tree
if (brother==NULL) parentNode->appendChild( contentNode );
else parentNode->insertBefore( contentNode, brother );
xiddoc->getXidMap().mapSubtree( xidmapStr, contentNode );
}
示例6: getLastChild
DOMNode* DOMTreeWalkerImpl::getLastChild (DOMNode* node) {
if (!node) return 0;
if(!fExpandEntityReferences && node->getNodeType()==DOMNode::ENTITY_REFERENCE_NODE)
return 0;
DOMNode* newNode = node->getLastChild();
if (!newNode) return 0;
short accept = acceptNode(newNode);
if (accept == DOMNodeFilter::FILTER_ACCEPT)
return newNode;
else
if (accept == DOMNodeFilter::FILTER_SKIP
&& newNode->hasChildNodes())
{
return getLastChild(newNode);
}
return getPreviousSibling(newNode);
}