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

📄 kissdom.cc

📁 XMDS is a code generator that integrates equations. You write them down in human readable form in a
💻 CC
📖 第 1 页 / 共 5 页
字号:
  return 0;};// ******************************************************************************Node* KissNamedNodeMap::setNamedItem(				     Node& arg) {  if(DEBUGKISSDOM) {    printf("KissNamedNodeMap::setNamedItem()\n");  }  canAddThisNode(arg);  if (DEBUGKISSDOM) {    printf("arg.nodeName = %s\n",arg.nodeName()->c_str());  }   Node* oldNode;  try {    oldNode = removeNamedItem(*(arg.nodeName()));  }  catch (DOMException DOMExc) {    if (DEBUGKISSDOM) {      printf("KissNamedNodeMap::setNamedItem DOMException %s\n", DOMExc.getError());    }    oldNode = 0;  }  myNodeList.push_back(&arg);  myNameList.push_back(arg.nodeName());  myNamespaceURIList.push_back(&EMPTY_STRING);  return oldNode;};// ******************************************************************************Node* KissNamedNodeMap::removeNamedItem(					const DOMString& name) {  if(DEBUGKISSDOM) {    printf("KissNamedNodeMap::removeNamedItem()\n");  }  if(DEBUGKISSDOM) {    printf("name is %s\n", name.c_str());  }  if(readOnly) {    throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR);  }  if(myNodeList.size() == 0) {    throw DOMException(DOMException::NOT_FOUND_ERR);  }  list<Node*>::iterator ppNode = myNodeList.begin();  list<const DOMString*>::iterator ppName = myNameList.begin();  list<const DOMString*>::iterator ppNamespaceURI = myNamespaceURIList.begin();  bool found=0;  while((ppNode != myNodeList.end())&!found) {    found = (**ppName==name);    if(!found) {      ppNode++;      ppName++;      ppNamespaceURI++;    }  }  if(ppNode != myNodeList.end()) {    Node* removedNode = *ppNode;    myNodeList.erase(ppNode);    myNameList.erase(ppName);    myNamespaceURIList.erase(ppNamespaceURI);    return removedNode;  }  // if not found by now  throw DOMException(DOMException::NOT_FOUND_ERR);};// ******************************************************************************unsigned long KissNamedNodeMap::length() const {  return myNodeList.size();};// ******************************************************************************Node* KissNamedNodeMap::item(			     const unsigned long index) const {  if(index >= myNodeList.size()) {    return 0;  }	  list<Node*>::const_iterator ppNode = myNodeList.begin();  for(unsigned long i = 0; i < index; i++) {    ppNode++;  }  return *ppNode;};// ******************************************************************************Node* KissNamedNodeMap::getNamedItemNS(				       const DOMString& namespaceURI,				       const DOMString& localname) const {  if(DEBUGKISSDOM) {    printf("KissNamedNodeMap::getNamedItemNS()\n");  }  if(myNodeList.size() == 0) {    return 0;  }  list<Node*>::const_iterator ppNode = myNodeList.begin();  list<const DOMString*>::const_iterator ppName = myNameList.begin();  list<const DOMString*>::const_iterator ppNamespaceURI = myNamespaceURIList.begin();  bool found=0;  while((ppNode != myNodeList.end())&!found) {    found = (**ppName==localname)&(**ppNamespaceURI==namespaceURI);    if(!found) {      ppNode++;      ppName++;      ppNamespaceURI++;    }  }  if(ppNode != myNodeList.end()) {    return *ppNode;  }  return 0;};// ******************************************************************************Node* KissNamedNodeMap::setNamedItemNS(				       Node& arg) {  if(DEBUGKISSDOM) {    printf("KissNamedNodeMap::setNamedItemNS()\n");  }  canAddThisNode(arg);  Node* oldNode;  try {    oldNode = removeNamedItemNS(*(arg.namespaceURI()),*(arg.localName()));  }  catch (DOMException DOMExc) {    oldNode = 0;  }  myNodeList.push_back(&arg);  myNameList.push_back(arg.localName());  myNamespaceURIList.push_back(arg.namespaceURI());  return oldNode;};// ******************************************************************************Node* KissNamedNodeMap::removeNamedItemNS(					  const DOMString& namespaceURI,					  const DOMString& localname) {  if(DEBUGKISSDOM) {    printf("KissNamedNodeMap::removeNamedItemNS()\n");  }  if(readOnly) {    throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR);  }  if(myNodeList.size() == 0) {    throw DOMException(DOMException::NOT_FOUND_ERR);  }  list<Node*>::iterator ppNode = myNodeList.begin();  list<const DOMString*>::iterator ppName = myNameList.begin();  list<const DOMString*>::iterator ppNamespaceURI = myNamespaceURIList.begin();  bool found=0;  while((ppNode != myNodeList.end())&!found) {    found = (**ppName==localname)&(**ppNamespaceURI==namespaceURI);    if(!found) {      ppNode++;      ppName++;      ppNamespaceURI++;    }  }  if(ppNode != myNodeList.end()) {    Node* removedNode = *ppNode;    myNodeList.erase(ppNode);    myNameList.erase(ppName);    myNamespaceURIList.erase(ppNamespaceURI);    return removedNode;  }  // if not found by now  throw DOMException(DOMException::NOT_FOUND_ERR);};// ******************************************************************************void KissNamedNodeMap::setReadOnly(				   const bool& newReadOnly) {  readOnly = newReadOnly;};// ******************************************************************************const Document* KissNamedNodeMap::ownerDocument() const {  if(DEBUGKISSDOM) {    printf("KissNamedNodeMap::ownerDocument()\n");  }  return myOwnerDocument;};// ******************************************************************************void KissNamedNodeMap::setOwnerDocument(					const Document* yourOwnerDocument) {  if(DEBUGKISSDOM) {    printf("KissNamedNodeMap::setOwnerDocument()\n");  }  myOwnerDocument=yourOwnerDocument;};// ******************************************************************************void KissNamedNodeMap::canAddThisNode(				      const Node& arg) const {  if(DEBUGKISSDOM) {    printf("KissNamedNodeMap::canAddThisNode()\n");  }  if(readOnly) {    throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR);  }  if(arg.ownerDocument() != ownerDocument()) {    throw DOMException(DOMException::WRONG_DOCUMENT_ERR);  }  if(arg.nodeType() != myNodeType) {    throw DOMException(DOMException::HIERARCHY_REQUEST_ERR);  }};// ******************************************************************************// ******************************************************************************//	KissNode// ******************************************************************************// ******************************************************************************long nKissNodes=0;  //!< Number of KISS node objects// ******************************************************************************KissNode::KissNode(		   const Document *const yourOwnerDocument,		   Node *const yourParentNode,		   const DOMString& yourNodeName) :  myKissNodeList(&myNodeList) {  if(DEBUGKISSDOM) {    nKissNodes++;    printf("KissNode::KissNode(); [%s]\n",yourNodeName.c_str());    printf("nKissNodes=%li\n",nKissNodes);  }  myOwnerDocument = yourOwnerDocument;  myParentNode = yourParentNode;  myNodeName = yourNodeName;  myReadOnly = 0;  if(myOwnerDocument != 0) {    myDOMKey = myOwnerDocument->getDOMKey();  }  else {    myDOMKey = 0;  }};// ******************************************************************************KissNode::~KissNode() {  if(DEBUGKISSDOM) {    printf("KissNode::~KissNode(%li); [%s]\n",myDOMKey,myNodeName.c_str());  }  for(list<Node*>::const_iterator ppNode = myNodeList.begin(); ppNode != myNodeList.end(); ppNode++) {    if(DEBUGKISSDOM) {      printf("deleting *ppNode=%li\n",(long)*ppNode);     }    delete (*ppNode);  }  if(DEBUGKISSDOM) {    nKissNodes--;    printf("	...(%li); [%s] deleted\n",myDOMKey,myNodeName.c_str());    printf("nKissNodes=%li\n",nKissNodes);  }};// ******************************************************************************const DOMString* KissNode::nodeName() const {  return &myNodeName;};// ******************************************************************************const DOMString* KissNode::nodeValue() const {  return 0;};// ******************************************************************************void KissNode::setNodeValue(			    const DOMString& newNodeValue) {};// ******************************************************************************Node* KissNode::parentNode() const {  return myParentNode;};// ******************************************************************************void KissNode::setParentNode(			     Node* newParentNode) {  if(DEBUGKISSDOM) {    printf("KissNode::setParentNode() [%s]\n",nodeName()->c_str());  }  if(myReadOnly) {    throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR);  }  myParentNode = newParentNode;};// ******************************************************************************const NodeList* KissNode::childNodes() const {  return &myKissNodeList;};// ******************************************************************************Node* KissNode::firstChild() const {  return *myNodeList.begin();};// ******************************************************************************Node* KissNode::lastChild() const {  return *myNodeList.end();};// ******************************************************************************Node* KissNode::previousSibling() const {  if(myParentNode == 0) {    return 0;  }  for(unsigned long i = 0; i < myParentNode->childNodes()->length(); i++) {    if((const Node*) myParentNode->childNodes()->item(i) == this) {      return myParentNode->childNodes()->item(i-1);    }  }  return 0;};// ******************************************************************************Node* KissNode::nextSibling() const {  if(myParentNode == 0) {    return 0;  }  for(unsigned long i = 0; i < myParentNode->childNodes()->length(); i++) {    if((const Node*) myParentNode->childNodes()->item(i) == this) {      return myParentNode->childNodes()->item(i+1);    }  }  return 0;};// ******************************************************************************const NamedNodeMap* KissNode::attributes() const {  return 0;};// ******************************************************************************const Document* KissNode::ownerDocument() const {  return myOwnerDocument;};// ******************************************************************************void KissNode::setOwnerDocument(				const Document *const newOwnerDocument) {  if(DEBUGKISSDOM) {    printf("KissNode::setOwnerDocument() [%s]\n",nodeName()->c_str());  }  myOwnerDocument = newOwnerDocument;  myDOMKey = newOwnerDocument->getDOMKey();  for(list<Node*>::const_iterator ppNode = myNodeList.begin(); ppNode != myNodeList.end(); ppNode++) {    (*ppNode)->setOwnerDocument(newOwnerDocument);  }};// ******************************************************************************Node* KissNode::insertBefore(			     Node* newChild,			     Node* refChild) {  if(newChild == 0) {    return 0;  }  if(refChild == 0) {    return(appendChild(newChild));  }  checkChildAddingConstraints1(newChild);  checkChildAddingConstraints2(newChild);  list<Node*>::iterator ppNode = myNodeList.begin();  while((ppNode != myNodeList.end()) &(*ppNode != refChild)) {    ppNode++;  }  if(*ppNode != refChild) {    throw DOMException(DOMException::NOT_FOUND_ERR);  }  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.insert(ppNode,nextChild);    }  }  else {    newChild->setParentNode(this);    myNodeList.insert(ppNode,newChild);  }  return newChild;};// ******************************************************************************Node* KissNode::replaceChild(			     Node* newChild,			     Node* oldChild) {  if(newChild == 0) {    return 0;  }  checkChildAddingConstraints1(newChild);  checkChildAddingConstraints2(newChild);  list<Node*>::iterator ppNode = myNodeList.begin();  while((ppNode != myNodeList.end())&(*ppNode != oldChild)) {    ppNode++;  }  if(*ppNode != oldChild) {    throw DOMException(DOMException::NOT_FOUND_ERR);  }  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.insert(ppNode,nextChild);    }  }  else {    newChild->setParentNode(this);    myNodeList.insert(ppNode,newChild);

⌨️ 快捷键说明

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