libNuML 1.1.1
Library for reading / writing NuML documents
NUMLWriter.cpp File Reference
#include <ios>
#include <iostream>
#include <fstream>
#include <sstream>
#include <numl/common/common.h>
#include <sbml/xml/XMLOutputStream.h>
#include <numl/NUMLError.h>
#include <numl/NUMLDocument.h>
#include <numl/NUMLWriter.h>
#include <numl/common/operationReturnValues.h>
#include <sbml/compress/CompressCommon.h>
#include <sbml/compress/OutputCompressor.h>
#include <sbml/SBMLWriter.h>

Functions

LIBNUML_EXTERN NUMLWriter_tNUMLWriter_create ()
 Creates a new NUMLWriter and returns a pointer to it. More...
 
LIBNUML_EXTERN void NUMLWriter_free (NUMLWriter_t *sw)
 Frees the given NUMLWriter. More...
 
LIBNUML_EXTERN int NUMLWriter_setProgramName (NUMLWriter_t *sw, const char *name)
 Sets the name of this program. More...
 
LIBNUML_EXTERN int NUMLWriter_setProgramVersion (NUMLWriter_t *sw, const char *version)
 Sets the version of this program. More...
 
LIBNUML_EXTERN int NUMLWriter_writeNUML (NUMLWriter_t *sw, const NUMLDocument_t *d, const char *filename)
 Writes the given NUML document to filename. More...
 
LIBNUML_EXTERN char * NUMLWriter_writeNUMLToString (NUMLWriter_t *sw, const NUMLDocument_t *d)
 Writes the given NUML document to an in-memory string and returns a pointer to it. More...
 
LIBNUML_EXTERN int NUMLWriter_hasZlib ()
 Predicate returning non-zero or zero depending on whether libNUML is linked with zlib at compile time. More...
 
LIBNUML_EXTERN int NUMLWriter_hasBzip2 ()
 Predicate returning non-zero or zero depending on whether libNUML is linked with bzip2 at compile time. More...
 
LIBNUML_EXTERN int writeNUML (const NUMLDocument_t *d, const char *filename)
 Writes the given NUML document to filename. More...
 
LIBNUML_EXTERN char * writeNUMLToString (const NUMLDocument_t *d)
 Writes the given NUML document to an in-memory string and returns a pointer to it. More...
 

Function Documentation

◆ NUMLWriter_create()

LIBNUML_EXTERN NUMLWriter_t * NUMLWriter_create ( )

Creates a new NUMLWriter and returns a pointer to it.

◆ NUMLWriter_free()

LIBNUML_EXTERN void NUMLWriter_free ( NUMLWriter_t sw)

Frees the given NUMLWriter.

◆ NUMLWriter_hasBzip2()

LIBNUML_EXTERN int NUMLWriter_hasBzip2 ( )

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

Returns
non-zero if bzip2 is linked, zero otherwise.

◆ NUMLWriter_hasZlib()

LIBNUML_EXTERN int NUMLWriter_hasZlib ( )

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

Returns
non-zero if zlib is linked, zero otherwise.

◆ NUMLWriter_setProgramName()

LIBNUML_EXTERN int NUMLWriter_setProgramName ( NUMLWriter_t sw,
const char *  name 
)

Sets the name of this program.

i. e. the one about to write out the NUMLDocument. 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:
  • LIBNUML_OPERATION_SUCCESS

◆ NUMLWriter_setProgramVersion()

LIBNUML_EXTERN int NUMLWriter_setProgramVersion ( NUMLWriter_t sw,
const char *  version 
)

Sets the version of this program.

i. e. the one about to write out the NUMLDocument. 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:
  • LIBNUML_OPERATION_SUCCESS

◆ NUMLWriter_writeNUML()

LIBNUML_EXTERN int NUMLWriter_writeNUML ( NUMLWriter_t sw,
const NUMLDocument_t d,
const char *  filename 
)

Writes the given NUML 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 .numl. 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.numl if the given filename is test.numl.zip.

Note
To create a gzip/zip file, libNUML needs to be linked with zlib at compile time. Also, libNUML 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 libNUML is not linked with the required library. NUMLWriter_hasZlib() and NUMLWriter_hasBzip2() can be used to check whether libNUML was linked with the library at compile time.
Returns
non-zero on success and zero if the filename could not be opened for writing.

◆ NUMLWriter_writeNUMLToString()

LIBNUML_EXTERN char * NUMLWriter_writeNUMLToString ( NUMLWriter_t sw,
const NUMLDocument_t d 
)

Writes the given NUML 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).

◆ writeNUML()

LIBNUML_EXTERN int writeNUML ( const NUMLDocument_t d,
const char *  filename 
)

Writes the given NUML document to filename.

This convenience function is functionally equivalent to:

NUMLWriter_writeNUML(NUMLWriter_create(), d, filename);

Returns
non-zero on success and zero if the filename could not be opened for writing.

◆ writeNUMLToString()

LIBNUML_EXTERN char * writeNUMLToString ( const NUMLDocument_t d)

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

NUMLWriter_writeNUMLToString(NUMLWriter_create(), d);

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