1 //------------------------------------------------------------------------------ 2 // <auto-generated /> 3 // 4 // This file was automatically generated by SWIG (http://www.swig.org). 5 // Version 4.0.2 6 // 7 // Do not make changes to this file unless you know what you are doing--modify 8 // the SWIG interface file instead. 9 //------------------------------------------------------------------------------ 10 11 namespace libsbml { 12 13 using System; 14 using System.Runtime.InteropServices; 15 16 /** 17 * @sbmlpackage{core} 18 * 19 @htmlinclude pkg-marker-core.html A list of attributes on an XML element. 20 * 21 * @htmlinclude not-sbml-warning.html 22 * 23 * In libSBML's XML interface layer, attributes on an element are stored as a 24 * list of values kept in an XMLAttributes object. XMLAttributes has methods 25 * for adding and removing individual attributes as well as performing other 26 * actions on the list of attributes. Classes in libSBML that represent nodes 27 * in an XML document (i.e., XMLNode and its parent class, XMLToken) use 28 * XMLAttributes objects to manage attributes on XML elements. 29 * 30 * Attributes on an XML element can be written in one of two forms: 31 * @li <code>name='value'</code> 32 * @li <code>prefix:name='value'</code> 33 * 34 * An attribute in XML must always have a value, and the value must always be 35 * a quoted string; i.e., it is always <code>name='value'</code> and not 36 * <code>name=value</code>. An empty value is represented simply as an 37 * empty string; i.e., <code>name=''</code>. 38 * 39 * In cases when a <code>prefix</code> is provided with an attribute name, 40 * general XML validity rules require that the prefix is an XML namespace 41 * prefix that has been declared somewhere else (possibly as an another 42 * attribute on the same element). However, the XMLAttributes class does 43 * @em not test for the proper existence or declaration of XML 44 * namespaces—callers must arrange to do this themselves in some other 45 * way. This class only provides facilities for tracking and manipulating 46 * attributes and their prefix/URI/name/value components. 47 * 48 * 49 * @note Note that although XMLAttributes provides operations that can 50 * manipulate attributes based on a numerical index, XML attributes are in 51 * fact unordered when they appear in files and data streams. The 52 * XMLAttributes class provides some list-like facilities, but it is only for 53 * the convenience of callers. (For example, it permits callers to loop 54 * across all attributes more easily.) Users should keep in mind that the 55 * order in which attributes are stored in XMLAttributes objects has no real 56 * impact on the order in which the attributes are read or written from an 57 * XML file or data stream. 58 * 59 * 60 * 61 * @see XMLTriple 62 * @see XMLNode 63 * @see XMLToken 64 */ 65 66 public class XMLAttributes : global::System.IDisposable { 67 private HandleRef swigCPtr; 68 protected bool swigCMemOwn; 69 XMLAttributes(IntPtr cPtr, bool cMemoryOwn)70 internal XMLAttributes(IntPtr cPtr, bool cMemoryOwn) 71 { 72 swigCMemOwn = cMemoryOwn; 73 swigCPtr = new HandleRef(this, cPtr); 74 } 75 getCPtr(XMLAttributes obj)76 internal static HandleRef getCPtr(XMLAttributes obj) 77 { 78 return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; 79 } 80 getCPtrAndDisown(XMLAttributes obj)81 internal static HandleRef getCPtrAndDisown (XMLAttributes obj) 82 { 83 HandleRef ptr = new HandleRef(null, IntPtr.Zero); 84 85 if (obj != null) 86 { 87 ptr = obj.swigCPtr; 88 obj.swigCMemOwn = false; 89 } 90 91 return ptr; 92 } 93 ~XMLAttributes()94 ~XMLAttributes() { 95 Dispose(false); 96 } 97 Dispose()98 public void Dispose() { 99 Dispose(true); 100 global::System.GC.SuppressFinalize(this); 101 } 102 Dispose(bool disposing)103 protected virtual void Dispose(bool disposing) { 104 lock(this) { 105 if (swigCPtr.Handle != global::System.IntPtr.Zero) { 106 if (swigCMemOwn) { 107 swigCMemOwn = false; 108 libsbmlPINVOKE.delete_XMLAttributes(swigCPtr); 109 } 110 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); 111 } 112 } 113 } 114 operator ==(XMLAttributes lhs, XMLAttributes rhs)115 public static bool operator==(XMLAttributes lhs, XMLAttributes rhs) 116 { 117 if((Object)lhs == (Object)rhs) 118 { 119 return true; 120 } 121 122 if( ((Object)lhs == null) || ((Object)rhs == null) ) 123 { 124 return false; 125 } 126 127 return (getCPtr(lhs).Handle.ToString() == getCPtr(rhs).Handle.ToString()); 128 } 129 operator !=(XMLAttributes lhs, XMLAttributes rhs)130 public static bool operator!=(XMLAttributes lhs, XMLAttributes rhs) 131 { 132 return !(lhs == rhs); 133 } 134 Equals(Object sb)135 public override bool Equals(Object sb) 136 { 137 if ( ! (sb is XMLAttributes) ) 138 { 139 return false; 140 } 141 142 return this == (XMLAttributes)sb; 143 } 144 GetHashCode()145 public override int GetHashCode() 146 { 147 return swigCPtr.Handle.ToInt32(); 148 } 149 150 151 /** 152 * Creates a new, empty XMLAttributes object. 153 */ public XMLAttributes()154 XMLAttributes() : this(libsbmlPINVOKE.new_XMLAttributes__SWIG_0(), true) { 155 if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); 156 } 157 158 159 /** 160 * Copy constructor; creates a copy of this XMLAttributes object. 161 * 162 * @p orig the XMLAttributes object to copy. 163 */ public XMLAttributes(XMLAttributes orig)164 XMLAttributes(XMLAttributes orig) : this(libsbmlPINVOKE.new_XMLAttributes__SWIG_1(XMLAttributes.getCPtr(orig)), true) { 165 if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); 166 } 167 168 169 /** 170 * Creates and returns a deep copy of this XMLAttributes object. 171 * 172 * @return the (deep) copy of this XMLAttributes object. 173 */ public clone()174 XMLAttributes clone() { 175 global::System.IntPtr cPtr = libsbmlPINVOKE.XMLAttributes_clone(swigCPtr); 176 XMLAttributes ret = (cPtr == global::System.IntPtr.Zero) ? null : new XMLAttributes(cPtr, true); 177 return ret; 178 } 179 180 181 /** 182 * Adds an attribute to this list of attributes. 183 * 184 * 185 * 186 * Some explanations are in order about the behavior of XMLAttributes with 187 * respect to namespace prefixes and namespace URIs. XMLAttributes does @em 188 * not verify the consistency of different uses of an XML namespace and the 189 * prefix used to refer to it in a given context. It cannot, because the 190 * prefix used for a given XML namespace in an XML document may intentionally 191 * be different on different elements in the document. Consequently, callers 192 * need to manage their own prefix-to-namespace mappings, and need to ensure 193 * that the desired prefix is used in any given context. 194 * 195 * When called with attribute names, prefixes and namespace URIs, 196 * XMLAttributes pays attention to the namespace URIs and not the prefixes: a 197 * match is established by a combination of attribute name and namespace URI, 198 * and if on different occasions a different prefix is used for the same 199 * name/namespace combination, the prefix associated with the namespace on 200 * that attribute is overwritten. 201 * 202 * Some examples will hopefully clarify this. Here are the results of a 203 * sequence of calls to the XMLAttributes <code>add</code> methods with 204 * different argument combinations. First, we create the object and add 205 * one attribute: 206 * 207 * @code{.cpp} 208 XMLAttributes att = new XMLAttributes(); 209 att->add('myattribute', '1', 'myuri'); 210 @endcode 211 * The above adds an attribute named <code>myattribute</code> in the namespace 212 * <code>myuri</code>, and with the attribute value <code>1</code>. No 213 * namespace prefix is associated with the attribute (but the attribute is 214 * recorded to exist in the namespace <code>myuri</code>). If 215 * this attribute object were written out in XML, it would look like the 216 * following (and note that, since no namespace prefix was assigned, none 217 * is written out): 218 * <center><pre> 219 myattribute='1' 220 * </pre></center> 221 * 222 * Continuing with this series of examples, suppose we invoke the 223 * <code>add</code> method again as follows: 224 * 225 * @code{.cpp} 226 att->add('myattribute', '2'); 227 @endcode 228 * The above adds a @em new attribute @em also named <code>myattribute</code>, 229 * but in a different XML namespace: it is placed in the namespace with no 230 * URI, which is to say, the default XML namespace. Both attributes coexist 231 * on this XMLAttributes object; both can be independently retrieved. 232 * 233 * @code{.cpp} 234 att->add('myattribute', '3'); 235 @endcode 236 * The code above now replaces the value of the attribute 237 * <code>myattribute</code> that resides in the default namespace. The 238 * attribute in the namespace <code>myuri</code> remains untouched. 239 * 240 * @code{.cpp} 241 att->add('myattribute', '4', 'myuri'); 242 @endcode 243 * The code above replaces the value of the attribute 244 * <code>myattribute</code> that resides in the <code>myuri</code> namespace. 245 * The attribute in the default namespace remains untouched. 246 * 247 * @code{.cpp} 248 att->add('myattribute', '5', 'myuri', 'foo'); 249 @endcode 250 * The code above replaces the value of the attribute 251 * <code>myattribute</code> that resides in the <code>myuri</code> namespace. 252 * It also now assigns a namespace prefix, <code>foo</code>, to the attribute. 253 * The attribute <code>myattribute</code> in the default namespace remains 254 * untouched. If this XMLAttributes object were written out in XML, it would 255 * look like the following: 256 * <center><pre> 257 myattribute='3' 258 foo:myattribute='5' 259 * </pre></center> 260 * Pressing on, now suppose we call the <code>add</code> method as follows: 261 * 262 * @code{.cpp} 263 att->add('myattribute', '6', 'myuri', 'bar'); 264 @endcode 265 * The code above replaces the value of the attribute 266 * <code>myattribute</code> that resides in the <code>myuri</code> namespace. 267 * It also assigns a different prefix to the attribute. The namespace of 268 * the attribute remains <code>myuri</code>. 269 * 270 * @code{.cpp} 271 att->add('myattribute', '7', '', 'foo'); 272 @endcode 273 274 * The code above replaces the value of the attribute 275 * <code>myattribute</code> that resides in the default namespace. It also 276 * now assigns a namespace prefix, <code>foo</code>, to that attribute. If 277 * this XMLAttributes object were written out in XML, it would look like the 278 * following: 279 * <center><pre> 280 bar:myattribute='6' 281 foo:myattribute='7' 282 * </pre></center> 283 * 284 * @param name a string, the unprefixed name of the attribute. 285 * @param value a string, the value of the attribute. 286 * @param namespaceURI a string, the namespace URI of the attribute. 287 * @param prefix a string, a prefix for the XML namespace. 288 * 289 * 290 * @return integer value indicating success/failure of the 291 * function. @if clike The value is drawn from the 292 * enumeration #OperationReturnValues_t. @endif The possible values 293 * returned by this function are: 294 * @li @link libsbml#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink 295 * @li @link libsbml#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT@endlink 296 * – this value is returned if any of the arguments are @c null. To 297 * set an empty @p prefix and/or @p name value, use an empty string rather 298 * than @c null. 299 * 300 * 301 * @note If an attribute with the same name and XML namespace URI already 302 * exists in the list of attributes held by this XMLAttributes object, then 303 * the previous value of that attribute will be replaced with the new value 304 * provided to this method. 305 * 306 * 307 * 308 * @ifnot hasDefaultArgs @htmlinclude warn-default-args-in-docs.html @endif 309 * 310 * @see add(XMLTriple triple, string value) 311 * @see getIndex(string name, string uri) 312 * @see getIndex(XMLTriple triple) 313 * @see hasAttribute(string name, string uri) 314 * @see hasAttribute(XMLTriple triple) 315 */ public add(string name, string value, string namespaceURI, string prefix)316 int add(string name, string value, string namespaceURI, string prefix) { 317 int ret = libsbmlPINVOKE.XMLAttributes_add__SWIG_0(swigCPtr, name, value, namespaceURI, prefix); 318 return ret; 319 } 320 321 322 /** 323 * Adds an attribute to this list of attributes. 324 * 325 * 326 * 327 * Some explanations are in order about the behavior of XMLAttributes with 328 * respect to namespace prefixes and namespace URIs. XMLAttributes does @em 329 * not verify the consistency of different uses of an XML namespace and the 330 * prefix used to refer to it in a given context. It cannot, because the 331 * prefix used for a given XML namespace in an XML document may intentionally 332 * be different on different elements in the document. Consequently, callers 333 * need to manage their own prefix-to-namespace mappings, and need to ensure 334 * that the desired prefix is used in any given context. 335 * 336 * When called with attribute names, prefixes and namespace URIs, 337 * XMLAttributes pays attention to the namespace URIs and not the prefixes: a 338 * match is established by a combination of attribute name and namespace URI, 339 * and if on different occasions a different prefix is used for the same 340 * name/namespace combination, the prefix associated with the namespace on 341 * that attribute is overwritten. 342 * 343 * Some examples will hopefully clarify this. Here are the results of a 344 * sequence of calls to the XMLAttributes <code>add</code> methods with 345 * different argument combinations. First, we create the object and add 346 * one attribute: 347 * 348 * @code{.cpp} 349 XMLAttributes att = new XMLAttributes(); 350 att->add('myattribute', '1', 'myuri'); 351 @endcode 352 * The above adds an attribute named <code>myattribute</code> in the namespace 353 * <code>myuri</code>, and with the attribute value <code>1</code>. No 354 * namespace prefix is associated with the attribute (but the attribute is 355 * recorded to exist in the namespace <code>myuri</code>). If 356 * this attribute object were written out in XML, it would look like the 357 * following (and note that, since no namespace prefix was assigned, none 358 * is written out): 359 * <center><pre> 360 myattribute='1' 361 * </pre></center> 362 * 363 * Continuing with this series of examples, suppose we invoke the 364 * <code>add</code> method again as follows: 365 * 366 * @code{.cpp} 367 att->add('myattribute', '2'); 368 @endcode 369 * The above adds a @em new attribute @em also named <code>myattribute</code>, 370 * but in a different XML namespace: it is placed in the namespace with no 371 * URI, which is to say, the default XML namespace. Both attributes coexist 372 * on this XMLAttributes object; both can be independently retrieved. 373 * 374 * @code{.cpp} 375 att->add('myattribute', '3'); 376 @endcode 377 * The code above now replaces the value of the attribute 378 * <code>myattribute</code> that resides in the default namespace. The 379 * attribute in the namespace <code>myuri</code> remains untouched. 380 * 381 * @code{.cpp} 382 att->add('myattribute', '4', 'myuri'); 383 @endcode 384 * The code above replaces the value of the attribute 385 * <code>myattribute</code> that resides in the <code>myuri</code> namespace. 386 * The attribute in the default namespace remains untouched. 387 * 388 * @code{.cpp} 389 att->add('myattribute', '5', 'myuri', 'foo'); 390 @endcode 391 * The code above replaces the value of the attribute 392 * <code>myattribute</code> that resides in the <code>myuri</code> namespace. 393 * It also now assigns a namespace prefix, <code>foo</code>, to the attribute. 394 * The attribute <code>myattribute</code> in the default namespace remains 395 * untouched. If this XMLAttributes object were written out in XML, it would 396 * look like the following: 397 * <center><pre> 398 myattribute='3' 399 foo:myattribute='5' 400 * </pre></center> 401 * Pressing on, now suppose we call the <code>add</code> method as follows: 402 * 403 * @code{.cpp} 404 att->add('myattribute', '6', 'myuri', 'bar'); 405 @endcode 406 * The code above replaces the value of the attribute 407 * <code>myattribute</code> that resides in the <code>myuri</code> namespace. 408 * It also assigns a different prefix to the attribute. The namespace of 409 * the attribute remains <code>myuri</code>. 410 * 411 * @code{.cpp} 412 att->add('myattribute', '7', '', 'foo'); 413 @endcode 414 415 * The code above replaces the value of the attribute 416 * <code>myattribute</code> that resides in the default namespace. It also 417 * now assigns a namespace prefix, <code>foo</code>, to that attribute. If 418 * this XMLAttributes object were written out in XML, it would look like the 419 * following: 420 * <center><pre> 421 bar:myattribute='6' 422 foo:myattribute='7' 423 * </pre></center> 424 * 425 * @param name a string, the unprefixed name of the attribute. 426 * @param value a string, the value of the attribute. 427 * @param namespaceURI a string, the namespace URI of the attribute. 428 * @param prefix a string, a prefix for the XML namespace. 429 * 430 * 431 * @return integer value indicating success/failure of the 432 * function. @if clike The value is drawn from the 433 * enumeration #OperationReturnValues_t. @endif The possible values 434 * returned by this function are: 435 * @li @link libsbml#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink 436 * @li @link libsbml#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT@endlink 437 * – this value is returned if any of the arguments are @c null. To 438 * set an empty @p prefix and/or @p name value, use an empty string rather 439 * than @c null. 440 * 441 * 442 * @note If an attribute with the same name and XML namespace URI already 443 * exists in the list of attributes held by this XMLAttributes object, then 444 * the previous value of that attribute will be replaced with the new value 445 * provided to this method. 446 * 447 * 448 * 449 * @ifnot hasDefaultArgs @htmlinclude warn-default-args-in-docs.html @endif 450 * 451 * @see add(XMLTriple triple, string value) 452 * @see getIndex(string name, string uri) 453 * @see getIndex(XMLTriple triple) 454 * @see hasAttribute(string name, string uri) 455 * @see hasAttribute(XMLTriple triple) 456 */ public add(string name, string value, string namespaceURI)457 int add(string name, string value, string namespaceURI) { 458 int ret = libsbmlPINVOKE.XMLAttributes_add__SWIG_1(swigCPtr, name, value, namespaceURI); 459 return ret; 460 } 461 462 463 /** 464 * Adds an attribute to this list of attributes. 465 * 466 * 467 * 468 * Some explanations are in order about the behavior of XMLAttributes with 469 * respect to namespace prefixes and namespace URIs. XMLAttributes does @em 470 * not verify the consistency of different uses of an XML namespace and the 471 * prefix used to refer to it in a given context. It cannot, because the 472 * prefix used for a given XML namespace in an XML document may intentionally 473 * be different on different elements in the document. Consequently, callers 474 * need to manage their own prefix-to-namespace mappings, and need to ensure 475 * that the desired prefix is used in any given context. 476 * 477 * When called with attribute names, prefixes and namespace URIs, 478 * XMLAttributes pays attention to the namespace URIs and not the prefixes: a 479 * match is established by a combination of attribute name and namespace URI, 480 * and if on different occasions a different prefix is used for the same 481 * name/namespace combination, the prefix associated with the namespace on 482 * that attribute is overwritten. 483 * 484 * Some examples will hopefully clarify this. Here are the results of a 485 * sequence of calls to the XMLAttributes <code>add</code> methods with 486 * different argument combinations. First, we create the object and add 487 * one attribute: 488 * 489 * @code{.cpp} 490 XMLAttributes att = new XMLAttributes(); 491 att->add('myattribute', '1', 'myuri'); 492 @endcode 493 * The above adds an attribute named <code>myattribute</code> in the namespace 494 * <code>myuri</code>, and with the attribute value <code>1</code>. No 495 * namespace prefix is associated with the attribute (but the attribute is 496 * recorded to exist in the namespace <code>myuri</code>). If 497 * this attribute object were written out in XML, it would look like the 498 * following (and note that, since no namespace prefix was assigned, none 499 * is written out): 500 * <center><pre> 501 myattribute='1' 502 * </pre></center> 503 * 504 * Continuing with this series of examples, suppose we invoke the 505 * <code>add</code> method again as follows: 506 * 507 * @code{.cpp} 508 att->add('myattribute', '2'); 509 @endcode 510 * The above adds a @em new attribute @em also named <code>myattribute</code>, 511 * but in a different XML namespace: it is placed in the namespace with no 512 * URI, which is to say, the default XML namespace. Both attributes coexist 513 * on this XMLAttributes object; both can be independently retrieved. 514 * 515 * @code{.cpp} 516 att->add('myattribute', '3'); 517 @endcode 518 * The code above now replaces the value of the attribute 519 * <code>myattribute</code> that resides in the default namespace. The 520 * attribute in the namespace <code>myuri</code> remains untouched. 521 * 522 * @code{.cpp} 523 att->add('myattribute', '4', 'myuri'); 524 @endcode 525 * The code above replaces the value of the attribute 526 * <code>myattribute</code> that resides in the <code>myuri</code> namespace. 527 * The attribute in the default namespace remains untouched. 528 * 529 * @code{.cpp} 530 att->add('myattribute', '5', 'myuri', 'foo'); 531 @endcode 532 * The code above replaces the value of the attribute 533 * <code>myattribute</code> that resides in the <code>myuri</code> namespace. 534 * It also now assigns a namespace prefix, <code>foo</code>, to the attribute. 535 * The attribute <code>myattribute</code> in the default namespace remains 536 * untouched. If this XMLAttributes object were written out in XML, it would 537 * look like the following: 538 * <center><pre> 539 myattribute='3' 540 foo:myattribute='5' 541 * </pre></center> 542 * Pressing on, now suppose we call the <code>add</code> method as follows: 543 * 544 * @code{.cpp} 545 att->add('myattribute', '6', 'myuri', 'bar'); 546 @endcode 547 * The code above replaces the value of the attribute 548 * <code>myattribute</code> that resides in the <code>myuri</code> namespace. 549 * It also assigns a different prefix to the attribute. The namespace of 550 * the attribute remains <code>myuri</code>. 551 * 552 * @code{.cpp} 553 att->add('myattribute', '7', '', 'foo'); 554 @endcode 555 556 * The code above replaces the value of the attribute 557 * <code>myattribute</code> that resides in the default namespace. It also 558 * now assigns a namespace prefix, <code>foo</code>, to that attribute. If 559 * this XMLAttributes object were written out in XML, it would look like the 560 * following: 561 * <center><pre> 562 bar:myattribute='6' 563 foo:myattribute='7' 564 * </pre></center> 565 * 566 * @param name a string, the unprefixed name of the attribute. 567 * @param value a string, the value of the attribute. 568 * @param namespaceURI a string, the namespace URI of the attribute. 569 * @param prefix a string, a prefix for the XML namespace. 570 * 571 * 572 * @return integer value indicating success/failure of the 573 * function. @if clike The value is drawn from the 574 * enumeration #OperationReturnValues_t. @endif The possible values 575 * returned by this function are: 576 * @li @link libsbml#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink 577 * @li @link libsbml#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT@endlink 578 * – this value is returned if any of the arguments are @c null. To 579 * set an empty @p prefix and/or @p name value, use an empty string rather 580 * than @c null. 581 * 582 * 583 * @note If an attribute with the same name and XML namespace URI already 584 * exists in the list of attributes held by this XMLAttributes object, then 585 * the previous value of that attribute will be replaced with the new value 586 * provided to this method. 587 * 588 * 589 * 590 * @ifnot hasDefaultArgs @htmlinclude warn-default-args-in-docs.html @endif 591 * 592 * @see add(XMLTriple triple, string value) 593 * @see getIndex(string name, string uri) 594 * @see getIndex(XMLTriple triple) 595 * @see hasAttribute(string name, string uri) 596 * @see hasAttribute(XMLTriple triple) 597 */ public add(string name, string value)598 int add(string name, string value) { 599 int ret = libsbmlPINVOKE.XMLAttributes_add__SWIG_2(swigCPtr, name, value); 600 return ret; 601 } 602 603 604 /** 605 * Adds an attribute to this list of attributes. 606 * 607 * 608 * 609 * Some explanations are in order about the behavior of XMLAttributes with 610 * respect to namespace prefixes and namespace URIs. XMLAttributes does @em 611 * not verify the consistency of different uses of an XML namespace and the 612 * prefix used to refer to it in a given context. It cannot, because the 613 * prefix used for a given XML namespace in an XML document may intentionally 614 * be different on different elements in the document. Consequently, callers 615 * need to manage their own prefix-to-namespace mappings, and need to ensure 616 * that the desired prefix is used in any given context. 617 * 618 * When called with attribute names, prefixes and namespace URIs, 619 * XMLAttributes pays attention to the namespace URIs and not the prefixes: a 620 * match is established by a combination of attribute name and namespace URI, 621 * and if on different occasions a different prefix is used for the same 622 * name/namespace combination, the prefix associated with the namespace on 623 * that attribute is overwritten. 624 * 625 * Some examples will hopefully clarify this. Here are the results of a 626 * sequence of calls to the XMLAttributes <code>add</code> methods with 627 * different argument combinations. First, we create the object and add 628 * one attribute: 629 * 630 * @code{.cpp} 631 XMLAttributes att = new XMLAttributes(); 632 att->add('myattribute', '1', 'myuri'); 633 @endcode 634 * The above adds an attribute named <code>myattribute</code> in the namespace 635 * <code>myuri</code>, and with the attribute value <code>1</code>. No 636 * namespace prefix is associated with the attribute (but the attribute is 637 * recorded to exist in the namespace <code>myuri</code>). If 638 * this attribute object were written out in XML, it would look like the 639 * following (and note that, since no namespace prefix was assigned, none 640 * is written out): 641 * <center><pre> 642 myattribute='1' 643 * </pre></center> 644 * 645 * Continuing with this series of examples, suppose we invoke the 646 * <code>add</code> method again as follows: 647 * 648 * @code{.cpp} 649 att->add('myattribute', '2'); 650 @endcode 651 * The above adds a @em new attribute @em also named <code>myattribute</code>, 652 * but in a different XML namespace: it is placed in the namespace with no 653 * URI, which is to say, the default XML namespace. Both attributes coexist 654 * on this XMLAttributes object; both can be independently retrieved. 655 * 656 * @code{.cpp} 657 att->add('myattribute', '3'); 658 @endcode 659 * The code above now replaces the value of the attribute 660 * <code>myattribute</code> that resides in the default namespace. The 661 * attribute in the namespace <code>myuri</code> remains untouched. 662 * 663 * @code{.cpp} 664 att->add('myattribute', '4', 'myuri'); 665 @endcode 666 * The code above replaces the value of the attribute 667 * <code>myattribute</code> that resides in the <code>myuri</code> namespace. 668 * The attribute in the default namespace remains untouched. 669 * 670 * @code{.cpp} 671 att->add('myattribute', '5', 'myuri', 'foo'); 672 @endcode 673 * The code above replaces the value of the attribute 674 * <code>myattribute</code> that resides in the <code>myuri</code> namespace. 675 * It also now assigns a namespace prefix, <code>foo</code>, to the attribute. 676 * The attribute <code>myattribute</code> in the default namespace remains 677 * untouched. If this XMLAttributes object were written out in XML, it would 678 * look like the following: 679 * <center><pre> 680 myattribute='3' 681 foo:myattribute='5' 682 * </pre></center> 683 * Pressing on, now suppose we call the <code>add</code> method as follows: 684 * 685 * @code{.cpp} 686 att->add('myattribute', '6', 'myuri', 'bar'); 687 @endcode 688 * The code above replaces the value of the attribute 689 * <code>myattribute</code> that resides in the <code>myuri</code> namespace. 690 * It also assigns a different prefix to the attribute. The namespace of 691 * the attribute remains <code>myuri</code>. 692 * 693 * @code{.cpp} 694 att->add('myattribute', '7', '', 'foo'); 695 @endcode 696 697 * The code above replaces the value of the attribute 698 * <code>myattribute</code> that resides in the default namespace. It also 699 * now assigns a namespace prefix, <code>foo</code>, to that attribute. If 700 * this XMLAttributes object were written out in XML, it would look like the 701 * following: 702 * <center><pre> 703 bar:myattribute='6' 704 foo:myattribute='7' 705 * </pre></center> 706 * 707 * @param triple an XMLTriple object describing the attribute to be added. 708 * @param value a string, the value of the attribute. 709 * 710 * 711 * @return integer value indicating success/failure of the 712 * function. @if clike The value is drawn from the 713 * enumeration #OperationReturnValues_t. @endif The possible values 714 * returned by this function are: 715 * @li @link libsbml#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink 716 * @li @link libsbml#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT@endlink 717 * – this value is returned if any of the arguments are @c null. To 718 * set an empty value for the attribute, use an empty string rather than 719 * @c null. 720 * 721 * 722 * @note If an attribute with the same name and XML namespace URI already 723 * exists in the list of attributes held by this XMLAttributes object, then 724 * the previous value of that attribute will be replaced with the new value 725 * provided to this method. 726 * 727 * 728 * 729 * @see add(string name, string value, string namespaceURI, string prefix) 730 * @see getIndex(string name, string uri) 731 * @see getIndex(XMLTriple triple) 732 * @see hasAttribute(string name, string uri) 733 * @see hasAttribute(XMLTriple triple) 734 */ public add(XMLTriple triple, string value)735 int add(XMLTriple triple, string value) { 736 int ret = libsbmlPINVOKE.XMLAttributes_add__SWIG_3(swigCPtr, XMLTriple.getCPtr(triple), value); 737 if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); 738 return ret; 739 } 740 741 742 /** */ /* libsbml-internal */ public removeResource(int n)743 int removeResource(int n) { 744 int ret = libsbmlPINVOKE.XMLAttributes_removeResource(swigCPtr, n); 745 return ret; 746 } 747 748 749 /** 750 * Removes the <em>n</em>th attribute from this list of attributes. 751 * 752 * @param n an integer the index of the resource to be deleted. 753 * 754 * 755 * @return integer value indicating success/failure of the 756 * function. @if clike The value is drawn from the 757 * enumeration #OperationReturnValues_t. @endif The possible values 758 * returned by this function are: 759 * @li @link libsbml#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink 760 * @li @link libsbml#LIBSBML_INDEX_EXCEEDS_SIZE LIBSBML_INDEX_EXCEEDS_SIZE@endlink 761 * 762 * The value @link libsbml#LIBSBML_INDEX_EXCEEDS_SIZE LIBSBML_INDEX_EXCEEDS_SIZE@endlink is returned if there is no attribute at the 763 * given index @p n. 764 * 765 * 766 * @note Note that although XMLAttributes provides operations that can 767 * manipulate attributes based on a numerical index, XML attributes are in 768 * fact unordered when they appear in files and data streams. The 769 * XMLAttributes class provides some list-like facilities, but it is only for 770 * the convenience of callers. (For example, it permits callers to loop 771 * across all attributes more easily.) Users should keep in mind that the 772 * order in which attributes are stored in XMLAttributes objects has no real 773 * impact on the order in which the attributes are read or written from an 774 * XML file or data stream. 775 * 776 * 777 * 778 * @see getLength() 779 * @see remove(XMLTriple triple) 780 * @see remove(string name, string uri) 781 */ public remove(int n)782 int remove(int n) { 783 int ret = libsbmlPINVOKE.XMLAttributes_remove__SWIG_0(swigCPtr, n); 784 return ret; 785 } 786 787 788 /** 789 * Removes a named attribute from this list of attributes. 790 * 791 * @param name a string, the unprefixed name of the attribute to be 792 * removed. 793 * 794 * @param uri a string, the namespace URI of the attribute to be removed. 795 * 796 * 797 * @return integer value indicating success/failure of the 798 * function. @if clike The value is drawn from the 799 * enumeration #OperationReturnValues_t. @endif The possible values 800 * returned by this function are: 801 * @li @link libsbml#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink 802 * @li @link libsbml#LIBSBML_INDEX_EXCEEDS_SIZE LIBSBML_INDEX_EXCEEDS_SIZE@endlink 803 * 804 * The value @link libsbml#LIBSBML_INDEX_EXCEEDS_SIZE LIBSBML_INDEX_EXCEEDS_SIZE@endlink is returned if there is no attribute with the 805 * given @p name (and @p uri if specified). 806 * 807 * @see remove(int n) 808 * @see remove(XMLTriple triple) 809 */ public remove(string name, string uri)810 int remove(string name, string uri) { 811 int ret = libsbmlPINVOKE.XMLAttributes_remove__SWIG_1(swigCPtr, name, uri); 812 return ret; 813 } 814 815 816 /** 817 * Removes a named attribute from this list of attributes. 818 * 819 * @param name a string, the unprefixed name of the attribute to be 820 * removed. 821 * 822 * @param uri a string, the namespace URI of the attribute to be removed. 823 * 824 * 825 * @return integer value indicating success/failure of the 826 * function. @if clike The value is drawn from the 827 * enumeration #OperationReturnValues_t. @endif The possible values 828 * returned by this function are: 829 * @li @link libsbml#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink 830 * @li @link libsbml#LIBSBML_INDEX_EXCEEDS_SIZE LIBSBML_INDEX_EXCEEDS_SIZE@endlink 831 * 832 * The value @link libsbml#LIBSBML_INDEX_EXCEEDS_SIZE LIBSBML_INDEX_EXCEEDS_SIZE@endlink is returned if there is no attribute with the 833 * given @p name (and @p uri if specified). 834 * 835 * @see remove(int n) 836 * @see remove(XMLTriple triple) 837 */ public remove(string name)838 int remove(string name) { 839 int ret = libsbmlPINVOKE.XMLAttributes_remove__SWIG_2(swigCPtr, name); 840 return ret; 841 } 842 843 844 /** 845 * Removes a specific attribute from this list of attributes. 846 * 847 * @param triple an XMLTriple describing the attribute to be removed. 848 * 849 * 850 * @return integer value indicating success/failure of the 851 * function. @if clike The value is drawn from the 852 * enumeration #OperationReturnValues_t. @endif The possible values 853 * returned by this function are: 854 * @li @link libsbml#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink 855 * @li @link libsbml#LIBSBML_INDEX_EXCEEDS_SIZE LIBSBML_INDEX_EXCEEDS_SIZE@endlink 856 * 857 * The value @link libsbml#LIBSBML_INDEX_EXCEEDS_SIZE LIBSBML_INDEX_EXCEEDS_SIZE@endlink is returned if there is no attribute matching 858 * the properties of the given @p triple. 859 * 860 * @see remove(int n) 861 * @see remove(string name, string uri) 862 */ public remove(XMLTriple triple)863 int remove(XMLTriple triple) { 864 int ret = libsbmlPINVOKE.XMLAttributes_remove__SWIG_3(swigCPtr, XMLTriple.getCPtr(triple)); 865 if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); 866 return ret; 867 } 868 869 870 /** 871 * Removes all attributes in this XMLAttributes object. 872 * 873 * 874 * @return integer value indicating success/failure of the 875 * function. @if clike The value is drawn from the 876 * enumeration #OperationReturnValues_t. @endif This particular 877 * function only does one thing irrespective of user input or 878 * object state, and thus will only return a single value: 879 * @li @link libsbml#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink 880 * 881 * @see remove(int n) 882 * @see remove(XMLTriple triple) 883 * @see remove(string name, string uri) 884 */ public clear()885 int clear() { 886 int ret = libsbmlPINVOKE.XMLAttributes_clear(swigCPtr); 887 return ret; 888 } 889 890 891 /** 892 * Returns the index of an attribute having a given name. 893 * 894 * @note This method does not check XML namespaces. Thus, if there are 895 * multiple attributes with the same local @p name but different 896 * namespaces, this method will return the first one found. Callers should 897 * use the more specific methods 898 * XMLAttributes::getIndex(string name, string uri) 899 * or XMLAttributes::getIndex(XMLTriple triple) 900 * to find attributes in particular namespaces. 901 * 902 * @param name a string, the name of the attribute whose index is begin 903 * sought. 904 * 905 * @return the index of an attribute with the given local name, or 906 * <code>-1</code> if no such attribute is present. 907 * 908 * @see hasAttribute(string name, string uri) 909 * @see hasAttribute(XMLTriple triple) 910 */ public getIndex(string name)911 int getIndex(string name) { 912 int ret = libsbmlPINVOKE.XMLAttributes_getIndex__SWIG_0(swigCPtr, name); 913 return ret; 914 } 915 916 917 /** 918 * Returns the index of the attribute having a given name and XML namespace 919 * URI. 920 * 921 * @param name a string, the name of the attribute being sought. 922 * @param uri a string, the namespace URI of the attribute being sought. 923 * 924 * @return the index of an attribute with the given local name and 925 * namespace URI, or <code>-1</code> if no such attribute is present. 926 * 927 * @see hasAttribute(string name, string uri) 928 * @see hasAttribute(XMLTriple triple) 929 */ public getIndex(string name, string uri)930 int getIndex(string name, string uri) { 931 int ret = libsbmlPINVOKE.XMLAttributes_getIndex__SWIG_1(swigCPtr, name, uri); 932 return ret; 933 } 934 935 936 /** 937 * Returns the index of the attribute defined by the given XMLTriple object. 938 * 939 * @param triple an XMLTriple describing the attribute being sought. 940 * 941 * @return the index of an attribute described by the given XMLTriple 942 * object, or <code>-1</code> if no such attribute is present. 943 * 944 * @see hasAttribute(string name, string uri) 945 * @see hasAttribute(XMLTriple triple) 946 */ public getIndex(XMLTriple triple)947 int getIndex(XMLTriple triple) { 948 int ret = libsbmlPINVOKE.XMLAttributes_getIndex__SWIG_2(swigCPtr, XMLTriple.getCPtr(triple)); 949 if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); 950 return ret; 951 } 952 953 954 /** 955 * Returns the number of attributes in this list of attributes. 956 * 957 * @return the number of attributes contained in this XMLAttributes object. 958 */ public getLength()959 int getLength() { 960 int ret = libsbmlPINVOKE.XMLAttributes_getLength(swigCPtr); 961 return ret; 962 } 963 964 965 /** 966 * Returns the number of attributes in this list of attributes. 967 * 968 * This function is merely an alias of XMLAttributes::getLength() 969 * introduced for consistency with other libXML classes. 970 * 971 * @return the number of attributes contained in this XMLAttributes object. 972 */ public getNumAttributes()973 int getNumAttributes() { 974 int ret = libsbmlPINVOKE.XMLAttributes_getNumAttributes(swigCPtr); 975 return ret; 976 } 977 978 979 /** 980 * Returns the name of the <em>n</em>th attribute in this list of 981 * attributes. 982 * 983 * @param index an integer, the position of the attribute whose name 984 * is being sought. 985 * 986 * @return the local name of the <em>n</em>th attribute. 987 * 988 * 989 * @note If @p index is out of range, this method will return an empty 990 * string. Callers should use XMLAttributes::getLength() to check the number 991 * of attributes contained in this object or XMLAttributes::hasAttribute(int 992 * index) to test for the existence of an attribute at a given 993 * position. 994 * 995 * 996 * 997 * 998 * @note Note that although XMLAttributes provides operations that can 999 * manipulate attributes based on a numerical index, XML attributes are in 1000 * fact unordered when they appear in files and data streams. The 1001 * XMLAttributes class provides some list-like facilities, but it is only for 1002 * the convenience of callers. (For example, it permits callers to loop 1003 * across all attributes more easily.) Users should keep in mind that the 1004 * order in which attributes are stored in XMLAttributes objects has no real 1005 * impact on the order in which the attributes are read or written from an 1006 * XML file or data stream. 1007 * 1008 * 1009 * 1010 * @see getLength() 1011 * @see hasAttribute(int index) 1012 */ public getName(int index)1013 string getName(int index) { 1014 string ret = libsbmlPINVOKE.XMLAttributes_getName(swigCPtr, index); 1015 return ret; 1016 } 1017 1018 1019 /** 1020 * Returns the namespace prefix of the <em>n</em>th attribute in this 1021 * attribute set. 1022 * 1023 * @param index an integer, the position of the attribute whose namespace 1024 * prefix is being sought. 1025 * 1026 * @return the XML namespace prefix of the <em>n</em>th attribute. 1027 * 1028 * 1029 * @note If @p index is out of range, this method will return an empty 1030 * string. Callers should use XMLAttributes::getLength() to check the number 1031 * of attributes contained in this object or XMLAttributes::hasAttribute(int 1032 * index) to test for the existence of an attribute at a given 1033 * position. 1034 * 1035 * 1036 * 1037 * 1038 * @note Note that although XMLAttributes provides operations that can 1039 * manipulate attributes based on a numerical index, XML attributes are in 1040 * fact unordered when they appear in files and data streams. The 1041 * XMLAttributes class provides some list-like facilities, but it is only for 1042 * the convenience of callers. (For example, it permits callers to loop 1043 * across all attributes more easily.) Users should keep in mind that the 1044 * order in which attributes are stored in XMLAttributes objects has no real 1045 * impact on the order in which the attributes are read or written from an 1046 * XML file or data stream. 1047 * 1048 * 1049 * 1050 * @see getLength() 1051 * @see hasAttribute(int index) 1052 */ public getPrefix(int index)1053 string getPrefix(int index) { 1054 string ret = libsbmlPINVOKE.XMLAttributes_getPrefix(swigCPtr, index); 1055 return ret; 1056 } 1057 1058 1059 /** 1060 * Returns the prefix name of the <em>n</em>th attribute in this attribute 1061 * set. 1062 * 1063 * @param index an integer, the position of the attribute whose prefixed 1064 * name is being sought. 1065 * 1066 * @return the prefixed name of the <em>n</em>th attribute. 1067 * 1068 * 1069 * @note If @p index is out of range, this method will return an empty 1070 * string. Callers should use XMLAttributes::getLength() to check the number 1071 * of attributes contained in this object or XMLAttributes::hasAttribute(int 1072 * index) to test for the existence of an attribute at a given 1073 * position. 1074 * 1075 * 1076 * 1077 * 1078 * @note Note that although XMLAttributes provides operations that can 1079 * manipulate attributes based on a numerical index, XML attributes are in 1080 * fact unordered when they appear in files and data streams. The 1081 * XMLAttributes class provides some list-like facilities, but it is only for 1082 * the convenience of callers. (For example, it permits callers to loop 1083 * across all attributes more easily.) Users should keep in mind that the 1084 * order in which attributes are stored in XMLAttributes objects has no real 1085 * impact on the order in which the attributes are read or written from an 1086 * XML file or data stream. 1087 * 1088 * 1089 * 1090 * @see getLength() 1091 * @see hasAttribute(int index) 1092 */ public getPrefixedName(int index)1093 string getPrefixedName(int index) { 1094 string ret = libsbmlPINVOKE.XMLAttributes_getPrefixedName(swigCPtr, index); 1095 return ret; 1096 } 1097 1098 1099 /** 1100 * Returns the XML namespace URI of the <em>n</em>th attribute in this 1101 * attribute set. 1102 * 1103 * @param index an integer, the position of the attribute whose namespace 1104 * URI is being sought. 1105 * 1106 * @return the XML namespace URI of the <em>n</em>th attribute. 1107 * 1108 * 1109 * @note If @p index is out of range, this method will return an empty 1110 * string. Callers should use XMLAttributes::getLength() to check the number 1111 * of attributes contained in this object or XMLAttributes::hasAttribute(int 1112 * index) to test for the existence of an attribute at a given 1113 * position. 1114 * 1115 * 1116 * 1117 * 1118 * @note Note that although XMLAttributes provides operations that can 1119 * manipulate attributes based on a numerical index, XML attributes are in 1120 * fact unordered when they appear in files and data streams. The 1121 * XMLAttributes class provides some list-like facilities, but it is only for 1122 * the convenience of callers. (For example, it permits callers to loop 1123 * across all attributes more easily.) Users should keep in mind that the 1124 * order in which attributes are stored in XMLAttributes objects has no real 1125 * impact on the order in which the attributes are read or written from an 1126 * XML file or data stream. 1127 * 1128 * 1129 * 1130 * @see getLength() 1131 * @see hasAttribute(int index) 1132 */ public getURI(int index)1133 string getURI(int index) { 1134 string ret = libsbmlPINVOKE.XMLAttributes_getURI(swigCPtr, index); 1135 return ret; 1136 } 1137 1138 1139 /** 1140 * Returns the value of the <em>n</em>th attribute in this list of attributes. 1141 * 1142 * @param index an integer, the position of the attribute whose value is 1143 * being sought. 1144 * 1145 * @return the XML value of the <em>n</em>th attribute. 1146 * 1147 * 1148 * @note If @p index is out of range, this method will return an empty 1149 * string. Callers should use XMLAttributes::getLength() to check the number 1150 * of attributes contained in this object or XMLAttributes::hasAttribute(int 1151 * index) to test for the existence of an attribute at a given 1152 * position. 1153 * 1154 * 1155 * 1156 * 1157 * @note Note that although XMLAttributes provides operations that can 1158 * manipulate attributes based on a numerical index, XML attributes are in 1159 * fact unordered when they appear in files and data streams. The 1160 * XMLAttributes class provides some list-like facilities, but it is only for 1161 * the convenience of callers. (For example, it permits callers to loop 1162 * across all attributes more easily.) Users should keep in mind that the 1163 * order in which attributes are stored in XMLAttributes objects has no real 1164 * impact on the order in which the attributes are read or written from an 1165 * XML file or data stream. 1166 * 1167 * 1168 * 1169 * @see getLength() 1170 * @see hasAttribute(int index) 1171 */ public getValue(int index)1172 string getValue(int index) { 1173 string ret = libsbmlPINVOKE.XMLAttributes_getValue__SWIG_0(swigCPtr, index); 1174 return ret; 1175 } 1176 1177 1178 /** 1179 * Returns a named attribute's value. 1180 * 1181 * @param name a string, the unprefixed name of the attribute whose value 1182 * is being sought. 1183 * 1184 * @return The attribute value as a string. 1185 * 1186 * @note If an attribute with the given local @p name does not exist in 1187 * this XMLAttributes object, this method will return an empty string. 1188 * Callers can use 1189 * XMLAttributes::hasAttribute(string name, string uri) 1190 * to test for an attribute's existence. This method also does not check 1191 * the XML namespace of the named attribute. Thus, if there are multiple 1192 * attributes with the same local @p name but different namespaces, this 1193 * method will return the value of the first such attribute found. Callers 1194 * should use the more specific methods 1195 * XMLAttributes::getIndex(string name, string uri) 1196 * or XMLAttributes::getIndex(XMLTriple triple) to find 1197 * attributes in particular namespaces. 1198 * 1199 * @see hasAttribute(string name, string uri) 1200 * @see hasAttribute(XMLTriple triple) 1201 */ public getValue(string name)1202 string getValue(string name) { 1203 string ret = libsbmlPINVOKE.XMLAttributes_getValue__SWIG_1(swigCPtr, name); 1204 return ret; 1205 } 1206 1207 1208 /** 1209 * Returns a named attribute's value. 1210 * 1211 * @param name a string, the name of the attribute whose value is being sought. 1212 * @param uri a string, the XML namespace URI of the attribute. 1213 * 1214 * @return The attribute value as a string. 1215 * 1216 * @note If an attribute with the given @p name and namespace @p uri does 1217 * not exist in this XMLAttributes object, this method will return an empty 1218 * string. Callers can use 1219 * XMLAttributes::hasAttribute(string name, string uri) 1220 * to test for an attribute's existence. 1221 * 1222 * @see hasAttribute(string name, string uri) 1223 * @see hasAttribute(XMLTriple triple) 1224 */ public getValue(string name, string uri)1225 string getValue(string name, string uri) { 1226 string ret = libsbmlPINVOKE.XMLAttributes_getValue__SWIG_2(swigCPtr, name, uri); 1227 return ret; 1228 } 1229 1230 1231 /** 1232 * Return the value of an attribute described by a given XMLTriple object. 1233 * 1234 * @param triple an XMLTriple describing the attribute whose value is being 1235 * sought. 1236 * 1237 * @return The attribute value as a string. 1238 * 1239 * @note If an attribute with the properties given by @p triple does not 1240 * exist in this XMLAttributes object, this method will return an empty 1241 * string. Callers can use 1242 * XMLAttributes::hasAttribute(string name, string uri) 1243 * to test for an attribute's existence. 1244 * 1245 * @see hasAttribute(string name, string uri) 1246 * @see hasAttribute(XMLTriple triple) 1247 */ public getValue(XMLTriple triple)1248 string getValue(XMLTriple triple) { 1249 string ret = libsbmlPINVOKE.XMLAttributes_getValue__SWIG_3(swigCPtr, XMLTriple.getCPtr(triple)); 1250 if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); 1251 return ret; 1252 } 1253 1254 1255 /** 1256 * Returns @c true if an attribute exists at a given index. 1257 * 1258 * @param index an integer, the position of the attribute to be tested. 1259 * 1260 * @return @c true if an attribute with the given index exists in this 1261 * XMLAttributes object, @c false otherwise. 1262 * 1263 * 1264 * @note Note that although XMLAttributes provides operations that can 1265 * manipulate attributes based on a numerical index, XML attributes are in 1266 * fact unordered when they appear in files and data streams. The 1267 * XMLAttributes class provides some list-like facilities, but it is only for 1268 * the convenience of callers. (For example, it permits callers to loop 1269 * across all attributes more easily.) Users should keep in mind that the 1270 * order in which attributes are stored in XMLAttributes objects has no real 1271 * impact on the order in which the attributes are read or written from an 1272 * XML file or data stream. 1273 * 1274 * 1275 */ public hasAttribute(int index)1276 bool hasAttribute(int index) { 1277 bool ret = libsbmlPINVOKE.XMLAttributes_hasAttribute__SWIG_0(swigCPtr, index); 1278 return ret; 1279 } 1280 1281 1282 /** 1283 * Returns @c true if an attribute with a given name and namespace URI 1284 * exists. 1285 * 1286 * @param name a string, the unprefixed name of the attribute. 1287 * @param uri a string, the XML namespace URI of the attribute. 1288 * 1289 * @return @c true if an attribute with the given local name and XML 1290 * namespace URI exists in this XMLAttributes object, @c false otherwise. 1291 * 1292 * @see add(string name, string value, string namespaceURI, string prefix) 1293 * @see add(XMLTriple triple, string value) 1294 */ public hasAttribute(string name, string uri)1295 bool hasAttribute(string name, string uri) { 1296 bool ret = libsbmlPINVOKE.XMLAttributes_hasAttribute__SWIG_1(swigCPtr, name, uri); 1297 return ret; 1298 } 1299 1300 1301 /** 1302 * Returns @c true if an attribute with a given name and namespace URI 1303 * exists. 1304 * 1305 * @param name a string, the unprefixed name of the attribute. 1306 * @param uri a string, the XML namespace URI of the attribute. 1307 * 1308 * @return @c true if an attribute with the given local name and XML 1309 * namespace URI exists in this XMLAttributes object, @c false otherwise. 1310 * 1311 * @see add(string name, string value, string namespaceURI, string prefix) 1312 * @see add(XMLTriple triple, string value) 1313 */ public hasAttribute(string name)1314 bool hasAttribute(string name) { 1315 bool ret = libsbmlPINVOKE.XMLAttributes_hasAttribute__SWIG_2(swigCPtr, name); 1316 return ret; 1317 } 1318 1319 1320 /** 1321 * Returns @c true if an attribute with the given properties exists. 1322 * 1323 * @param triple an XMLTriple describing the attribute to be tested. 1324 * 1325 * @return @c true if an attribute with the given XML triple exists in this 1326 * XMLAttributes object, @c false otherwise. 1327 * 1328 * @see add(string name, string value, string namespaceURI, string prefix) 1329 * @see add(XMLTriple triple, string value) 1330 */ public hasAttribute(XMLTriple triple)1331 bool hasAttribute(XMLTriple triple) { 1332 bool ret = libsbmlPINVOKE.XMLAttributes_hasAttribute__SWIG_3(swigCPtr, XMLTriple.getCPtr(triple)); 1333 if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); 1334 return ret; 1335 } 1336 1337 1338 /** 1339 * Returns @c true if this list of attributes is empty. 1340 * 1341 * @return @c true if this XMLAttributes object is empty, @c false 1342 * otherwise. 1343 */ public isEmpty()1344 bool isEmpty() { 1345 bool ret = libsbmlPINVOKE.XMLAttributes_isEmpty(swigCPtr); 1346 return ret; 1347 } 1348 1349 } 1350 1351 } 1352