libSBML C++ API  5.18.0
SBMLWriter.h File Reference

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

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

Classes

class  SBMLWriter
  File and text-string SBML writer. More...
 

Functions

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 a pointer to it. More...
 

Detailed Description

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

Author
Ben Bornstein

Function Documentation

int writeSBML ( const SBMLDocument_t d,
const char *  filename 
)

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);

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 (true) on success and 0 (false) 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()
Examples:
addCVTerms.cpp, addingEvidenceCodes_1.cpp, addingEvidenceCodes_2.cpp, addLayout.cpp, addModelHistory.cpp, appendAnnotation.cpp, convertCobraToFbc.cpp, convertFbcToCobra.cpp, convertLayout.cpp, convertSBML.cpp, echoSBML.cpp, example1-L3.cpp, example1.cpp, example2-L3.cpp, example2.cpp, example3-L3.cpp, example3.cpp, fbc_example1.cpp, flattenModel.cpp, groups_example1.cpp, groups_example2.cpp, inlineFunctionDefintions.cpp, promoteParameters.cpp, qual_example1.cpp, stripPackage.cpp, unsetAnnotation.cpp, and unsetNotes.cpp.
int writeSBMLToFile ( const SBMLDocument_t d,
const char *  filename 
)

Writes the given SBML document d to the file filename.

This convenience function is functionally equivalent to:

SBMLWriter_writeSBMLToFile(SBMLWriter_create(), d, filename);

but that 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 (true) on success and 0 (false) 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.
Warning
Note that the string is owned by the caller and should be freed (with the normal string free() C++ function) after it is no longer needed.
See also
SBMLWriter::hasZlib()
SBMLWriter::hasBzip2()
Examples:
renameSId.cpp, setIdFromNames.cpp, setNamesFromIds.cpp, spec_example1.cpp, spec_example2.cpp, spec_example3.cpp, and spec_example4.cpp.
char* writeSBMLToString ( const SBMLDocument_t d)

Writes the given SBML document d 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. This convenience function is functionally equivalent to:

SBMLWriter_writeSBMLToString(SBMLWriter_create(), d);

but 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.
Warning
Note that the string is owned by the caller and should be freed after it is no longer needed.
Examples:
rngvalidator.cpp.