⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kissdom.cc

📁 XMDS is a code generator that integrates equations. You write them down in human readable form in a
💻 CC
📖 第 1 页 / 共 5 页
字号:
  }	  oldChild->setParentNode(0);  myNodeList.erase(ppNode);  return oldChild;};// ******************************************************************************Node* KissNode::removeChild(			    Node* oldChild) {  if(oldChild == 0) {    return 0;  }  if(myReadOnly) {    throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR);  }  list<Node*>::iterator ppNode = myNodeList.begin();  while((ppNode != myNodeList.end())&(*ppNode != oldChild)) {    ppNode++;  }	  if(*ppNode != oldChild) {    throw DOMException(DOMException::NOT_FOUND_ERR);  }  myNodeList.erase(ppNode);  oldChild->setParentNode(0);  return oldChild;};// ******************************************************************************Node* KissNode::appendChild(			    Node* newChild) {  if(newChild == 0) {    return 0;  }  checkChildAddingConstraints1(newChild);  checkChildAddingConstraints2(newChild);  if(newChild->parentNode() != 0) {    newChild->parentNode()->removeChild(newChild);  }  if(newChild->nodeType() == DOCUMENT_FRAGMENT_NODE) {    while(newChild->hasChildNodes()) {      Node* nextChild = newChild->removeChild(newChild->firstChild());      nextChild->setParentNode(this);      myNodeList.push_back(nextChild);    }  }  else {    newChild->setParentNode(this);    myNodeList.push_back(newChild);  }  return newChild;};// ******************************************************************************bool KissNode::hasChildNodes() const {  return (myNodeList.size() > 0);};// ******************************************************************************void KissNode::normalize() {  if(myReadOnly) {    throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR);  }  unsigned long i;  // firstly remove empty text nodes  i = 0;  while(i < myNodeList.size()) {    Node* testNode = myKissNodeList.item(i);    if(testNode->nodeType() == TEXT_NODE) {      if(testNode->nodeValue()->length() == 0) {	removeChild(testNode);	delete testNode;	i--;      }    i++;	    }  }  i = 0;  while(i + 1 < myNodeList.size()) {    Node* testNode1 = myKissNodeList.item(i);    Node* testNode2 = myKissNodeList.item(i + 1);    if((testNode1->nodeType() == TEXT_NODE) &(testNode2->nodeType() == TEXT_NODE)) {      DOMString s = *(testNode1->nodeValue());      s += *(testNode2->nodeValue());      testNode1->setNodeValue(s);      removeChild(testNode2);      delete testNode2;      i--;    }    i++;  }};// ******************************************************************************bool KissNode::isSupported(			   DOMString& feature,			   DOMString& version) const {  return 0;};// ******************************************************************************const DOMString* KissNode::namespaceURI() const {  return 0;};// ******************************************************************************const DOMString* KissNode::prefix() const {  return 0;};// ******************************************************************************void KissNode::setPrefix(			 const DOMString& newPrefix) {};// ******************************************************************************const DOMString* KissNode::localName() const {  return 0;};// ******************************************************************************bool KissNode::hasAttributes() const {  return 0;};// ******************************************************************************const DOMString* KissNode::baseURI() const {  return 0;};// ******************************************************************************Node::DocumentOrder KissNode::compareDocumentOrder(						   const Node* other) const {  if(other == this) {    return DOCUMENT_ORDER_SAME;  }   if(other->ownerDocument() != 0) {    if(other->ownerDocument() != myOwnerDocument); {    throw DOMException(DOMException::WRONG_DOCUMENT_ERR);    }  }  else {    if(other != myOwnerDocument) {      throw DOMException(DOMException::WRONG_DOCUMENT_ERR);    }  }  if(other->nodeType() == ATTRIBUTE_NODE) {    return DOCUMENT_ORDER_UNORDERED;  }	  bool passedThisNode = 0;  // work forwards from top node looking for other node  const Node* nextNode = myOwnerDocument;  while (nextNode != 0) {    if(nextNode == other) {      if(passedThisNode) {	return DOCUMENT_ORDER_FOLLOWING;      }      else {	return DOCUMENT_ORDER_PRECEDING;      }    }    passedThisNode = passedThisNode | (nextNode == this);    if(nextNode->hasChildNodes()) {      nextNode = nextNode->firstChild();    }    else {      while((nextNode->nextSibling() == 0) &(nextNode->parentNode() != 0)) {	nextNode = nextNode->parentNode();      }    }    if(nextNode != 0) {      nextNode = nextNode->nextSibling();    }  }  return DOCUMENT_ORDER_UNORDERED;};// ******************************************************************************Node::TreePosition KissNode::compareTreePosition(						 const Node* other) const {  if(other == this) {    return TREE_POSITION_SAME;  }  if(other->ownerDocument() != 0) {    if(other->ownerDocument() != myOwnerDocument) {      throw DOMException(DOMException::WRONG_DOCUMENT_ERR);    }  }  else {    if(other != myOwnerDocument) {      throw DOMException(DOMException::WRONG_DOCUMENT_ERR);    }  }  const Node* nextNode;  // look for other as ancestor  nextNode = myParentNode;  while(nextNode != 0) {    if(nextNode == other) {      return TREE_POSITION_ANCESTOR;    }    nextNode = nextNode->parentNode();  }  // look for other as child  nextNode = other->parentNode();  while(nextNode != 0) {    if(nextNode == this) {      return TREE_POSITION_DESCENDANT;    }    nextNode = nextNode->parentNode();  }  // else use document order  switch(compareDocumentOrder(other)) {  case DOCUMENT_ORDER_PRECEDING :    return TREE_POSITION_PRECEDING;    break;  case DOCUMENT_ORDER_FOLLOWING :    return TREE_POSITION_FOLLOWING;    break;  default :    return TREE_POSITION_UNORDERED;  }};// ******************************************************************************const DOMString* KissNode::textContent(				       const bool& deep) const {  const DOMString* pS = nodeValue();  if(pS != 0) {    myTextContent = *pS;  }  else {    myTextContent = EMPTY_STRING;  }  if(deep) {    for(list<Node*>::const_iterator ppNode = myNodeList.begin(); ppNode != myNodeList.end(); ppNode ++) {      if(((*ppNode)->nodeType() != COMMENT_NODE) &((*ppNode)->nodeType() != PROCESSING_INSTRUCTION_NODE)) {	myTextContent += *(*ppNode)->textContent(deep);      }    }  }  else {    for(list<Node*>::const_iterator ppNode = myNodeList.begin(); ppNode != myNodeList.end(); ppNode ++) {      if(	((*ppNode)->nodeType() == TEXT_NODE) |((*ppNode)->nodeType() == CDATA_SECTION_NODE)) {	myTextContent += *(*ppNode)->textContent(deep);      }    }  }  return &myTextContent;};// ******************************************************************************void KissNode::setTextContent(			      const DOMString& newTextContent) {  if(myReadOnly) {    throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR);  }  // delete all children  for(list<Node*>::const_iterator ppNode = myNodeList.begin(); ppNode != myNodeList.end(); ppNode++) {    delete (*ppNode);  }  Node* newTextNode = new KissText(myOwnerDocument,myParentNode,newTextContent);  appendChild(newTextNode);};// ******************************************************************************bool KissNode::isSameNode(			  const Node* other) const {  return (other == this);};// ******************************************************************************const DOMString* KissNode::lookupNamespacePrefix(						 const DOMString& namespaceURI) const {  if(DEBUGKISSDOM) {    printf("KissNode::lookupNamespacePrefix() [%s]\n",nodeName()->c_str());  }  if(namespaceURI.length() == 0) {    return 0;  }  const Node* nextAncestor = this;  while(nextAncestor != 0) {    if(nextAncestor->hasAttributes()) {      for(unsigned long i = 0; i < nextAncestor->attributes()->length(); i++) {	if(*nextAncestor->attributes()->item(i)->nodeValue() == namespaceURI) {	  if(nextAncestor->attributes()->item(i)->namespaceURI() != 0) {	    if(nextAncestor->attributes()->item(i)->prefix()->eqxmlns()) {	      return nextAncestor->attributes()->item(i)->localName();	    }	  }	}      }    }    nextAncestor = nextAncestor->parentNode();  }  return 0;};// ******************************************************************************const DOMString* KissNode::lookupNamespaceURI(					      const DOMString& prefix) const {  if(DEBUGKISSDOM) {    printf("KissNode::lookupNamespaceURI() [%s]\n",nodeName()->c_str());  }  if(prefix.eqxml()) {    return &XML_NAMESPACEURI;  }  if(prefix.eqxmlns()) {    return &XMLNS_NAMESPACEURI;  }  const Node* nextAncestor = this;  while(nextAncestor != 0) {    if(nextAncestor->hasAttributes()) {      if(prefix.length() > 0) {	// look for explicitly defined namespace	for(unsigned long i = 0; i < nextAncestor->attributes()->length(); i++)  {	  if(nextAncestor->attributes()->item(i)->namespaceURI() != 0) {	    if(nextAncestor->attributes()->item(i)->prefix()->eqxmlns()	       &(*nextAncestor->attributes()->item(i)->localName() == prefix)) {	      return nextAncestor->attributes()->item(i)->nodeValue();	    }	  }	}      }      else	{	// look for first default namespace	for(unsigned long i = 0; i < nextAncestor->attributes()->length(); i++)  {	  if(nextAncestor->attributes()->item(i)->namespaceURI() != 0) {	    if(nextAncestor->attributes()->item(i)->nodeName()->eqxmlns()) {	      return(nextAncestor->attributes()->item(i)->nodeValue());	    }	  }	}      }    }		    nextAncestor = nextAncestor->parentNode();  }  return 0;};// ******************************************************************************void KissNode::normalizeNS() {};// ******************************************************************************DOMKey KissNode::key() const {  return myDOMKey;};// ******************************************************************************bool KissNode::equalsNode(			  const Node* arg,			  bool deep) const {  // check for the obvious first!  if(arg == 0) {    return 0;  }  if(arg == this) {    return 1;  }  const DOMString* s1;  const DOMString* s2;   const NamedNodeMap* a1 = arg->attributes();  const NamedNodeMap* a2 = attributes();  unsigned long i;  // compare nodeTypes  if (arg->nodeType() != nodeType()) {    return 0;  }  // compare nodeNames  if (arg->nodeName() != nodeName()) {    return 0;  }  // compare nodeValues  s1 = arg->nodeValue();  s2 = nodeValue();  if((s1 == 0) != (s1 == 0)) {    return 0;  }  if((s1 != 0) && (s2 != 0)) {    if(*s1 != *s2) {      return 0;    }  }  // compare namespaceURIs;  s1 = arg->namespaceURI();  s2 = namespaceURI();  if((s1 == 0) != (s1 == 0)) {    return 0;  }  if((s1 != 0) && (s2 != 0)) {    if(*s1 != *s2) {      return 0;    }  }  // compare attributes (if any)  if((a1 == 0) != (a1 == 0)) {    return 0;  }  if(a1 != 0) {    if(a1->length() != a2->length()) {      return 0;    }    for(i = 0; i < a1->length(); i++) {      if(!a1->item(i)->equalsNode(a2->item(i),deep)) {	return 0;      }    }  }  if(deep) {    // compare children    if(arg->childNodes()->length() != childNodes()->length()) {      return 0;    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -