1 /* 2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 3 * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET 4 * 5 * Copyright (C) 2012 - 2016 - Scilab Enterprises 6 * 7 * This file is hereby licensed under the terms of the GNU GPL v2.0, 8 * pursuant to article 5.3.4 of the CeCILL v.2.1. 9 * This file was originally licensed under the terms of the CeCILL v2.1, 10 * and continues to be available under such terms. 11 * For more information, see the COPYING file which you should have received 12 * along with this program. 13 * 14 */ 15 16 #ifndef __XMLATTR_HXX__ 17 #define __XMLATTR_HXX__ 18 19 #include <string> 20 #include "dynlib_xml_scilab.h" 21 #include "xml.h" 22 23 namespace org_modules_xml 24 { 25 class XMLElement; 26 class XMLObject; 27 28 class XML_SCILAB_IMPEXP XMLAttr : public XMLObject 29 { 30 const XMLElement & elem; 31 32 public: 33 /** 34 * Default constructor 35 * @param elem the element which has this attributes 36 */ 37 XMLAttr(const XMLElement & elem); 38 39 ~XMLAttr(); 40 41 void *getRealXMLPointer() const; 42 43 /** 44 * Get the number of attributes 45 * @return the attributes number 46 */ 47 int getSize() const; 48 49 /** 50 * Gets the attribute value with the given index. 51 * @param index the attribute index 52 * @return the attribute value 53 */ 54 const char *getAttributeValue(int index) const; 55 56 /** 57 * Gets the attribute value. 58 * @param name the attribute name 59 * @return the attribute value 60 */ 61 const char *getAttributeValue(const char *name) const; 62 63 /** 64 * Gets the attribute value with a prefix namespace. 65 * @param prefix the namespace prefix or the namespace itself 66 * @param name the attribute name 67 * @return the attribute value 68 */ 69 const char *getAttributeValue(const char *prefix, const char *name) const; 70 71 /** 72 * Sets the attribute value. 73 * @param name the attribute name 74 * @param value the attribute value 75 */ 76 void setAttributeValue(const char *name, const char *value) const; 77 78 /** 79 * Sets the attribute value. 80 * @param node the node where to set the attributes 81 * @param name the attribute name 82 * @param value the attribute value 83 */ 84 static void setAttributeValue(xmlNode * node, const char *name, const char *value); 85 86 /** 87 * Sets the attribute value. 88 * @param name the attribute names 89 * @param value the attribute values 90 * @param size the number of names 91 */ 92 void setAttributeValue(const char **name, const char **value, int size) const; 93 94 /** 95 * Sets the attribute value. 96 * @param node the node where to set the attributes 97 * @param name the attribute names 98 * @param value the attribute values 99 * @param size the number of names 100 */ 101 static void setAttributeValue(xmlNode * node, const char **name, const char **value, int size); 102 103 /** 104 * Sets the attribute value at the given index. 105 * @param index the attribute index 106 * @param value the attribute value 107 */ 108 void setAttributeValue(int index, const char *value) const; 109 110 /** 111 * Sets the attribute value at the given index. 112 * @param node the node where to set the attributes 113 * @param index the attribute index 114 * @param value the attribute value 115 */ 116 static void setAttributeValue(xmlNode * node, int index, const char *value); 117 118 /** 119 * Sets the attribute value with a prefix namespace. 120 * @param prefix the namespace prefix or the namespace itself 121 * @param name the attribute name 122 * @param value the attribute value 123 */ 124 void setAttributeValue(const char *prefix, const char *name, const char *value) const; 125 126 /** 127 * Sets the attribute value with a prefix namespace. 128 * @param node the node where to set the attributes 129 * @param prefix the namespace prefix or the namespace itself 130 * @param name the attribute name 131 * @param value the attribute value 132 */ 133 static void setAttributeValue(xmlNode * node, const char *prefix, const char *name, const char *value); 134 135 /** 136 * Sets the attribute value with a prefix namespace. 137 * @param prefix the namespace prefix or the namespace itself 138 * @param name the attribute names 139 * @param value the attribute values 140 * @param size the number of names 141 */ 142 void setAttributeValue(const char **prefix, const char **name, const char **value, int size) const; 143 144 /** 145 * Sets the attribute value with a prefix namespace. 146 * @param node the node where to set the attributes 147 * @param prefix the namespace prefix or the namespace itself 148 * @param name the attribute names 149 * @param value the attribute values 150 * @param size the number of names 151 */ 152 static void setAttributeValue(xmlNode * node, const char **prefix, const char **name, const char **value, int size); 153 154 /** 155 * @return the names of the attributes 156 */ 157 const char ** getNames() const; 158 159 /** 160 * Gets the element associated with this object 161 * @return the associated object 162 */ getElement() const163 const XMLElement & getElement() const 164 { 165 return elem; 166 } 167 168 const XMLObject *getXMLObjectParent() const; 169 const std::string toString() const; 170 171 /** 172 * Get the number of attributes 173 * @return the attributes number 174 */ 175 static int getSize(xmlAttr * attr); 176 }; 177 } 178 179 #endif 180