#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for jejdb 1.0.1.
+# Generated by GNU Autoconf 2.69 for jejdb 1.0.2.
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
# Identity of this package.
PACKAGE_NAME='jejdb'
PACKAGE_TARNAME='jejdb'
-PACKAGE_VERSION='1.0.1'
-PACKAGE_STRING='jejdb 1.0.1'
+PACKAGE_VERSION='1.0.2'
+PACKAGE_STRING='jejdb 1.0.2'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures jejdb 1.0.1 to adapt to many kinds of systems.
+\`configure' configures jejdb 1.0.2 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of jejdb 1.0.1:";;
+ short | recursive ) echo "Configuration of jejdb 1.0.2:";;
esac
cat <<\_ACEOF
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-jejdb configure 1.0.1
+jejdb configure 1.0.2
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by jejdb $as_me 1.0.1, which was
+It was created by jejdb $as_me 1.0.2, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by jejdb $as_me 1.0.1, which was
+This file was extended by jejdb $as_me 1.0.2, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-jejdb config.status 1.0.1
+jejdb config.status 1.0.2
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
test -n "$CPPFLAGS" && MYCPPFLAGS="$CPPFLAGS $MYCPPFLAGS"
test -n "$LDFLAGS" && MYLDFLAGS="$LDFLAGS $MYLDFLAGS"
-AC_INIT(jejdb, 1.0.1)
+AC_INIT(jejdb, 1.0.2)
AC_PREFIX_DEFAULT(/usr)
# Package information
/**
* Default open mode
*/
- public static final int JBO_DEFAULT = (JBOWRITER | JBOCREAT | JBOTSYNC);
+ public static final int JBO_DEFAULT = (JBOWRITER | JBOCREAT);
static {
System.loadLibrary("jejdb");
/**
* Open database using default open mode.
* <p/>
- * Default open mode: JBOWRITER | JBOCREAT | JBOTSYNC
+ * Default open mode: JBOWRITER | JBOCREAT
*
* @param path EJDB path
* @throws EJDBException
/**
* Open database.
* <p/>
- * Default open mode: JBOWRITER | JBOCREAT | JBOTSYNC
+ * Default open mode: JBOWRITER | JBOCREAT
*
* @param path EJDB path
* @param mode Open mode
package = "luaejdb"
-version = "1.0.3-1"
+version = "1.0.4-0"
source = {
url = "https://github.com/Softmotions/ejdb.git"
}
//Cursor user data
#define EJDBCURSORMT "mtejc"
-#define DEFAULT_OPEN_MODE (JBOWRITER | JBOCREAT | JBOTSYNC)
+#define DEFAULT_OPEN_MODE (JBOWRITER | JBOCREAT)
#define TBLSETNUMCONST(_CN) \
do { \
// if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
// Boston, MA 02111-1307 USA.
// ============================================================================================
-
using System;
+using System.Runtime.InteropServices;
namespace Ejdb.DB {
- public class EJDB {
+ public class EJDB : IDisposable {
+ //Open modes
+ public const int JBOREADER = 1 << 0;
+ public const int JBOWRITER = 1 << 1;
+ public const int JBOCREAT = 1 << 2;
+ public const int JBOTRUNC = 1 << 3;
+ public const int JBONOLCK = 1 << 4;
+ public const int JBOLCKNB = 1 << 5;
+ public const int JBOTSYNC = 1 << 6;
+ public const int DEFAULT_OPEN_MODE = (JBOWRITER | JBOCREAT);
+ public const string EJDB_LIB_NAME = "tcejdb";
+ IntPtr _db = (IntPtr) 0x0;
+ #region Functions
+ [DllImport(EJDB_LIB_NAME, EntryPoint="ejdbnew")]
+ static extern IntPtr _ejdbnew();
+
+ [DllImport(EJDB_LIB_NAME, EntryPoint="ejdbdel")]
+ static extern IntPtr _ejdbdel(IntPtr db);
+
+ [DllImport(EJDB_LIB_NAME, EntryPoint="ejdbopen", CharSet=CharSet.Auto)]
+ static extern bool _ejdbopen(IntPtr db, string path, int mode);
+
+ [DllImport(EJDB_LIB_NAME, EntryPoint="ejdbclose")]
+ static extern bool _ejdbclose(IntPtr db);
- IntPtr dbptr;
+ [DllImport(EJDB_LIB_NAME, EntryPoint="ejdbisopen")]
+ static extern bool _ejdbisopen(IntPtr db);
+
+ [DllImport(EJDB_LIB_NAME, EntryPoint="ejdbecode")]
+ static extern int _ejdbecode(IntPtr db);
+
+ [DllImport(EJDB_LIB_NAME, EntryPoint="ejdberrmsg")]
+ static extern string _ejdberrmsg(int ecode);
+ #endregion
+ /// <summary>
+ /// Gets the last DB error code or <c>null</c> if underlying native database object does not exist.
+ /// </summary>
+ /// <value>The last DB error code.</value>
+ public int? LastDBErrorCode {
+ get {
+ return (_db.ToInt32() != 0x0) ? (int?) _ejdbecode(_db) : null;
+ }
+ }
- public EJDB() {
+ /// <summary>
+ /// Gets the last DB error message or <c>null</c> if underlying native database object does not exist.
+ /// </summary>
+ public string LastDBErrorMsg {
+ get {
+ int? ecode = LastDBErrorCode;
+ return ecode != null ? _ejdberrmsg((int) ecode) : null;
+ }
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether this EJDB databse is open.
+ /// </summary>
+ /// <value><c>true</c> if this instance is open; otherwise, <c>false</c>.</value>
+ public bool IsOpen {
+ get {
+ return _ejdbisopen(_db);
+ }
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Ejdb.DB.EJDB"/> class.
+ /// </summary>
+ /// <param name="path">The main database file path.</param>
+ /// <param name="omode">Open mode.</param>
+ public EJDB(string path, int omode) {
+ bool rv;
+ _db = _ejdbnew();
+ if (_db.ToInt32() == 0x0) {
+ throw new EJDBException("Unable to create ejdb instance");
+ }
+ try {
+ rv = _ejdbopen(_db, path, omode);
+ } catch (Exception) {
+ Dispose();
+ throw;
+ }
+ if (!rv) {
+ throw new EJDBException(this);
+ }
}
~EJDB() {
+ Dispose();
+ }
+
+ public void Dispose() {
+ if (_db.ToInt32() != 0x0) {
+ IntPtr db = _db;
+ _db = (IntPtr) 0x0;
+ if (db.ToInt32() != 0x0) {
+ _ejdbdel(db);
+ }
+ }
}
}
}
--- /dev/null
+// ============================================================================================
+// .NET API for EJDB database library http://ejdb.org
+// Copyright (C) 2012-2013 Softmotions Ltd <info@softmotions.com>
+//
+// This file is part of EJDB.
+// EJDB is free software; you can redistribute it and/or modify it under the terms of
+// the GNU Lesser General Public License as published by the Free Software Foundation; either
+// version 2.1 of the License or any later version. EJDB is distributed in the hope
+// that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+// License for more details.
+// You should have received a copy of the GNU Lesser General Public License along with EJDB;
+// if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+// Boston, MA 02111-1307 USA.
+// ============================================================================================
+using System;
+
+namespace Ejdb.DB {
+
+ public class EJDBException : Exception {
+
+ public int? Code {
+ get;
+ private set;
+ }
+
+ public EJDBException() {
+ }
+
+ public EJDBException(string msg) : base(msg) {
+ }
+
+ public EJDBException(int code, string msg) : base(msg) {
+ this.Code = code;
+ }
+
+ public EJDBException(EJDB db) : base(db.LastDBErrorMsg) {
+ this.Code = db.LastDBErrorCode;
+ }
+
+ public override string ToString() {
+ return string.Format("[EJDBException: Code={0}, Msg={1}]", Code, Message);
+ }
+ }
+}
+
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
+ <Reference Include="Mono.Posix" />
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Ejdb.BSON\BSONConstants.cs" />
<Compile Include="Ejdb.JSON\JSONReader.cs" />
<Compile Include="Ejdb.JSON\JSONElement.cs" />
+ <Compile Include="Ejdb.DB\EJDBException.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.Workbench ActiveDocument="Ejdb.DB/EJDB.cs">
<Files>
- <File FileName="Ejdb.BSON/BSONArray.cs" Line="12" Column="61" />
- <File FileName="Ejdb.JSON/JSONReader.cs" Line="32" Column="4" />
- <File FileName="Ejdb.JSON/JSONElement.cs" Line="1" Column="1" />
- <File FileName="Ejdb.BSON/BSONDocument.cs" Line="322" Column="1" />
- <File FileName="Ejdb.BSON/BSONIterator.cs" Line="1" Column="1" />
- <File FileName="Ejdb.BSON/BSONType.cs" Line="1" Column="1" />
- <File FileName="Ejdb.BSON/BSONOid.cs" Line="1" Column="1" />
- <File FileName="Ejdb.IO/ExtBinaryWriter.cs" Line="1" Column="1" />
- <File FileName="Ejdb.DB/EJDB.cs" Line="22" Column="3" />
+ <File FileName="Ejdb.Tests/TestBSON.cs" Line="27" Column="37" />
+ <File FileName="Ejdb.DB/EJDB.cs" Line="26" Column="38" />
+ <File FileName="Ejdb.DB/EJDBException.cs" Line="25" Column="4" />
+ <File FileName="Ejdb.BSON/InvalidBSONDataException.cs" Line="22" Column="36" />
+ <File FileName="Ejdb.BSON/BSONType.cs" Line="20" Column="15" />
</Files>
<Pads>
<Pad Id="ProjectPad">
<State selected="True" />
</Pad>
<Pad Id="MonoDevelop.NUnit.TestPad">
- <State expanded="True">
- <Node name="nejdb" expanded="True" selected="True">
- <Node name="Ejdb" expanded="True">
- <Node name="Tests" expanded="True">
- <Node name="TestBSON" expanded="True" />
- </Node>
- </Node>
- </Node>
- </State>
+ <State expanded="True" selected="True" />
</Pad>
</Pads>
</MonoDevelop.Ide.Workbench>
}
var EJDBImpl = ejdblib.NodeEJDB;
-const DEFAULT_OPEN_MODE = (ejdblib.JBOWRITER | ejdblib.JBOCREAT | ejdblib.JBOTSYNC);
+const DEFAULT_OPEN_MODE = (ejdblib.JBOWRITER | ejdblib.JBOCREAT);
var EJDB = function(dbFile, openMode) {
Object.defineProperty(this, "_impl", {
value : new EJDBImpl(dbFile, (openMode > 0) ? openMode : DEFAULT_OPEN_MODE),
{
"name" : "ejdb",
- "version" : "1.1.12-0",
+ "version" : "1.1.13-0",
"config" : {
"windownloadurl_ia32" : "http://dl.dropboxusercontent.com/u/4709222/ejdb/tcejdb-1.1.12-mingw32-i686.zip",
"windownloadurl_x64" : "http://dl.dropboxusercontent.com/u/4709222/ejdb/tcejdb-1.1.12-mingw32-x86_64.zip"
JBONOLCK = _pyejdb.JBONOLCK
JBOLCKNB = _pyejdb.JBOLCKNB
JBOTSYNC = _pyejdb.JBOTSYNC
-DEFAULT_OPEN_MODE = JBOWRITER | JBOCREAT | JBOTSYNC
+DEFAULT_OPEN_MODE = JBOWRITER | JBOCREAT
#Query flags
JBQRYCOUNT = _pyejdb.JBQRYCOUNT
JBOLCKNB - Lock without blocking
JBOTSYNC - Synchronize db on every transaction
- Default open mode: DEFAULT_OPEN_MODE = JBOWRITER | JBOCREAT | JBOTSYNC
+ Default open mode: DEFAULT_OPEN_MODE = JBOWRITER | JBOCREAT
"""
def __init__(self, fpath, mode=DEFAULT_OPEN_MODE):
setup(
name="pyejdb",
- version="1.0.12",
+ version="1.0.13",
url="http://ejdb.org",
keywords=["ejdb", "tokyocabinet", "nosql", "database", "storage", "embedded", "mongodb", "json"],
description="Python 2.7/3.x binding for EJDB database engine.",
#include "rbbson.h"
-#define DEFAULT_OPEN_MODE (JBOWRITER | JBOCREAT | JBOTSYNC)
+#define DEFAULT_OPEN_MODE (JBOWRITER | JBOCREAT)
typedef struct {
EJDB* ejdb;