libSBML C API  libSBML 5.8.0 C API
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
SBMLWriter.h File Reference

Detailed Description

Writes an SBML Document to file or in-memory string.

Author
Ben Bornstein
Include dependency graph for SBMLWriter.h:
This graph shows which files directly or indirectly include this file:

Functions

SBMLWriter_t * SBMLWriter_create (void)
 Creates a new SBMLWriter and returns a pointer to it. More...
 
void SBMLWriter_free (SBMLWriter_t *sw)
 Frees the given SBMLWriter. More...
 
int SBMLWriter_hasBzip2 ()
 Predicate returning non-zero or zero depending on whether libSBML is linked with bzip2 at compile time. More...
 
int SBMLWriter_hasZlib ()
 Predicate returning non-zero or zero depending on whether libSBML is linked with zlib at compile time. More...
 
int SBMLWriter_setProgramName (SBMLWriter_t *sw, const char *name)
 Sets the name of this program. More...
 
int SBMLWriter_setProgramVersion (SBMLWriter_t *sw, const char *version)
 Sets the version of this program. More...
 
int SBMLWriter_writeSBML (SBMLWriter_t *sw, const SBMLDocument_t *d, const char *filename)
 Writes the given SBML document to filename. More...
 
int SBMLWriter_writeSBMLToFile (SBMLWriter_t *sw, const SBMLDocument_t *d, const char *filename)
 Writes the given SBML document to filename. More...
 
char * SBMLWriter_writeSBMLToString (SBMLWriter_t *sw, const SBMLDocument_t *d)
 Writes the given SBML document to an in-memory string and returns a pointer to it. More...
 
int writeSBML (const SBMLDocument_t *d, const char *filename)
 Writes the given SBML document d to the file named by filename. More...
 
int writeSBMLToFile (const SBMLDocument_t *d, const char *filename)
 Writes the given SBML document d to the file filename. More...
 
char * writeSBMLToString (const SBMLDocument_t *d)
 Writes the given SBML document d to an in-memory string and returns the string. More...
 

Function Documentation

SBMLWriter_t* SBMLWriter_create ( void  )

Creates a new SBMLWriter and returns a pointer to it.

void SBMLWriter_free ( SBMLWriter_t *  sw)

Frees the given SBMLWriter.

int SBMLWriter_hasBzip2 ( )

Predicate returning non-zero or zero depending on whether libSBML is linked with bzip2 at compile time.

Returns
non-zero if bzip2 is linked, zero otherwise.
int SBMLWriter_hasZlib ( )

Predicate returning non-zero or zero depending on whether libSBML is linked with zlib at compile time.

Returns
non-zero if zlib is linked, zero otherwise.
int SBMLWriter_setProgramName ( SBMLWriter_t *  sw,
const char *  name 
)

Sets the name of this program.

i. e. the one about to write out the SBMLDocument. If the program name and version are set (setProgramVersion()), the following XML comment, intended for human consumption, will be written at the beginning of the document:

i. e. the one about to write out the SBMLDocument. If the program name and version are set (setProgramVersion()), the following XML comment, intended for human consumption, will be written at the beginning of the document:

Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
int SBMLWriter_setProgramVersion ( SBMLWriter_t *  sw,
const char *  version 
)

Sets the version of this program.

i. e. the one about to write out the SBMLDocument. If the program version and name are set (setProgramName()), the following XML comment, intended for human consumption, will be written at the beginning of the document:

i. e. the one about to write out the SBMLDocument. If the program version and name are set (setProgramName()), the following XML comment, intended for human consumption, will be written at the beginning of the document:

Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
int SBMLWriter_writeSBML ( SBMLWriter_t *  sw,
const SBMLDocument_t *  d,
const char *  filename 
)

Writes the given SBML document to filename.

If the given filename ends with the suffix ".gz" (for example, "myfile.xml.gz"), libSBML assumes the caller wants the file to be written compressed in gzip format. Similarly, if the given filename ends with ".zip" or ".bz2", libSBML assumes the caller wants the file to be compressed in zip or bzip2 format (respectively). Files whose names lack these suffixes will be written uncompressed. Special considerations for the zip format: If the given filename ends with ".zip", the file placed in the zip archive will have the suffix ".xml" or ".sbml". For example, the file in the zip archive will be named "test.xml" if the given filename is "test.xml.zip" or "test.zip". Similarly, the filename in the archive will be "test.sbml" if the given filename is "test.sbml.zip".
Returns
non-zero on success and zero if the filename could not be opened for writing.
Note
To write a gzip/zip file, libSBML needs to be configured and linked with the zlib library at compile time. It also needs to be linked with the bzip2 library to write files in bzip2 format. (Both of these are the default configurations for libSBML.) Errors about unreadable files will be logged and this method will return false if a compressed filename is given and libSBML was not linked with the corresponding required library.
SBMLReader::hasZlib() and SBMLReader::hasBzip2() can be used to check whether libSBML has been linked with each library.

If the filename ends with .gz, the file will be compressed by gzip. Similary, if the filename ends with .zip or .bz2, the file will be compressed by zip or bzip2, respectively. Otherwise, the fill will be uncompressed. If the filename ends with .zip, a filename that will be added to the zip archive file will end with .xml or .sbml. For example, the filename in the zip archive will be test.xml if the given filename is test.xml.zip or test.zip. Also, the filename in the archive will be test.sbml if the given filename is test.sbml.zip.

Note
To create a gzip/zip file, libSBML needs to be linked with zlib at compile time. Also, libSBML needs to be linked with bzip2 to create a bzip2 file. File unwritable error will be logged and zero will be returned if a compressed file name is given and libSBML is not linked with the required library. SBMLWriter_hasZlib() and SBMLWriter_hasBzip2() can be used to check whether libSBML was linked with the library at compile time.
Returns
non-zero on success and zero if the filename could not be opened for writing.
int SBMLWriter_writeSBMLToFile ( SBMLWriter_t *  sw,
const SBMLDocument_t *  d,
const char *  filename 
)

Writes the given SBML document to filename.

If the filename ends with .gz, the file will be compressed by gzip. Similary, if the filename ends with .zip or .bz2, the file will be compressed by zip or bzip2, respectively. Otherwise, the fill will be uncompressed. If the filename ends with .zip, a filename that will be added to the zip archive file will end with .xml or .sbml. For example, the filename in the zip archive will be test.xml if the given filename is test.xml.zip or test.zip. Also, the filename in the archive will be test.sbml if the given filename is test.sbml.zip.

Note
To create a gzip/zip file, libSBML needs to be linked with zlib at compile time. Also, libSBML needs to be linked with bzip2 to create a bzip2 file. File unwritable error will be logged and zero will be returned if a compressed file name is given and libSBML is not linked with the required library. SBMLWriter_hasZlib() and SBMLWriter_hasBzip2() can be used to check whether libSBML was linked with the library at compile time.
Returns
non-zero on success and zero if the filename could not be opened for writing.
char* SBMLWriter_writeSBMLToString ( SBMLWriter_t *  sw,
const SBMLDocument_t *  d 
)

Writes the given SBML document to an in-memory string and returns a pointer to it.

The string is owned by the caller and should be freed (with free()) when no longer needed.

Returns
the string on success and NULL if one of the underlying parser components fail (rare).

The string is owned by the caller and should be freed (with free()) when no longer needed.

Returns
the string on success and NULL if one of the underlying parser components fail (rare).
int writeSBML ( const SBMLDocument_t *  d,
const char *  filename 
)

Writes the given SBML document d to the file named by filename.

This function is identical to.

If the given filename ends with the suffix ".gz" (for example, "myfile.xml.gz"), libSBML assumes the caller wants the file to be written compressed in gzip format. Similarly, if the given filename ends with ".zip" or ".bz2", libSBML assumes the caller wants the file to be compressed in zip or bzip2 format (respectively). Files whose names lack these suffixes will be written uncompressed. Special considerations for the zip format: If the given filename ends with ".zip", the file placed in the zip archive will have the suffix ".xml" or ".sbml". For example, the file in the zip archive will be named "test.xml" if the given filename is "test.xml.zip" or "test.zip". Similarly, the filename in the archive will be "test.sbml" if the given filename is "test.sbml.zip".
Parameters
dthe SBMLDocument object to be written out in XML format
filenamea string giving the path to a file where the XML content is to be written.
Returns
1 on success and 0 (zero) if filename could not be written. Some possible reasons for failure include (a) being unable to open the file, and (b) using a filename that indicates a compressed SBML file (i.e., a filename ending in ".zip" or similar) when the compression functionality has not been enabled in the underlying copy of libSBML.
See Also
SBMLWriter::hasZlib()
SBMLWriter::hasBzip2()

Writes the given SBML document d to the file named by filename.

This convenience function is functionally equivalent to:

SBMLWriter_writeSBML(SBMLWriter_create(), d, filename);

Returns
non-zero on success and zero if the filename could not be opened for writing.
int writeSBMLToFile ( const SBMLDocument_t *  d,
const char *  filename 
)

Writes the given SBML document d to the file filename.

This is a convenience function that uses the SBMLWriter::writeSBMLToFile(const SBMLDocument* d, const std::string& filename) method internally, yet does not require the caller to create an SBMLWriter object first.

If the given filename ends with the suffix ".gz" (for example, "myfile.xml.gz"), libSBML assumes the caller wants the file to be written compressed in gzip format. Similarly, if the given filename ends with ".zip" or ".bz2", libSBML assumes the caller wants the file to be compressed in zip or bzip2 format (respectively). Files whose names lack these suffixes will be written uncompressed. Special considerations for the zip format: If the given filename ends with ".zip", the file placed in the zip archive will have the suffix ".xml" or ".sbml". For example, the file in the zip archive will be named "test.xml" if the given filename is "test.xml.zip" or "test.zip". Similarly, the filename in the archive will be "test.sbml" if the given filename is "test.sbml.zip".
Parameters
dan SBMLDocument object to be written out in XML format
filenamea string giving the path to a file where the XML content is to be written.
Returns
1 on success and 0 (zero) if filename could not be written. Some possible reasons for failure include (a) being unable to open the file, and (b) using a filename that indicates a compressed SBML file (i.e., a filename ending in ".zip" or similar) when the compression functionality has not been enabled in the underlying copy of libSBML.
See Also
SBMLWriter::hasZlib()
SBMLWriter::hasBzip2()

Writes the given SBML document d to the file filename.

This convenience function is functionally equivalent to:

SBMLWriter_writeSBMLToFile(SBMLWriter_create(), d, filename);

Returns
non-zero on success and zero if the filename could not be opened for writing.
char* writeSBMLToString ( const SBMLDocument_t *  d)

Writes the given SBML document d to an in-memory string and returns the string.

This is a convenience function that uses the SBMLWriter::writeSBMLToString(const SBMLDocument* d) method internally, yet does not require the caller to create an SBMLWriter object first.

Parameters
dan SBMLDocument object to be written out in XML format
Returns
the string on success and NULL if one of the underlying parser components fail.

Writes the given SBML document d to an in-memory string and returns the string.

The string is owned by the caller and should be freed (with free()) when no longer needed. This convenience function is functionally equivalent to:

SBMLWriter_writeSBMLToString(SBMLWriter_create(), d);

Returns
the string on success and NULL if one of the underlying parser components fail (rare).