1/* ---------------------------------------------------------------------------- 2 * This file was automatically generated by SWIG (http://www.swig.org). 3 * Version 1.3.38 4 * 5 * Do not make changes to this file unless you know what you are doing--modify 6 * the SWIG interface file instead. 7 * ----------------------------------------------------------------------------- */ 8 9namespace BerkeleyDB.Internal { 10 11using System; 12using System.Runtime.InteropServices; 13 14internal class DBC : IDisposable { 15 private HandleRef swigCPtr; 16 protected bool swigCMemOwn; 17 18 internal DBC(IntPtr cPtr, bool cMemoryOwn) { 19 swigCMemOwn = cMemoryOwn; 20 swigCPtr = new HandleRef(this, cPtr); 21 } 22 23 internal static HandleRef getCPtr(DBC obj) { 24 return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; 25 } 26 27 ~DBC() { 28 Dispose(); 29 } 30 31 public virtual void Dispose() { 32 lock(this) { 33 if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { 34 swigCMemOwn = false; 35 libdb_csharpPINVOKE.delete_DBC(swigCPtr); 36 } 37 swigCPtr = new HandleRef(null, IntPtr.Zero); 38 GC.SuppressFinalize(this); 39 } 40 } 41 42 internal DBC dup(uint flags) { 43 int err = 0; 44 DBC ret = dup(flags, ref err); 45 DatabaseException.ThrowException(err); 46 return ret; 47 } 48 49 internal int close() { 50 int ret = libdb_csharpPINVOKE.DBC_close(swigCPtr); 51 if (ret == 0) 52 /* Close is a db handle destructor. Reflect that in the wrapper class. */ 53 swigCPtr = new HandleRef(null, IntPtr.Zero); 54 else 55 DatabaseException.ThrowException(ret); 56 return ret; 57} 58 59 internal int cmp(DBC other_dbc, ref int result, uint flags) { 60 int ret; 61 ret = libdb_csharpPINVOKE.DBC_cmp(swigCPtr, DBC.getCPtr(other_dbc), ref result, flags); 62 DatabaseException.ThrowException(ret); 63 return ret; 64} 65 66 internal int count(ref uint cnt, uint flags) { 67 int ret; 68 ret = libdb_csharpPINVOKE.DBC_count(swigCPtr, ref cnt, flags); 69 DatabaseException.ThrowException(ret); 70 return ret; 71} 72 73 internal int del(uint flags) { 74 int ret; 75 ret = libdb_csharpPINVOKE.DBC_del(swigCPtr, flags); 76 DatabaseException.ThrowException(ret); 77 return ret; 78} 79 80 private DBC dup(uint flags, ref int err) { 81 IntPtr cPtr = libdb_csharpPINVOKE.DBC_dup(swigCPtr, flags, ref err); 82 DBC ret = (cPtr == IntPtr.Zero) ? null : new DBC(cPtr, false); 83 return ret; 84 } 85 86 internal int get(DatabaseEntry key, DatabaseEntry data, uint flags) { 87 try { 88 int ret; 89 ret = libdb_csharpPINVOKE.DBC_get(swigCPtr, DBT.getCPtr(DatabaseEntry.getDBT(key)), DBT.getCPtr(DatabaseEntry.getDBT(data)), flags); 90 DatabaseException.ThrowException(ret); 91 return ret; 92} finally { 93 GC.KeepAlive(key); 94 GC.KeepAlive(data); 95 } 96 } 97 98 internal int pget(DatabaseEntry key, DatabaseEntry pkey, DatabaseEntry data, uint flags) { 99 try { 100 int ret; 101 ret = libdb_csharpPINVOKE.DBC_pget(swigCPtr, DBT.getCPtr(DatabaseEntry.getDBT(key)), DBT.getCPtr(DatabaseEntry.getDBT(pkey)), DBT.getCPtr(DatabaseEntry.getDBT(data)), flags); 102 DatabaseException.ThrowException(ret); 103 return ret; 104} finally { 105 GC.KeepAlive(key); 106 GC.KeepAlive(pkey); 107 GC.KeepAlive(data); 108 } 109 } 110 111 internal int put(DatabaseEntry key, DatabaseEntry data, uint flags) { 112 try { 113 int ret; 114 ret = libdb_csharpPINVOKE.DBC_put(swigCPtr, DBT.getCPtr(DatabaseEntry.getDBT(key)), DBT.getCPtr(DatabaseEntry.getDBT(data)), flags); 115 DatabaseException.ThrowException(ret); 116 return ret; 117} finally { 118 GC.KeepAlive(key); 119 GC.KeepAlive(data); 120 } 121 } 122 123 internal int set_priority(uint priority) { 124 int ret; 125 ret = libdb_csharpPINVOKE.DBC_set_priority(swigCPtr, priority); 126 DatabaseException.ThrowException(ret); 127 return ret; 128} 129 130 internal DBC() : this(libdb_csharpPINVOKE.new_DBC(), true) { 131 } 132 133} 134 135} 136