libNuML 1.1.1
Library for reading / writing NuML documents
NUMLDocument.cpp File Reference
#include <iostream>
#include <string.h>
#include <sbml/xml/XMLAttributes.h>
#include <sbml/xml/XMLNamespaces.h>
#include <sbml/xml/XMLInputStream.h>
#include <sbml/xml/XMLOutputStream.h>
#include <sbml/xml/XMLError.h>
#include <numl/NUMLErrorLog.h>
#include <numl/NUMLVisitor.h>
#include <numl/NUMLError.h>
#include <numl/NUMLDocument.h>
#include <numl/NUMLReader.h>
#include <numl/NUMLWriter.h>

Functions

LIBNUML_EXTERN NUMLDocument_tNUMLDocument_create ()
 Creates a new, empty NUMLDocument_t structure. More...
 
LIBNUML_EXTERN NUMLDocument_tNUMLDocument_createWithLevelAndVersion (unsigned int level, unsigned int version)
 Creates a new, empty NUMLDocument_t structure with given values for the NUML Level and Version. More...
 
LIBNUML_EXTERN void NUMLDocument_free (NUMLDocument_t *d)
 Frees the given NUMLDocument_t structure. More...
 
LIBNUML_EXTERN NUMLDocument_tNUMLDocument_clone (const NUMLDocument_t *d)
 Creates and returns a deep copy of the given NUMLDocument_t structure. More...
 
LIBNUML_EXTERN unsigned int NUMLDocument_getLevel (const NUMLDocument_t *d)
 Returns the NUML Level of the given NUMLDocument_t structure. More...
 
LIBNUML_EXTERN unsigned int NUMLDocument_getVersion (const NUMLDocument_t *d)
 Returns the Version within the NUML Level of the given NUMLDocument_t structure. More...
 
LIBNUML_EXTERN int NUMLDocument_setLevelAndVersion (NUMLDocument_t *d, unsigned int level, unsigned int version)
 Sets the NUML Level and Version of this NUMLDocument, attempting to convert the ResultComponent as needed. More...
 
LIBNUML_EXTERN int NUMLDocument_setLevelAndVersionStrict (NUMLDocument_t *d, unsigned int level, unsigned int version)
 Sets the NUML Level and Version of this NUMLDocument, attempting to convert the model as needed. More...
 
LIBNUML_EXTERN const NUMLError_tNUMLDocument_getError (NUMLDocument_t *d, unsigned int n)
 Returns the nth error or warning encountered during parsing, consistency checking, or attempted translation of this model. More...
 
LIBNUML_EXTERN unsigned int NUMLDocument_getNumErrors (const NUMLDocument_t *d)
 Returns the number of errors or warnings encountered during parsing, consistency checking, or attempted translation of this model. More...
 
LIBNUML_EXTERN void NUMLDocument_printErrors (NUMLDocument_t *d, FILE *stream)
 Prints to the given output stream all the errors or warnings encountered during parsing, consistency checking, or attempted translation of this model. More...
 
unsigned int NUMLDocument_getDefaultLevel ()
 
unsigned int NUMLDocument_getDefaultVersion ()
 
LIBNUML_EXTERN const LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNamespaces_tNUMLDocument_getNamespaces (NUMLDocument_t *d)
 Returns a list of XMLNamespaces_t associated with the XML content of this NUML document. More...
 

Function Documentation

◆ NUMLDocument_clone()

LIBNUML_EXTERN NUMLDocument_t * NUMLDocument_clone ( const NUMLDocument_t d)

Creates and returns a deep copy of the given NUMLDocument_t structure.

Parameters
dthe NUMLDocument_t structure
Returns
a (deep) copy of the NUMLDocument_t structure

◆ NUMLDocument_create()

LIBNUML_EXTERN NUMLDocument_t * NUMLDocument_create ( )

Creates a new, empty NUMLDocument_t structure.

The NUML Level and Version attributes default to the most recent NUML specification (at the time this libNUML was released).

Returns
the NUMLDocument_t structure created

◆ NUMLDocument_createWithLevelAndVersion()

LIBNUML_EXTERN NUMLDocument_t * NUMLDocument_createWithLevelAndVersion ( unsigned int  level,
unsigned int  version 
)

Creates a new, empty NUMLDocument_t structure with given values for the NUML Level and Version.

If not specified, the NUML Level and Version attributes default to the most recent NUML specification (at the time this libNUML was released).

Parameters
levelan integer for the NUML Level
versionan integer for the Version within the NUML Level
Returns
the NUMLDocument_t structure created

◆ NUMLDocument_free()

LIBNUML_EXTERN void NUMLDocument_free ( NUMLDocument_t d)

Frees the given NUMLDocument_t structure.

Parameters
dthe NUMLDocument_t structure

◆ NUMLDocument_getDefaultLevel()

unsigned int NUMLDocument_getDefaultLevel ( )
Returns
the most recent NUML specification level (at the time this libNUML was released).

◆ NUMLDocument_getDefaultVersion()

unsigned int NUMLDocument_getDefaultVersion ( )
Returns
the most recent NUML specification version (at the time this libNUML was released).

◆ NUMLDocument_getError()

LIBNUML_EXTERN const NUMLError_t * NUMLDocument_getError ( NUMLDocument_t d,
unsigned int  n 
)

Returns the nth error or warning encountered during parsing, consistency checking, or attempted translation of this model.

Callers can use method XMLError_getSeverity() on the result to assess the severity of the problem. The severity levels range from informationl messages to fatal errors.

Returns
the error or warning indexed by integer n, or return NULL if n > (NUMLDocument_getNumErrors() - 1).
Parameters
dthe NUMLDocument_t structure
nthe index of the error sought.
See also
NUMLDocument_getNumErrors(), NUMLDocument_setLevelAndVersion(), NUMLDocument_checkConsistency(), NUMLDocument_checkL1Compatibility(), NUMLReader_readNUMLFromString().

◆ NUMLDocument_getLevel()

LIBNUML_EXTERN unsigned int NUMLDocument_getLevel ( const NUMLDocument_t d)

Returns the NUML Level of the given NUMLDocument_t structure.

Parameters
dthe NUMLDocument_t structure
Returns
the NUML Level number

◆ NUMLDocument_getNamespaces()

LIBNUML_EXTERN const LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNamespaces_t * NUMLDocument_getNamespaces ( NUMLDocument_t d)

Returns a list of XMLNamespaces_t associated with the XML content of this NUML document.

Parameters
dthe NUMLDocument_t structure
Returns
pointer to the XMLNamespaces_t structure associated with this NUML object

◆ NUMLDocument_getNumErrors()

LIBNUML_EXTERN unsigned int NUMLDocument_getNumErrors ( const NUMLDocument_t d)

Returns the number of errors or warnings encountered during parsing, consistency checking, or attempted translation of this model.

Parameters
dthe NUMLDocument_t structure
Returns
the number of errors or warnings encountered
See also
NUMLDocument_setLevelAndVersion(), NUMLDocument_checkConsistency(), NUMLDocument_checkL1Compatibility(), NUMLReader_readNUMLFromString().

◆ NUMLDocument_getVersion()

LIBNUML_EXTERN unsigned int NUMLDocument_getVersion ( const NUMLDocument_t d)

Returns the Version within the NUML Level of the given NUMLDocument_t structure.

Parameters
dthe NUMLDocument_t structure
Returns
the version number

◆ NUMLDocument_printErrors()

LIBNUML_EXTERN void NUMLDocument_printErrors ( NUMLDocument_t d,
FILE *  stream 
)

Prints to the given output stream all the errors or warnings encountered during parsing, consistency checking, or attempted translation of this model.

If no errors have occurred, i.e., NUMLDocument_getNumErrors() == 0, no output will be sent to the stream.

The format of the output is:

N error(s): line NNN: (id) message

Parameters
dthe NUMLDocument_t structure
streamthe output stream where the messages should be printed

◆ NUMLDocument_setLevelAndVersion()

LIBNUML_EXTERN int NUMLDocument_setLevelAndVersion ( NUMLDocument_t d,
unsigned int  level,
unsigned int  version 
)

Sets the NUML Level and Version of this NUMLDocument, attempting to convert the ResultComponent as needed.

This method is used to convert numl between Levels and Versions of NUML.

Callers can also check compatibility directly using the methods

The valid combinations as of this release of libNUML are the following:

  • Level 1 Version 1
Parameters
dthe NUMLDocument_t structure
levelthe desired NUML Level
versionthe desired Version within the NUML Level
Note
Calling this method will not necessarily lead to successful conversion. If the conversion fails, it will be logged in the error list associated with this NUMLDocument_t structure. Callers should consult getNumErrors() to find out if the conversion succeeded without problems. (If the conversion to Level 1 failed, the Level of this ResultComponent will be left unchanged.)

◆ NUMLDocument_setLevelAndVersionStrict()

LIBNUML_EXTERN int NUMLDocument_setLevelAndVersionStrict ( NUMLDocument_t d,
unsigned int  level,
unsigned int  version 
)

Sets the NUML Level and Version of this NUMLDocument, attempting to convert the model as needed.

This method is used to convert models between Levels and Versions of NUML.

Callers can also check compatibility directly using the methods

The valid combinations as of this release of libNUML are the following:

  • Level 1 Version 1
Parameters
dthe NUMLDocument_t structure
levelthe desired NUML Level
versionthe desired Version within the NUML Level
Note
Calling this method will not necessarily lead to successful conversion. If the conversion fails, it will be logged in the error list associated with this NUMLDocument_t structure. Callers should consult getNumErrors() to find out if the conversion succeeded without problems.

Strict conversion applies the additional criteria that both the source and the target model must be consistent NUML. Users can control the consistency checks that are applied using the NUMLDocument::setConsistencyChecks function. If either the source or the potential target model have validation errors, the conversion is not performed. When a strict conversion is successful, the underlying NUML object model is altered to reflect the new level and version. Thus information that cannot be converted (e.g. sboTerms) will be lost.