libSBML C# API  libSBML 5.16.0 C# API
libsbmlcs.XMLInputStream Class Reference
Inheritance diagram for libsbmlcs.XMLInputStream:
[legend]

Detailed Description

{core}

An interface to an XML input stream.

This class of objects is defined by libSBML only and has no direct equivalent in terms of SBML components. This class is not prescribed by the SBML specifications, although it is used to implement features defined in SBML.

SBML content is serialized using XML; the resulting data can be stored and read to/from a file or data stream. Low-level XML parsers such as Xerces provide facilities to read XML data. To permit the use of different XML parsers (Xerces, Expat or libxml2), libSBML implements an abstraction layer. XMLInputStream and XMLOutputStream are two parts of that abstraction layer.

XMLInputStream is an interface to a file or text string containing XML. It wraps the content to be read, as well as the low-level XML parser to be used and an XMLErrorLog to record errors and other issues (if any arise). Internally, the content will be in the form of either a pointer to a file name or a character string; XMLInputStream knows the form of the content and acts appropriately. Other libSBML object classes use XMLInputStream as their interface for all read operations on the XML data. XMLInputStream provides the functionality to extract data in the form of XMLToken objects. It logs any errors encountered while reading. It also keeps track of whether a read operation has failed irrecoverably or determines whether it is safe to continue reading.

SBMLNamespaces objects can be associated with an XMLInputStream; this facilitates logging errors related to reading XML attributes and elements that may only be relevant to particular Level and Version combinations of SBML.

Note
The convenience of the XMLInputStream and XMLOutputStream abstraction may be useful for developers interested in creating parsers for other XML formats besides SBML. It can provide developers with a layer above more basic XML parsers, as well as some useful programmatic elements such as XMLToken, XMLError, etc.
See also
XMLOutputStream

Public Member Functions

bool containsChild (string childName, string container)
 Predicate returning true if a child token of the specified type occurs within a given container element. More...
 
long determineNumberChildren (string elementName)
 Returns the number of child tokens of the given element in this stream. More...
 
long determineNumberChildren ()
 Returns the number of child tokens of the given element in this stream. More...
 
long determineNumSpecificChildren (string childName, string container)
 Returns the number of child tokens of the specified type within a given container element. More...
 
virtual void Dispose ()
 
string getEncoding ()
 Returns the encoding of the XML stream. More...
 
XMLErrorLog getErrorLog ()
 Returns the XMLErrorLog used to log parsing problems. More...
 
SBMLNamespaces getSBMLNamespaces ()
 Returns the SBMLNamespaces object attached to this XMLInputStream. More...
 
string getVersion ()
 Returns the version of the XML stream. More...
 
bool isEOF ()
 Returns true if end of file (stream) has been reached. More...
 
bool isError ()
 Returns true if a fatal error occurred while reading from this stream. More...
 
bool isGood ()
 Returns true if the stream is in a good state. More...
 
XMLToken next ()
 Returns the next token on this XML input stream. More...
 
XMLToken peek ()
 Returns the next token without consuming it. More...
 
int setErrorLog (XMLErrorLog log)
 Sets the XMLErrorLog this stream will use to log errors. More...
 
void setSBMLNamespaces (SBMLNamespaces sbmlns)
 Sets the SBML namespaces associated with this XML input stream. More...
 
void skipPastEnd (XMLToken element)
 Consume zero or more tokens up to and including the corresponding end element or EOF. More...
 
void skipText ()
 Consume zero or more tokens up to but not including the next XML element or EOF. More...
 
string toString ()
 Prints a string representation of the underlying token stream. More...
 
 XMLInputStream (string content, bool isFile, string library, XMLErrorLog errorLog)
 Creates a new XMLInputStream. More...
 
 XMLInputStream (string content, bool isFile, string library)
 Creates a new XMLInputStream. More...
 
 XMLInputStream (string content, bool isFile)
 Creates a new XMLInputStream. More...
 
 XMLInputStream (string content)
 Creates a new XMLInputStream. More...
 

Protected Attributes

bool swigCMemOwn
 

Constructor & Destructor Documentation

◆ XMLInputStream() [1/4]

libsbmlcs.XMLInputStream.XMLInputStream ( string  content,
bool  isFile,
string  library,
XMLErrorLog  errorLog 
)

Creates a new XMLInputStream.

Parameters
contentthe source of the stream.
isFilea boolean flag to indicate whether content is a file name. If true, content is assumed to be the file from which the XML content is to be read. If false, content is taken to be a string that is the content to be read.
librarythe name of the parser library to use.
errorLogthe XMLErrorLog object to use.
Documentation note:
The native C++ implementation of this method defines a default argument value. In the documentation generated for different libSBML language bindings, you may or may not see corresponding arguments in the method declarations. For example, in Java and C#, a default argument is handled by declaring two separate methods, with one of them having the argument and the other one lacking the argument. However, the libSBML documentation will be identical for both methods. Consequently, if you are reading this and do not see an argument even though one is described, please look for descriptions of other variants of this method near where this one appears in the documentation.

◆ XMLInputStream() [2/4]

libsbmlcs.XMLInputStream.XMLInputStream ( string  content,
bool  isFile,
string  library 
)

Creates a new XMLInputStream.

Parameters
contentthe source of the stream.
isFilea boolean flag to indicate whether content is a file name. If true, content is assumed to be the file from which the XML content is to be read. If false, content is taken to be a string that is the content to be read.
librarythe name of the parser library to use.
errorLogthe XMLErrorLog object to use.
Documentation note:
The native C++ implementation of this method defines a default argument value. In the documentation generated for different libSBML language bindings, you may or may not see corresponding arguments in the method declarations. For example, in Java and C#, a default argument is handled by declaring two separate methods, with one of them having the argument and the other one lacking the argument. However, the libSBML documentation will be identical for both methods. Consequently, if you are reading this and do not see an argument even though one is described, please look for descriptions of other variants of this method near where this one appears in the documentation.

◆ XMLInputStream() [3/4]

libsbmlcs.XMLInputStream.XMLInputStream ( string  content,
bool  isFile 
)

Creates a new XMLInputStream.

Parameters
contentthe source of the stream.
isFilea boolean flag to indicate whether content is a file name. If true, content is assumed to be the file from which the XML content is to be read. If false, content is taken to be a string that is the content to be read.
librarythe name of the parser library to use.
errorLogthe XMLErrorLog object to use.
Documentation note:
The native C++ implementation of this method defines a default argument value. In the documentation generated for different libSBML language bindings, you may or may not see corresponding arguments in the method declarations. For example, in Java and C#, a default argument is handled by declaring two separate methods, with one of them having the argument and the other one lacking the argument. However, the libSBML documentation will be identical for both methods. Consequently, if you are reading this and do not see an argument even though one is described, please look for descriptions of other variants of this method near where this one appears in the documentation.

◆ XMLInputStream() [4/4]

libsbmlcs.XMLInputStream.XMLInputStream ( string  content)

Creates a new XMLInputStream.

Parameters
contentthe source of the stream.
isFilea boolean flag to indicate whether content is a file name. If true, content is assumed to be the file from which the XML content is to be read. If false, content is taken to be a string that is the content to be read.
librarythe name of the parser library to use.
errorLogthe XMLErrorLog object to use.
Documentation note:
The native C++ implementation of this method defines a default argument value. In the documentation generated for different libSBML language bindings, you may or may not see corresponding arguments in the method declarations. For example, in Java and C#, a default argument is handled by declaring two separate methods, with one of them having the argument and the other one lacking the argument. However, the libSBML documentation will be identical for both methods. Consequently, if you are reading this and do not see an argument even though one is described, please look for descriptions of other variants of this method near where this one appears in the documentation.

Member Function Documentation

◆ containsChild()

bool libsbmlcs.XMLInputStream.containsChild ( string  childName,
string  container 
)

Predicate returning true if a child token of the specified type occurs within a given container element.

This method allows information from the input stream to be determined without the need to actually read and consume the tokens in the stream. It returns true if the childName element occurs at any point within the element specified by container.

Parameters
childNamea string representing the name of the child element whose presence is to be determined.
containera string representing the name of the element for which the presence of the child element is to be determined.
Returns
boolean true if a child of type childName occurs within the container element, false otherwise.
Note
This method assumes the stream has been read up to and including the element container.

◆ determineNumberChildren() [1/2]

long libsbmlcs.XMLInputStream.determineNumberChildren ( string  elementName)

Returns the number of child tokens of the given element in this stream.

This method allows information from the input stream to be determined without the need to actually read and consume the tokens in the stream. It returns the number of child elements of the element represented by the elementName, i.e., the number of child elements encountered before the closing tag for the elementName supplied.

If no elementName is supplied or it is an empty string, then as a special case, this method assumes the element is a MathML apply element followed by a function name.

Parameters
elementNamea string representing the name of the element for which the number of children are to be determined.
Returns
a long integer giving the number of children of the elementName specified.
Note
This method assumes the stream has been read up to and including the element elementName.
Documentation note:
The native C++ implementation of this method defines a default argument value. In the documentation generated for different libSBML language bindings, you may or may not see corresponding arguments in the method declarations. For example, in Java and C#, a default argument is handled by declaring two separate methods, with one of them having the argument and the other one lacking the argument. However, the libSBML documentation will be identical for both methods. Consequently, if you are reading this and do not see an argument even though one is described, please look for descriptions of other variants of this method near where this one appears in the documentation.

◆ determineNumberChildren() [2/2]

long libsbmlcs.XMLInputStream.determineNumberChildren ( )

Returns the number of child tokens of the given element in this stream.

This method allows information from the input stream to be determined without the need to actually read and consume the tokens in the stream. It returns the number of child elements of the element represented by the elementName, i.e., the number of child elements encountered before the closing tag for the elementName supplied.

If no elementName is supplied or it is an empty string, then as a special case, this method assumes the element is a MathML apply element followed by a function name.

Parameters
elementNamea string representing the name of the element for which the number of children are to be determined.
Returns
a long integer giving the number of children of the elementName specified.
Note
This method assumes the stream has been read up to and including the element elementName.
Documentation note:
The native C++ implementation of this method defines a default argument value. In the documentation generated for different libSBML language bindings, you may or may not see corresponding arguments in the method declarations. For example, in Java and C#, a default argument is handled by declaring two separate methods, with one of them having the argument and the other one lacking the argument. However, the libSBML documentation will be identical for both methods. Consequently, if you are reading this and do not see an argument even though one is described, please look for descriptions of other variants of this method near where this one appears in the documentation.

◆ determineNumSpecificChildren()

long libsbmlcs.XMLInputStream.determineNumSpecificChildren ( string  childName,
string  container 
)

Returns the number of child tokens of the specified type within a given container element.

This method allows information from the input stream to be determined without the need to actually read and consume the tokens in the stream. It returns the number of child elements of the childName element within the element specified by container. In other words, it counts the number of childName elements encountered before the closing tag for the container supplied.

Parameters
childNamea string representing the name of the child element whose number is to be determined.
containera string representing the name of the element for which the number of children are to be determined.
Returns
a long integer giving the number of children of type childName within the container element.
Note
This method assumes the stream has been read up to and including the element container.

◆ Dispose()

virtual void libsbmlcs.XMLInputStream.Dispose ( )
virtual

◆ getEncoding()

string libsbmlcs.XMLInputStream.getEncoding ( )

Returns the encoding of the XML stream.

The encoding is indicated by the xml declaration at the beginning of an XML document or data stream. The form of this declaration is

<?xml version='1.0' encoding='UTF-8'?>

Note that the SBML specifications require the use of UTF-8 encoding, so for SBML documents, the value returned by this method will always be the string 'UTF-8'.

Returns
the encoding of the XML stream.
See also
getVersion()

◆ getErrorLog()

XMLErrorLog libsbmlcs.XMLInputStream.getErrorLog ( )

Returns the XMLErrorLog used to log parsing problems.

Returns
the XMLErrorLog used to log XML parse errors and other validation errors (and messages).

◆ getSBMLNamespaces()

SBMLNamespaces libsbmlcs.XMLInputStream.getSBMLNamespaces ( )

Returns the SBMLNamespaces object attached to this XMLInputStream.

Returns
the SBMLNamespaces object or null if none has been set.

◆ getVersion()

string libsbmlcs.XMLInputStream.getVersion ( )

Returns the version of the XML stream.

The version is indicated by the xml declaration at the beginning of an XML document or data stream. The form of this declaration is

 <?xml version='1.0' encoding='UTF-8'?>

Note that the SBML specifications require the use of version 1.0, so for SBML documents, the value returned by this method will always be the string '1.0'.

Returns
the version of the XML stream.
See also
getEncoding()

◆ isEOF()

bool libsbmlcs.XMLInputStream.isEOF ( )

Returns true if end of file (stream) has been reached.

Returns
true if end of file (stream) has been reached, false otherwise.

◆ isError()

bool libsbmlcs.XMLInputStream.isError ( )

Returns true if a fatal error occurred while reading from this stream.

Returns
true if a fatal error occurred while reading from this stream.

◆ isGood()

bool libsbmlcs.XMLInputStream.isGood ( )

Returns true if the stream is in a good state.

The definition of 'good state' is that isEOF() and isError() both return false.

Returns
true if the stream is in a good state, false otherwise.

◆ next()

XMLToken libsbmlcs.XMLInputStream.next ( )

Returns the next token on this XML input stream.

The token is consumed in the process.

Returns
the next XMLToken, or an EOF token (i.e., XMLToken.isEOF() == true).
See also
peek()

◆ peek()

XMLToken libsbmlcs.XMLInputStream.peek ( )

Returns the next token without consuming it.

A subsequent call to either peek() or next() will return the same token.

Returns
the next XMLToken or EOF (XMLToken.isEOF() == true).
See also
next()

◆ setErrorLog()

int libsbmlcs.XMLInputStream.setErrorLog ( XMLErrorLog  log)

Sets the XMLErrorLog this stream will use to log errors.

Returns
integer value indicating success/failure of the function. The possible values returned by this function are:

◆ setSBMLNamespaces()

void libsbmlcs.XMLInputStream.setSBMLNamespaces ( SBMLNamespaces  sbmlns)

Sets the SBML namespaces associated with this XML input stream.

This allows this stream to reference the available SBML namespaces being read.

Parameters
sbmlnsthe list of namespaces to use.

◆ skipPastEnd()

void libsbmlcs.XMLInputStream.skipPastEnd ( XMLToken  element)

Consume zero or more tokens up to and including the corresponding end element or EOF.

Parameters
elementthe element whose end will be sought in the input stream.

◆ skipText()

void libsbmlcs.XMLInputStream.skipText ( )

Consume zero or more tokens up to but not including the next XML element or EOF.

◆ toString()

string libsbmlcs.XMLInputStream.toString ( )

Prints a string representation of the underlying token stream.

Returns
a string representing the underlying XML token stream.
Note
This method is intended for debugging purposes.

Member Data Documentation

◆ swigCMemOwn

bool libsbmlcs.XMLInputStream.swigCMemOwn
protected