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 An interface to an XML input stream. 20 * 21 * @htmlinclude not-sbml-warning.html 22 * 23 * SBML content is serialized using XML; the resulting data can be stored and 24 * read to/from a file or data stream. Low-level XML parsers such as Xerces 25 * provide facilities to read XML data. To permit the use of different XML 26 * parsers (Xerces, Expat or libxml2), libSBML implements an abstraction 27 * layer. XMLInputStream and XMLOutputStream are two parts of that 28 * abstraction layer. 29 * 30 * XMLInputStream is an interface to a file or text string containing XML. 31 * It wraps the content to be read, as well as the low-level XML parser to be 32 * used and an XMLErrorLog to record errors and other issues (if any arise). 33 * Internally, the content will be in the form of either a pointer to a file 34 * name or a character string; XMLInputStream knows the form of the content 35 * and acts appropriately. Other libSBML object classes use XMLInputStream 36 * as their interface for all read operations on the XML data. 37 * XMLInputStream provides the functionality to extract data in the form of 38 * XMLToken objects. It logs any errors encountered while reading. It also 39 * keeps track of whether a read operation has failed irrecoverably or 40 * determines whether it is safe to continue reading. 41 * 42 * SBMLNamespaces objects can be associated with an XMLInputStream; this 43 * facilitates logging errors related to reading XML attributes and elements 44 * that may only be relevant to particular Level and Version combinations of 45 * SBML. 46 * 47 * @note The convenience of the XMLInputStream and XMLOutputStream 48 * abstraction may be useful for developers interested in creating parsers 49 * for other XML formats besides SBML. It can provide developers with a 50 * layer above more basic XML parsers, as well as some useful programmatic 51 * elements such as XMLToken, XMLError, etc. 52 * 53 * @see XMLOutputStream 54 */ 55 56 public class XMLInputStream : global::System.IDisposable { 57 private HandleRef swigCPtr; 58 protected bool swigCMemOwn; 59 XMLInputStream(IntPtr cPtr, bool cMemoryOwn)60 internal XMLInputStream(IntPtr cPtr, bool cMemoryOwn) 61 { 62 swigCMemOwn = cMemoryOwn; 63 swigCPtr = new HandleRef(this, cPtr); 64 } 65 getCPtr(XMLInputStream obj)66 internal static HandleRef getCPtr(XMLInputStream obj) 67 { 68 return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; 69 } 70 getCPtrAndDisown(XMLInputStream obj)71 internal static HandleRef getCPtrAndDisown (XMLInputStream obj) 72 { 73 HandleRef ptr = new HandleRef(null, IntPtr.Zero); 74 75 if (obj != null) 76 { 77 ptr = obj.swigCPtr; 78 obj.swigCMemOwn = false; 79 } 80 81 return ptr; 82 } 83 ~XMLInputStream()84 ~XMLInputStream() { 85 Dispose(false); 86 } 87 Dispose()88 public void Dispose() { 89 Dispose(true); 90 global::System.GC.SuppressFinalize(this); 91 } 92 Dispose(bool disposing)93 protected virtual void Dispose(bool disposing) { 94 lock(this) { 95 if (swigCPtr.Handle != global::System.IntPtr.Zero) { 96 if (swigCMemOwn) { 97 swigCMemOwn = false; 98 libsbmlPINVOKE.delete_XMLInputStream(swigCPtr); 99 } 100 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); 101 } 102 } 103 } 104 105 106 /** 107 * Creates a new XMLInputStream. 108 * 109 * @param content the source of the stream. 110 * 111 * @param isFile a boolean flag to indicate whether @p content is a file 112 * name. If @c true, @p content is assumed to be the file from which the 113 * XML content is to be read. If @c false, @p content is taken to be a 114 * string that @em is the content to be read. 115 * 116 * @param library the name of the parser library to use. 117 * 118 * @param errorLog the XMLErrorLog object to use. 119 * 120 * @ifnot hasDefaultArgs @htmlinclude warn-default-args-in-docs.html @endif 121 */ public XMLInputStream(string content, bool isFile, string library, XMLErrorLog errorLog)122 XMLInputStream(string content, bool isFile, string library, XMLErrorLog errorLog) : this(libsbmlPINVOKE.new_XMLInputStream__SWIG_0(content, isFile, library, XMLErrorLog.getCPtr(errorLog)), true) { 123 } 124 125 126 /** 127 * Creates a new XMLInputStream. 128 * 129 * @param content the source of the stream. 130 * 131 * @param isFile a boolean flag to indicate whether @p content is a file 132 * name. If @c true, @p content is assumed to be the file from which the 133 * XML content is to be read. If @c false, @p content is taken to be a 134 * string that @em is the content to be read. 135 * 136 * @param library the name of the parser library to use. 137 * 138 * @param errorLog the XMLErrorLog object to use. 139 * 140 * @ifnot hasDefaultArgs @htmlinclude warn-default-args-in-docs.html @endif 141 */ public XMLInputStream(string content, bool isFile, string library)142 XMLInputStream(string content, bool isFile, string library) : this(libsbmlPINVOKE.new_XMLInputStream__SWIG_1(content, isFile, library), true) { 143 } 144 145 146 /** 147 * Creates a new XMLInputStream. 148 * 149 * @param content the source of the stream. 150 * 151 * @param isFile a boolean flag to indicate whether @p content is a file 152 * name. If @c true, @p content is assumed to be the file from which the 153 * XML content is to be read. If @c false, @p content is taken to be a 154 * string that @em is the content to be read. 155 * 156 * @param library the name of the parser library to use. 157 * 158 * @param errorLog the XMLErrorLog object to use. 159 * 160 * @ifnot hasDefaultArgs @htmlinclude warn-default-args-in-docs.html @endif 161 */ public XMLInputStream(string content, bool isFile)162 XMLInputStream(string content, bool isFile) : this(libsbmlPINVOKE.new_XMLInputStream__SWIG_2(content, isFile), true) { 163 } 164 165 166 /** 167 * Creates a new XMLInputStream. 168 * 169 * @param content the source of the stream. 170 * 171 * @param isFile a boolean flag to indicate whether @p content is a file 172 * name. If @c true, @p content is assumed to be the file from which the 173 * XML content is to be read. If @c false, @p content is taken to be a 174 * string that @em is the content to be read. 175 * 176 * @param library the name of the parser library to use. 177 * 178 * @param errorLog the XMLErrorLog object to use. 179 * 180 * @ifnot hasDefaultArgs @htmlinclude warn-default-args-in-docs.html @endif 181 */ public XMLInputStream(string content)182 XMLInputStream(string content) : this(libsbmlPINVOKE.new_XMLInputStream__SWIG_3(content), true) { 183 } 184 185 186 /** 187 * Returns the encoding of the XML stream. 188 * 189 * 190 * The @em encoding is indicated by the <code>xml</code> declaration at the 191 * beginning of an XML document or data stream. The form of this declaration 192 * is 193 * @verbatim 194 <?xml version='1.0' encoding='UTF-8'?> 195 @endverbatim 196 * Note that the SBML specifications require the use of UTF-8 encoding, so 197 * for SBML documents, the value returned by this method will always be 198 * the string <code>'UTF-8'</code>. 199 * 200 * 201 * 202 * @return the encoding of the XML stream. 203 * 204 * @see getVersion() 205 */ public getEncoding()206 string getEncoding() { 207 string ret = libsbmlPINVOKE.XMLInputStream_getEncoding(swigCPtr); 208 return ret; 209 } 210 211 212 /** 213 * Returns the version of the XML stream. 214 * 215 * 216 * The @em version is indicated by the <code>xml</code> declaration at the 217 * beginning of an XML document or data stream. The form of this declaration 218 * is 219 * @verbatim 220 <?xml version='1.0' encoding='UTF-8'?> 221 @endverbatim 222 * Note that the SBML specifications require the use of version 1.0, so 223 * for SBML documents, the value returned by this method will always be 224 * the string <code>'1.0'</code>. 225 * 226 * @return the version of the XML stream. 227 * 228 * @see getEncoding() 229 */ public getVersion()230 string getVersion() { 231 string ret = libsbmlPINVOKE.XMLInputStream_getVersion(swigCPtr); 232 return ret; 233 } 234 235 236 /** 237 * Returns the XMLErrorLog used to log parsing problems. 238 * 239 * @return the XMLErrorLog used to log XML parse errors and other 240 * validation errors (and messages). 241 */ public getErrorLog()242 XMLErrorLog getErrorLog() { 243 global::System.IntPtr cPtr = libsbmlPINVOKE.XMLInputStream_getErrorLog(swigCPtr); 244 XMLErrorLog ret = (cPtr == global::System.IntPtr.Zero) ? null : new XMLErrorLog(cPtr, false); 245 return ret; 246 } 247 248 249 /** 250 * Returns @c true if end of file (stream) has been reached. 251 * 252 * @return @c true if end of file (stream) has been reached, @c false 253 * otherwise. 254 */ public isEOF()255 bool isEOF() { 256 bool ret = libsbmlPINVOKE.XMLInputStream_isEOF(swigCPtr); 257 return ret; 258 } 259 260 261 /** 262 * Returns @c true if a fatal error occurred while reading from this 263 * stream. 264 * 265 * @return @c true if a fatal error occurred while reading from this 266 * stream. 267 */ public isError()268 bool isError() { 269 bool ret = libsbmlPINVOKE.XMLInputStream_isError(swigCPtr); 270 return ret; 271 } 272 273 274 /** 275 * Returns @c true if the stream is in a good state. 276 * 277 * The definition of 'good state' is that isEOF() and isError() both return 278 * @c false. 279 * 280 * @return @c true if the stream is in a good state, @c false otherwise. 281 */ public isGood()282 bool isGood() { 283 bool ret = libsbmlPINVOKE.XMLInputStream_isGood(swigCPtr); 284 return ret; 285 } 286 287 288 /** 289 * Returns the next token on this XML input stream. 290 * 291 * The token is consumed in the process. 292 * 293 * @return the next XMLToken, or an EOF token (i.e., 294 * <code>XMLToken.isEOF() == true</code>). 295 * 296 * @see peek() 297 */ public next()298 XMLToken next() { 299 XMLToken ret = new XMLToken(libsbmlPINVOKE.XMLInputStream_next(swigCPtr), true); 300 return ret; 301 } 302 303 304 /** 305 * Returns the next token @em without consuming it. 306 * 307 * A subsequent call to either peek() or next() will return the same token. 308 * 309 * @return the next XMLToken or EOF (XMLToken.isEOF() == true). 310 * 311 * @see next() 312 */ public peek()313 XMLToken peek() { 314 XMLToken ret = new XMLToken(libsbmlPINVOKE.XMLInputStream_peek(swigCPtr), false); 315 return ret; 316 } 317 318 319 /** 320 * Consume zero or more tokens up to and including the corresponding end 321 * element or EOF. 322 * 323 * @param element the element whose end will be sought in the input stream. 324 */ public skipPastEnd(XMLToken element)325 void skipPastEnd(XMLToken element) { 326 libsbmlPINVOKE.XMLInputStream_skipPastEnd(swigCPtr, XMLToken.getCPtr(element)); 327 if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); 328 } 329 330 331 /** 332 * Consume zero or more tokens up to but not including the next XML element 333 * or EOF. 334 */ public skipText()335 void skipText() { 336 libsbmlPINVOKE.XMLInputStream_skipText(swigCPtr); 337 } 338 339 340 /** 341 * Sets the XMLErrorLog this stream will use to log errors. 342 * 343 * 344 * @return integer value indicating success/failure of the 345 * function. @if clike The value is drawn from the 346 * enumeration #OperationReturnValues_t. @endif The possible values 347 * returned by this function are: 348 * @li @link libsbml#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink 349 * @li @link libsbml#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED@endlink 350 */ public setErrorLog(XMLErrorLog log)351 int setErrorLog(XMLErrorLog log) { 352 int ret = libsbmlPINVOKE.XMLInputStream_setErrorLog(swigCPtr, XMLErrorLog.getCPtr(log)); 353 return ret; 354 } 355 356 357 /** 358 * Prints a string representation of the underlying token stream. 359 * 360 * @return a string representing the underlying XML token stream. 361 * 362 * @note This method is intended for debugging purposes. 363 */ public toString()364 string toString() { 365 string ret = libsbmlPINVOKE.XMLInputStream_toString(swigCPtr); 366 return ret; 367 } 368 369 370 /** 371 * Returns the SBMLNamespaces object attached to this XMLInputStream. 372 * 373 * @return the SBMLNamespaces object or @c null if none has been set. 374 */ public getSBMLNamespaces()375 SBMLNamespaces getSBMLNamespaces() { 376 SBMLNamespaces ret 377 = (SBMLNamespaces) libsbml.DowncastSBMLNamespaces(libsbmlPINVOKE.XMLInputStream_getSBMLNamespaces(swigCPtr), false); 378 return ret; 379 } 380 381 382 /** 383 * Sets the SBML namespaces associated with this XML input stream. 384 * 385 * This allows this stream to reference the available SBML namespaces being 386 * read. 387 * 388 * @param sbmlns the list of namespaces to use. 389 */ public setSBMLNamespaces(SBMLNamespaces sbmlns)390 void setSBMLNamespaces(SBMLNamespaces sbmlns) { 391 libsbmlPINVOKE.XMLInputStream_setSBMLNamespaces(swigCPtr, SBMLNamespaces.getCPtr(sbmlns)); 392 } 393 394 395 /** 396 * Returns the number of child tokens of the given element in this stream. 397 * 398 * This method allows information from the input stream to be determined 399 * without the need to actually read and consume the tokens in the stream. 400 * It returns the number of child elements of the element represented by 401 * the @p elementName, i.e., the number of child elements encountered 402 * before the closing tag for the @p elementName supplied. 403 * 404 * If no @p elementName is supplied or it is an empty string, then as a 405 * special case, this method assumes the element is a MathML 406 * <code>apply</code> element followed by a function name. 407 * 408 * @param elementName a string representing the name of the element for 409 * which the number of children are to be determined. 410 * 411 * @return a long integer giving the number of children of the @p 412 * elementName specified. 413 * 414 * @note This method assumes the stream has been read up to and including 415 * the element @p elementName. 416 * 417 * @ifnot hasDefaultArgs @htmlinclude warn-default-args-in-docs.html @endif 418 */ public determineNumberChildren(string elementName)419 long determineNumberChildren(string elementName) { return (long)libsbmlPINVOKE.XMLInputStream_determineNumberChildren__SWIG_0(swigCPtr, elementName); } 420 421 422 /** 423 * Returns the number of child tokens of the given element in this stream. 424 * 425 * This method allows information from the input stream to be determined 426 * without the need to actually read and consume the tokens in the stream. 427 * It returns the number of child elements of the element represented by 428 * the @p elementName, i.e., the number of child elements encountered 429 * before the closing tag for the @p elementName supplied. 430 * 431 * If no @p elementName is supplied or it is an empty string, then as a 432 * special case, this method assumes the element is a MathML 433 * <code>apply</code> element followed by a function name. 434 * 435 * @param elementName a string representing the name of the element for 436 * which the number of children are to be determined. 437 * 438 * @return a long integer giving the number of children of the @p 439 * elementName specified. 440 * 441 * @note This method assumes the stream has been read up to and including 442 * the element @p elementName. 443 * 444 * @ifnot hasDefaultArgs @htmlinclude warn-default-args-in-docs.html @endif 445 */ public determineNumberChildren()446 long determineNumberChildren() { return (long)libsbmlPINVOKE.XMLInputStream_determineNumberChildren__SWIG_1(swigCPtr); } 447 448 449 /** 450 * Returns the number of child tokens of the specified type within a 451 * given container element. 452 * 453 * This method allows information from the input stream to be determined 454 * without the need to actually read and consume the tokens in the stream. 455 * It returns the number of child elements of the @p childName element 456 * within the element specified by @p container. In other words, it counts 457 * the number of @p childName elements encountered before the closing tag 458 * for the @p container supplied. 459 * 460 * @param childName a string representing the name of the child 461 * element whose number is to be determined. 462 * 463 * @param container a string representing the name of the element 464 * for which the number of children are to be determined. 465 * 466 * @return a long integer giving the number of children of type @p 467 * childName within the @p container element. 468 * 469 * @note This method assumes the stream has been read up to and including 470 * the element @p container. 471 */ public determineNumSpecificChildren(string childName, string container)472 long determineNumSpecificChildren(string childName, string container) { return (long)libsbmlPINVOKE.XMLInputStream_determineNumSpecificChildren(swigCPtr, childName, container); } 473 474 475 /** 476 * Predicate returning @c true if a child token of the specified type occurs 477 * within a given container element. 478 * 479 * This method allows information from the input stream to be determined 480 * without the need to actually read and consume the tokens in the stream. 481 * It returns @c true if the @p childName element occurs at any point 482 * within the element specified by @p container. 483 * 484 * @param childName a string representing the name of the child 485 * element whose presence is to be determined. 486 * 487 * @param container a string representing the name of the element 488 * for which the presence of the child element is to be determined. 489 * 490 * @return boolean @c true if a child of type @p childName occurs within 491 * the @p container element, @c false otherwise. 492 * 493 * @note This method assumes the stream has been read up to and including 494 * the element @p container. 495 */ public containsChild(string childName, string container)496 bool containsChild(string childName, string container) { 497 bool ret = libsbmlPINVOKE.XMLInputStream_containsChild(swigCPtr, childName, container); 498 return ret; 499 } 500 501 } 502 503 } 504