1 //------------------------------------------------------------------------------
2 // <auto-generated />
3 //
4 // This file was automatically generated by SWIG (http://www.swig.org).
5 // Version 4.0.2
6 //
7 // Do not make changes to this file unless you know what you are doing--modify
8 // the SWIG interface file instead.
9 //------------------------------------------------------------------------------
10 
11 namespace libsbml {
12 
13  using System;
14  using System.Runtime.InteropServices;
15 
16 /**
17  * @sbmlpackage{core}
18  *
19 @htmlinclude pkg-marker-core.html File and text-string SBML writer.
20  *
21  * @htmlinclude not-sbml-warning.html
22  *
23  * The SBMLWriter class is the converse of SBMLReader, and provides the
24  * main interface for serializing SBML models into XML and writing the
25  * result to an output stream or to files and text strings.  The methods
26  * for writing SBML all take an SBMLDocument object and a destination.
27  * They return a boolean or integer value to indicate success or failure.
28  *
29  * @section sbmlwriter-compression Support for writing compressed files
30  *
31  * LibSBML provides support for writing (as well as reading) compressed
32  * SBML files.  The process is transparent to the calling
33  * application---the application does not need to do anything
34  * deliberate to invoke the functionality.  If a given SBML filename ends
35  * with an extension for the @em gzip, @em zip or @em bzip2 compression
36  * formats (respectively, <code>&quot;.gz&quot;</code>,
37  * <code>&quot;.zip&quot;</code>, or <code>&quot;.bz2&quot;</code>),
38  * then the methods
39  * SBMLWriter::writeSBML(@if java SBMLDocument, String@endif)
40  * and SBMLReader::readSBML(@if java String@endif)
41  * will automatically compress and decompress the file while writing and
42  * reading it.  If the filename has no such extension, it
43  * will be written and read uncompressed as normal.
44  *
45  * The compression feature requires that the @em zlib (for @em gzip and @em
46  * zip formats) and/or @em bzip2 (for @em bzip2 format) be available on the
47  * system running libSBML, and that libSBML was configured with their
48  * support compiled-in.  Please see the libSBML @if clike <a href='libsbml-installation.html'>installation instructions</a>@endif@if python <a href='libsbml-installation.html'>installation instructions</a>@endif@if java  <a href='../../../libsbml-installation.html'>installation instructions</a>@endif for
49  * more information about this.  The methods
50  * SBMLWriter::hasZlib() and
51  * SBMLWriter::hasBzip2()
52  * can be used by an application to query at run-time whether support
53  * for the compression libraries is available in the present copy of
54  * libSBML.
55  *
56  * Support for compression is not mandated by the SBML standard, but
57  * applications may find it helpful, particularly when large SBML models
58  * are being communicated across data links of limited bandwidth.
59  */
60 
61 public class SBMLWriter : global::System.IDisposable {
62 	private HandleRef swigCPtr;
63 	protected bool swigCMemOwn;
64 
SBMLWriter(IntPtr cPtr, bool cMemoryOwn)65 	internal SBMLWriter(IntPtr cPtr, bool cMemoryOwn)
66 	{
67 		swigCMemOwn = cMemoryOwn;
68 		swigCPtr    = new HandleRef(this, cPtr);
69 	}
70 
getCPtr(SBMLWriter obj)71 	internal static HandleRef getCPtr(SBMLWriter obj)
72 	{
73 		return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
74 	}
75 
getCPtrAndDisown(SBMLWriter obj)76 	internal static HandleRef getCPtrAndDisown (SBMLWriter obj)
77 	{
78 		HandleRef ptr = new HandleRef(null, IntPtr.Zero);
79 
80 		if (obj != null)
81 		{
82 			ptr             = obj.swigCPtr;
83 			obj.swigCMemOwn = false;
84 		}
85 
86 		return ptr;
87 	}
88 
~SBMLWriter()89   ~SBMLWriter() {
90     Dispose(false);
91   }
92 
Dispose()93   public void Dispose() {
94     Dispose(true);
95     global::System.GC.SuppressFinalize(this);
96   }
97 
Dispose(bool disposing)98   protected virtual void Dispose(bool disposing) {
99     lock(this) {
100       if (swigCPtr.Handle != global::System.IntPtr.Zero) {
101         if (swigCMemOwn) {
102           swigCMemOwn = false;
103           libsbmlPINVOKE.delete_SBMLWriter(swigCPtr);
104         }
105         swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
106       }
107     }
108   }
109 
operator ==(SBMLWriter lhs, SBMLWriter rhs)110   public static bool operator==(SBMLWriter lhs, SBMLWriter rhs)
111   {
112     if((Object)lhs == (Object)rhs)
113     {
114       return true;
115     }
116 
117     if( ((Object)lhs == null) || ((Object)rhs == null) )
118     {
119       return false;
120     }
121 
122     return (getCPtr(lhs).Handle.ToString() == getCPtr(rhs).Handle.ToString());
123   }
124 
operator !=(SBMLWriter lhs, SBMLWriter rhs)125   public static bool operator!=(SBMLWriter lhs, SBMLWriter rhs)
126   {
127     return !(lhs == rhs);
128   }
129 
Equals(Object sb)130   public override bool Equals(Object sb)
131   {
132     if ( ! (sb is SBMLWriter) )
133     {
134       return false;
135     }
136 
137     return this == (SBMLWriter)sb;
138   }
139 
GetHashCode()140   public override int GetHashCode()
141   {
142     return swigCPtr.Handle.ToInt32();
143   }
144 
145 
146 /**
147    * Creates a new SBMLWriter.
148    *
149    * The libSBML SBMLWriter objects offer methods for writing SBML in
150    * XML form to files and text strings.
151    */ public
SBMLWriter()152  SBMLWriter() : this(libsbmlPINVOKE.new_SBMLWriter(), true) {
153   }
154 
155 
156 /**
157    * Sets the name of this program, i.e., the program that is about to
158    * write out the SBMLDocument.
159    *
160    * If the program name and version are set (see
161    * SBMLWriter::setProgramVersion(@if java String@endif)), the
162    * following XML comment, intended for human consumption, will be written
163    * at the beginning of the XML document:
164    * @verbatim
165  <!-- Created by <program name> version <program version>
166  on yyyy-MM-dd HH:mm with libSBML version <libsbml version>. -->
167  @endverbatim
168    *
169    * If the program name and version are not set at some point before
170    * calling the writeSBML() methods, no such comment is written out.
171    *
172    * @param name the name of this program (where 'this program' refers to
173    * program in which libSBML is embedded, not libSBML itself!)
174    *
175    *
176  * @return integer value indicating success/failure of the
177  * function.  @if clike The value is drawn from the
178  * enumeration #OperationReturnValues_t. @endif This particular
179  * function only does one thing irrespective of user input or
180  * object state, and thus will only return a single value:
181  * @li @link libsbml#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink
182    *
183    * @see setProgramVersion(string version)
184    */ public
setProgramName(string name)185  int setProgramName(string name) {
186     int ret = libsbmlPINVOKE.SBMLWriter_setProgramName(swigCPtr, name);
187     return ret;
188   }
189 
190 
191 /**
192    * Sets the version of this program, i.e., the program that is about to
193    * write out the SBMLDocument.
194    *
195    * If the program version and name are set (see
196    * SBMLWriter::setProgramName(@if java String@endif)), the
197    * following XML comment, intended for human consumption, will be written
198    * at the beginning of the document:
199    * @verbatim
200  <!-- Created by <program name> version <program version>
201  on yyyy-MM-dd HH:mm with libSBML version <libsbml version>. -->
202  @endverbatim
203    *
204    * If the program version and name are not set at some point before
205    * calling the writeSBML() methods, no such comment is written out.
206    *
207    * @param version the version of this program (where 'this program'
208    * refers to program in which libSBML is embedded, not libSBML itself!)
209    *
210    *
211  * @return integer value indicating success/failure of the
212  * function.  @if clike The value is drawn from the
213  * enumeration #OperationReturnValues_t. @endif This particular
214  * function only does one thing irrespective of user input or
215  * object state, and thus will only return a single value:
216  * @li @link libsbml#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink
217    *
218    * @see setProgramName(string name)
219    */ public
setProgramVersion(string version)220  int setProgramVersion(string version) {
221     int ret = libsbmlPINVOKE.SBMLWriter_setProgramVersion(swigCPtr, version);
222     return ret;
223   }
224 
225 
226 /**
227    * Writes the given SBML document to filename.
228    *
229    * @htmlinclude assuming-compressed-file.html
230    *
231    * @param d the SBML document to be written.
232    *
233    * @param filename the name or full pathname of the file where the SBML
234    * is to be written.
235    *
236    * @return @c true on success and @c false if the filename could not be
237    * opened for writing.
238    *
239    * @note @htmlinclude note-writing-zipped-files.html
240    *
241    * @see setProgramVersion(string version)
242    * @see setProgramName(string name)
243    */ public
writeSBML(SBMLDocument d, string filename)244  bool writeSBML(SBMLDocument d, string filename) {
245     bool ret = libsbmlPINVOKE.SBMLWriter_writeSBML__SWIG_0(swigCPtr, SBMLDocument.getCPtr(d), filename);
246     return ret;
247   }
248 
249 
250 /**
251    * Writes the given SBML document to the output stream.
252    *
253    * @param d the SBML document to be written.
254    *
255    * @param stream the stream object where the SBML is to be written.
256    *
257    * @return @c true on success and @c false if one of the underlying
258    * parser components fail (rare).
259    *
260    * @see setProgramVersion(string version)
261    * @see setProgramName(string name)
262    */ public
writeSBML(SBMLDocument d, OStream stream)263  bool writeSBML(SBMLDocument d, OStream stream) {
264     bool ret = libsbmlPINVOKE.SBMLWriter_writeSBML__SWIG_1(swigCPtr, SBMLDocument.getCPtr(d), SWIGTYPE_p_std__ostream.getCPtr(stream.get_ostream()));
265     if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve();
266     return ret;
267   }
268 
269 
270 /** */ /* libsbml-internal */ public
writeToString(SBMLDocument d)271  string writeToString(SBMLDocument d) {
272     string ret = libsbmlPINVOKE.SBMLWriter_writeToString(swigCPtr, SBMLDocument.getCPtr(d));
273     return ret;
274   }
275 
276 
277 /**
278    * Writes the given SBML document to filename.
279    *
280    * @htmlinclude assuming-compressed-file.html
281    *
282    * @param d the SBML document to be written.
283    *
284    * @param filename the name or full pathname of the file where the SBML
285    * is to be written.
286    *
287    * @return @c true on success and @c false if the filename could not be
288    * opened for writing.
289    *
290    * @note @htmlinclude note-writing-zipped-files.html
291    *
292    * @see setProgramVersion(string version)
293    * @see setProgramName(string name)
294    */ public
writeSBMLToFile(SBMLDocument d, string filename)295  bool writeSBMLToFile(SBMLDocument d, string filename) {
296     bool ret = libsbmlPINVOKE.SBMLWriter_writeSBMLToFile(swigCPtr, SBMLDocument.getCPtr(d), filename);
297     return ret;
298   }
299 
300 
301 /**
302    * Writes the given SBML document to an in-memory string and returns a
303    * pointer to it.
304    *
305    * The string is owned by the caller and should be freed (with @c free())
306    * when no longer needed.
307    *
308    * @param d the SBML document to be written.
309    *
310    * @return the string on success and @c 0 if one of the underlying parser
311    * components fail.
312    *
313    * @see setProgramVersion(string version)
314    * @see setProgramName(string name)
315    */ public
writeSBMLToString(SBMLDocument d)316  string writeSBMLToString(SBMLDocument d) {
317     string ret = libsbmlPINVOKE.SBMLWriter_writeSBMLToString(swigCPtr, SBMLDocument.getCPtr(d));
318     return ret;
319   }
320 
321 
322 /**
323    * Predicate returning @c true if this copy of libSBML has been linked
324    * with the <em>zlib</em> library.
325    *
326    * LibSBML supports reading and writing files compressed with either
327    * bzip2 or zip/gzip compression.  The facility depends on libSBML having
328    * been compiled with the necessary support libraries.  This method
329    * allows a calling program to inquire whether that is the case for the
330    * copy of libSBML it is using.
331    *
332    * @return @c true if libSBML is linked with zlib, @c false otherwise.
333    *
334    *
335  * @if python @note Because this is a static method on a class, the Python
336  * language interface for libSBML will contain two variants.  One will be the
337  * expected, normal static method on the class (i.e., a regular
338  * <em>methodName</em>), and the other will be a standalone top-level
339  * function with the name <em>ClassName_methodName()</em>. This is merely an
340  * artifact of how the language interfaces are created in libSBML.  The
341  * methods are functionally identical. @endif
342  *
343  *
344    *
345    * @see @if clike hasBzip2() @else SBMLWriter::hasBzip2() @endif
346    */ public
hasZlib()347  static bool hasZlib() {
348     bool ret = libsbmlPINVOKE.SBMLWriter_hasZlib();
349     return ret;
350   }
351 
352 
353 /**
354    * Predicate returning @c true if this copy of libSBML has been linked
355    * with the <em>bzip2</em> library.
356    *
357    * LibSBML supports reading and writing files compressed with either
358    * bzip2 or zip/gzip compression.  The facility depends on libSBML having
359    * been compiled with the necessary support libraries.  This method
360    * allows a calling program to inquire whether that is the case for the
361    * copy of libSBML it is using.
362    *
363    * @return @c true if libSBML is linked with bzip2, @c false otherwise.
364    *
365    *
366  * @if python @note Because this is a static method on a class, the Python
367  * language interface for libSBML will contain two variants.  One will be the
368  * expected, normal static method on the class (i.e., a regular
369  * <em>methodName</em>), and the other will be a standalone top-level
370  * function with the name <em>ClassName_methodName()</em>. This is merely an
371  * artifact of how the language interfaces are created in libSBML.  The
372  * methods are functionally identical. @endif
373  *
374  *
375    *
376    * @see @if clike hasZlib() @else SBMLWriter::hasZlib() @endif
377    */ public
hasBzip2()378  static bool hasBzip2() {
379     bool ret = libsbmlPINVOKE.SBMLWriter_hasBzip2();
380     return ret;
381   }
382 
383 }
384 
385 }
386