| OLD | NEW |
| 1 /* | 1 /* |
| 2 ******************************************************************************* | 2 ******************************************************************************* |
| 3 * | 3 * |
| 4 * Copyright (C) 2004-2010, International Business Machines | 4 * Copyright (C) 2004-2010, International Business Machines |
| 5 * Corporation and others. All Rights Reserved. | 5 * Corporation and others. All Rights Reserved. |
| 6 * | 6 * |
| 7 ******************************************************************************* | 7 ******************************************************************************* |
| 8 * file name: xmlparser.cpp | 8 * file name: xmlparser.cpp |
| 9 * encoding: US-ASCII | 9 * encoding: US-ASCII |
| 10 * tab size: 8 (not used) | 10 * tab size: 8 (not used) |
| (...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 appendText(text, recurse); | 708 appendText(text, recurse); |
| 709 return text; | 709 return text; |
| 710 } | 710 } |
| 711 | 711 |
| 712 void | 712 void |
| 713 UXMLElement::appendText(UnicodeString &text, UBool recurse) const { | 713 UXMLElement::appendText(UnicodeString &text, UBool recurse) const { |
| 714 const UObject *node; | 714 const UObject *node; |
| 715 int32_t i, count=fChildren.size(); | 715 int32_t i, count=fChildren.size(); |
| 716 for(i=0; i<count; ++i) { | 716 for(i=0; i<count; ++i) { |
| 717 node=(const UObject *)fChildren.elementAt(i); | 717 node=(const UObject *)fChildren.elementAt(i); |
| 718 const UnicodeString *s=dynamic_cast<const UnicodeString *>(node); | 718 const UnicodeString *s=CR_DYNAMIC_CAST<const UnicodeString *>(node); |
| 719 if(s!=NULL) { | 719 if(s!=NULL) { |
| 720 text.append(*s); | 720 text.append(*s); |
| 721 } else if(recurse) /* must be a UXMLElement */ { | 721 } else if(recurse) /* must be a UXMLElement */ { |
| 722 ((const UXMLElement *)node)->appendText(text, recurse); | 722 ((const UXMLElement *)node)->appendText(text, recurse); |
| 723 } | 723 } |
| 724 } | 724 } |
| 725 } | 725 } |
| 726 | 726 |
| 727 int32_t | 727 int32_t |
| 728 UXMLElement::countAttributes() const { | 728 UXMLElement::countAttributes() const { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 | 760 |
| 761 int32_t | 761 int32_t |
| 762 UXMLElement::countChildren() const { | 762 UXMLElement::countChildren() const { |
| 763 return fChildren.size(); | 763 return fChildren.size(); |
| 764 } | 764 } |
| 765 | 765 |
| 766 const UObject * | 766 const UObject * |
| 767 UXMLElement::getChild(int32_t i, UXMLNodeType &type) const { | 767 UXMLElement::getChild(int32_t i, UXMLNodeType &type) const { |
| 768 if(0<=i && i<fChildren.size()) { | 768 if(0<=i && i<fChildren.size()) { |
| 769 const UObject *node=(const UObject *)fChildren.elementAt(i); | 769 const UObject *node=(const UObject *)fChildren.elementAt(i); |
| 770 if(dynamic_cast<const UXMLElement *>(node)!=NULL) { | 770 if(CR_DYNAMIC_CAST<const UXMLElement *>(node)!=NULL) { |
| 771 type=UXML_NODE_TYPE_ELEMENT; | 771 type=UXML_NODE_TYPE_ELEMENT; |
| 772 } else { | 772 } else { |
| 773 type=UXML_NODE_TYPE_STRING; | 773 type=UXML_NODE_TYPE_STRING; |
| 774 } | 774 } |
| 775 return node; | 775 return node; |
| 776 } else { | 776 } else { |
| 777 return NULL; | 777 return NULL; |
| 778 } | 778 } |
| 779 } | 779 } |
| 780 | 780 |
| 781 const UXMLElement * | 781 const UXMLElement * |
| 782 UXMLElement::nextChildElement(int32_t &i) const { | 782 UXMLElement::nextChildElement(int32_t &i) const { |
| 783 if(i<0) { | 783 if(i<0) { |
| 784 return NULL; | 784 return NULL; |
| 785 } | 785 } |
| 786 | 786 |
| 787 const UObject *node; | 787 const UObject *node; |
| 788 int32_t count=fChildren.size(); | 788 int32_t count=fChildren.size(); |
| 789 while(i<count) { | 789 while(i<count) { |
| 790 node=(const UObject *)fChildren.elementAt(i++); | 790 node=(const UObject *)fChildren.elementAt(i++); |
| 791 const UXMLElement *elem=dynamic_cast<const UXMLElement *>(node); | 791 const UXMLElement *elem=CR_DYNAMIC_CAST<const UXMLElement *>(node); |
| 792 if(elem!=NULL) { | 792 if(elem!=NULL) { |
| 793 return elem; | 793 return elem; |
| 794 } | 794 } |
| 795 } | 795 } |
| 796 return NULL; | 796 return NULL; |
| 797 } | 797 } |
| 798 | 798 |
| 799 const UXMLElement * | 799 const UXMLElement * |
| 800 UXMLElement::getChildElement(const UnicodeString &name) const { | 800 UXMLElement::getChildElement(const UnicodeString &name) const { |
| 801 // search for the element name by comparing the interned pointer, | 801 // search for the element name by comparing the interned pointer, |
| 802 // not the string contents | 802 // not the string contents |
| 803 const UnicodeString *p=fParser->findName(name); | 803 const UnicodeString *p=fParser->findName(name); |
| 804 if(p==NULL) { | 804 if(p==NULL) { |
| 805 return NULL; // no such element seen by the parser at all | 805 return NULL; // no such element seen by the parser at all |
| 806 } | 806 } |
| 807 | 807 |
| 808 const UObject *node; | 808 const UObject *node; |
| 809 int32_t i, count=fChildren.size(); | 809 int32_t i, count=fChildren.size(); |
| 810 for(i=0; i<count; ++i) { | 810 for(i=0; i<count; ++i) { |
| 811 node=(const UObject *)fChildren.elementAt(i); | 811 node=(const UObject *)fChildren.elementAt(i); |
| 812 const UXMLElement *elem=dynamic_cast<const UXMLElement *>(node); | 812 const UXMLElement *elem=CR_DYNAMIC_CAST<const UXMLElement *>(node); |
| 813 if(elem!=NULL) { | 813 if(elem!=NULL) { |
| 814 if(p==elem->fName) { | 814 if(p==elem->fName) { |
| 815 return elem; | 815 return elem; |
| 816 } | 816 } |
| 817 } | 817 } |
| 818 } | 818 } |
| 819 return NULL; | 819 return NULL; |
| 820 } | 820 } |
| 821 | 821 |
| 822 U_NAMESPACE_END | 822 U_NAMESPACE_END |
| 823 | 823 |
| 824 #endif /* !UCONFIG_NO_REGULAR_EXPRESSIONS */ | 824 #endif /* !UCONFIG_NO_REGULAR_EXPRESSIONS */ |
| 825 | 825 |
| OLD | NEW |