libNuML 1.1.1
Library for reading / writing NuML documents
|
#include <numl/common/extern.h>
#include <numl/common/numlfwd.h>
#include <sbml/util/util.h>
#include <string>
Go to the source code of this file.
Classes | |
class | NUMLReader |
The reader class implementing reading NuML documents from file / string. More... | |
Functions | |
LIBNUML_CPP_NAMESPACE_END LIBNUML_CPP_NAMESPACE_BEGIN BEGIN_C_DECLS LIBNUML_EXTERN NUMLDocument_t * | readNUML (const char *filename) |
Reads an NUML document from the given file filename . More... | |
LIBNUML_EXTERN NUMLDocument_t * | readNUMLFromFile (const char *filename) |
Reads an NUML document from the given file. More... | |
LIBNUML_EXTERN NUMLDocument_t * | readNUMLFromString (const char *xml) |
Reads an NUML document from a string assumed to be in XML format. More... | |
LIBNUML_CPP_NAMESPACE_END LIBNUML_CPP_NAMESPACE_BEGIN BEGIN_C_DECLS LIBNUML_EXTERN NUMLDocument_t * readNUML | ( | const char * | filename | ) |
Reads an NUML document from the given file filename
.
If filename
does not exist, or it is not an NUML file, an error will be logged in the error log of the NUMLDocument object returned by this method. Calling programs can inspect this error log to determine the nature of the problem. Please refer to the definition of NUMLDocument for more information about the error reporting mechanism.
Reads an NUML document from the given file filename
.
If filename does not exist or is not an NUML file, an error will be logged. Errors can be identified by their unique ids, e.g.:
NUMLReader_t *sr;
NUMLDocument_t *d;
sr = NUMLReader_create();
d = NUMLReader_readNUML(reader, filename);
if (NUMLDocument_getNumErrors(d) > 0)
{
if (XMLError_getId(NUMLDocument_getError(d, 0)) == NUML_READ_ERROR_FILE_NOT_FOUND)
if (XMLError_getId(NUMLDocument_getError(d, 0)) == NUML_READ_ERROR_NOT_NUML)
}
If the filename ends with .gz, the file will be read as a gzip file. Similary, if the filename ends with .zip or .bz2, the file will be read as a zip or bzip2 file, respectively. Otherwise, the fill will be read as an uncompressed file. If the filename ends with .zip, only the first file in the archive will be read if the zip archive contains two or more files.
To read a gzip/zip file, underlying libNUML needs to be linked with zlib at compile time. Also, underlying libNUML needs to be linked with bzip2 to read a bzip2 file. File unreadable error will be logged if a compressed file name is given and underlying libNUML is not linked with the corresponding required library. NUMLReader_hasZlib() and NUMLReader_hasBzip2() can be used to check whether libNUML is linked with each library.
LIBNUML_EXTERN NUMLDocument_t * readNUMLFromFile | ( | const char * | filename | ) |
Reads an NUML document from the given file.
If filename does not exist or is not an NUML file, an error will be logged. Errors can be identified by their unique ids, e.g.:
NUMLReader_t *sr;
NUMLDocument_t *d;
sr = NUMLReader_create();
d = NUMLReader_readNUML(reader, filename);
if (NUMLDocument_getNumErrors(d) > 0)
{
if (XMLError_getId(NUMLDocument_getError(d, 0)) == NUML_READ_ERROR_FILE_NOT_FOUND)
if (XMLError_getId(NUMLDocument_getError(d, 0)) == NUML_READ_ERROR_NOT_NUML)
}
If the filename ends with .gz, the file will be read as a gzip file. Similary, if the filename ends with .zip or .bz2, the file will be read as a zip or bzip2 file, respectively. Otherwise, the fill will be read as an uncompressed file. If the filename ends with .zip, only the first file in the archive will be read if the zip archive contains two or more files.
To read a gzip/zip file, underlying libNUML needs to be linked with zlib at compile time. Also, underlying libNUML needs to be linked with bzip2 to read a bzip2 file. File unreadable error will be logged if a compressed file name is given and underlying libNUML is not linked with the corresponding required library. NUMLReader_hasZlib() and NUMLReader_hasBzip2() can be used to check whether libNUML is linked with each library.
LIBNUML_EXTERN NUMLDocument_t * readNUMLFromString | ( | const char * | xml | ) |
Reads an NUML document from a string assumed to be in XML format.
If the string does not begin with XML declaration,
<?xml version='1.0' encoding='UTF-8'?>
an XML declaration string will be prepended.
This method will report an error if the given string xml
is not NUML. The error will be logged in the error log of the NUMLDocument object returned by this method. Calling programs can inspect this error log to determine the nature of the problem. Please refer to the definition of NUMLDocument for more information about the error reporting mechanism.
Reads an NUML document from a string assumed to be in XML format.
If the string does not begin with XML declaration:
<?xml version='1.0' encoding='UTF-8'?>
it will be prepended.
This method will log a fatal error if the XML string is not NUML. See the method documentation for readNUML(filename) for example error checking code.