summaryrefslogtreecommitdiff
path: root/nejdb
diff options
context:
space:
mode:
authoradam <adamansky@gmail.com>2013-06-21 15:34:51 +0700
committeradam <adamansky@gmail.com>2013-06-21 15:34:51 +0700
commit8118b29b557a87147705c63c343f0ef0fc2a261f (patch)
treeb0f349affa37363973df9e09f3e399afce1b02ea /nejdb
parent17b79d3bcb9dcc4edb381a0fdf6de5ad26b75b0d (diff)
downloadejdb-8118b29b557a87147705c63c343f0ef0fc2a261f.tar.gz
ejdb-8118b29b557a87147705c63c343f0ef0fc2a261f.tar.bz2
ejdb-8118b29b557a87147705c63c343f0ef0fc2a261f.zip
#24
Diffstat (limited to 'nejdb')
-rw-r--r--nejdb/Ejdb.DB/EJDB.cs68
-rw-r--r--nejdb/Ejdb.IO/ExtBinaryReader.cs9
-rw-r--r--nejdb/Ejdb.IO/ExtBinaryWriter.cs8
-rwxr-xr-xnejdb/lib/Mono.Posix.dllbin0 -> 187904 bytes
-rw-r--r--nejdb/lib/Mono.Posix.dll.mdbbin0 -> 64746 bytes
-rw-r--r--nejdb/nejdb.csproj31
-rw-r--r--nejdb/nejdb.sln18
-rw-r--r--nejdb/nejdb.userprefs21
8 files changed, 128 insertions, 27 deletions
diff --git a/nejdb/Ejdb.DB/EJDB.cs b/nejdb/Ejdb.DB/EJDB.cs
index 63bb1f1..3f6e005 100644
--- a/nejdb/Ejdb.DB/EJDB.cs
+++ b/nejdb/Ejdb.DB/EJDB.cs
@@ -126,10 +126,23 @@ namespace Ejdb.DB {
const int JBIDXISTR = 1 << 7;
/// <summary>
+ /// The EJDB library version
+ /// </summary>
+ static string _LIBVERSION;
+
+ /// <summary>
+ /// The EJDB library version hex code.
+ /// </summary>
+ static long _LIBHEXVERSION;
+
+ /// <summary>
/// Name if EJDB library
/// </summary>
+ #if EJDBDLL
+ public const string EJDB_LIB_NAME = "tcejdbdll";
+#else
public const string EJDB_LIB_NAME = "tcejdb";
-
+ #endif
/// <summary>
/// Pointer to the native EJDB instance.
/// </summary>
@@ -242,6 +255,9 @@ namespace Ejdb.DB {
//EJDB_EXPORT bool ejdbtranstatus(EJCOLL *jcoll, bool *txactive);
[DllImport(EJDB_LIB_NAME, EntryPoint="ejdbtranstatus")]
internal static extern bool _ejdbtranstatus([In] IntPtr coll, out bool txactive);
+ //EJDB_EXPORT const char *ejdbversion();
+ [DllImport(EJDB_LIB_NAME, EntryPoint="ejdbversion")]
+ internal static extern IntPtr _ejdbversion();
internal static bool _ejdbsetindex(IntPtr coll, string ipath, int flags) {
IntPtr ipathptr = UnixMarshal.StringToHeap(ipath, Encoding.UTF8);
@@ -310,11 +326,59 @@ namespace Ejdb.DB {
}
/// <summary>
+ /// Gets the EJDB library version.
+ /// </summary>
+ /// <value>The LIB version.</value>
+ public static string LIBVersion {
+ get {
+ if (_LIBVERSION != null) {
+ return _LIBVERSION;
+ }
+ lock (typeof(EJDB)) {
+ if (_LIBVERSION != null) {
+ return _LIBVERSION;
+ }
+ IntPtr vres = _ejdbversion();
+ if (vres == IntPtr.Zero) {
+ throw new Exception("Unable to get ejdb library version");
+ }
+ _LIBVERSION = UnixMarshal.PtrToString(vres, Encoding.UTF8);
+ }
+ return _LIBVERSION;
+ }
+ }
+
+ /// <summary>
+ /// Gets the EJDB library hex encoded version.
+ /// </summary>
+ /// <remarks>
+ /// E.g: for the version "1.1.13" return value will be: 0x1113
+ /// </remarks>
+ /// <value>The lib hex version.</value>
+ public static long LibHexVersion {
+ get {
+ if (_LIBHEXVERSION != 0) {
+ return _LIBHEXVERSION;
+ }
+ lock (typeof(EJDB)) {
+ if (_LIBHEXVERSION != 0) {
+ return _LIBHEXVERSION;
+ }
+ _LIBHEXVERSION = Convert.ToInt64("0x" + LIBVersion.Replace(".", ""), 16);
+ }
+ return _LIBHEXVERSION;
+ }
+ }
+
+ /// <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=DEFAULT_OPEN_MODE) {
+ public EJDB(string path, int omode=DEFAULT_OPEN_MODE) {
+ if (EJDB.LibHexVersion < 0x1113) {
+ throw new EJDBException("EJDB library version must be at least '1.1.13' or greater");
+ }
bool rv;
_db = _ejdbnew();
if (_db == IntPtr.Zero) {
diff --git a/nejdb/Ejdb.IO/ExtBinaryReader.cs b/nejdb/Ejdb.IO/ExtBinaryReader.cs
index dfd8dd2..a824e18 100644
--- a/nejdb/Ejdb.IO/ExtBinaryReader.cs
+++ b/nejdb/Ejdb.IO/ExtBinaryReader.cs
@@ -24,6 +24,8 @@ namespace Ejdb.IO {
public static Encoding DEFAULT_ENCODING = Encoding.UTF8;
+ bool _leaveopen;
+
public ExtBinaryReader(Stream input) : this(input, DEFAULT_ENCODING) {
}
@@ -33,7 +35,12 @@ namespace Ejdb.IO {
public ExtBinaryReader(Stream input, bool leaveOpen) : this(input, DEFAULT_ENCODING, leaveOpen) {
}
- public ExtBinaryReader(Stream input, Encoding encoding, bool leaveOpen) : base(input, encoding, leaveOpen) {
+ public ExtBinaryReader(Stream input, Encoding encoding, bool leaveopen) : base(input, encoding) {
+ this._leaveopen = leaveopen;
+ }
+
+ protected override void Dispose(bool disposing) {
+ base.Dispose(!_leaveopen);
}
public string ReadCString() {
diff --git a/nejdb/Ejdb.IO/ExtBinaryWriter.cs b/nejdb/Ejdb.IO/ExtBinaryWriter.cs
index a62b838..bf158ca 100644
--- a/nejdb/Ejdb.IO/ExtBinaryWriter.cs
+++ b/nejdb/Ejdb.IO/ExtBinaryWriter.cs
@@ -23,6 +23,7 @@ namespace Ejdb.IO {
public static Encoding DEFAULT_ENCODING = Encoding.UTF8;
Encoding _encoding;
+ bool _leaveopen;
public ExtBinaryWriter() {
_encoding = DEFAULT_ENCODING;
@@ -31,8 +32,9 @@ namespace Ejdb.IO {
public ExtBinaryWriter(Stream output) : this(output, DEFAULT_ENCODING, false) {
}
- public ExtBinaryWriter(Stream output, Encoding encoding, bool leaveopen) : base(output, encoding, leaveopen) {
+ public ExtBinaryWriter(Stream output, Encoding encoding, bool leaveopen) : base(output, encoding) {
_encoding = encoding;
+ _leaveopen = leaveopen;
}
public ExtBinaryWriter(Stream output, Encoding encoding) : this(output, encoding, false) {
@@ -41,6 +43,10 @@ namespace Ejdb.IO {
public ExtBinaryWriter(Stream output, bool leaveopen) : this(output, DEFAULT_ENCODING, leaveopen) {
}
+ protected override void Dispose(bool disposing) {
+ base.Dispose(!_leaveopen);
+ }
+
public void WriteBSONString(string val) {
byte[] buf = _encoding.GetBytes(val);
Write(buf.Length + 1);
diff --git a/nejdb/lib/Mono.Posix.dll b/nejdb/lib/Mono.Posix.dll
new file mode 100755
index 0000000..09a5dfc
--- /dev/null
+++ b/nejdb/lib/Mono.Posix.dll
Binary files differ
diff --git a/nejdb/lib/Mono.Posix.dll.mdb b/nejdb/lib/Mono.Posix.dll.mdb
new file mode 100644
index 0000000..d88f793
--- /dev/null
+++ b/nejdb/lib/Mono.Posix.dll.mdb
Binary files differ
diff --git a/nejdb/nejdb.csproj b/nejdb/nejdb.csproj
index 0b3b68b..4d4b040 100644
--- a/nejdb/nejdb.csproj
+++ b/nejdb/nejdb.csproj
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Configuration Condition=" '$(Configuration)' == '' ">DebugUnix</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
@@ -11,9 +11,9 @@
<AssemblyName>nejdb</AssemblyName>
<Description>EJDB .Net binding (http://ejdb.org)</Description>
<ReleaseVersion>1.0.0</ReleaseVersion>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <CodePage>65001</CodePage>
</PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugUnix|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
@@ -23,7 +23,7 @@
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseUnix|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
@@ -31,13 +31,34 @@
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugWindows|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug</OutputPath>
+ <DefineConstants>DEBUG;EJDBDLL</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ConsolePause>false</ConsolePause>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseWindows|AnyCPU' ">
+ <DebugType>none</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ConsolePause>false</ConsolePause>
+ <DefineConstants>EJDBDLL</DefineConstants>
+ </PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="nunit.framework, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
<Private>False</Private>
</Reference>
<Reference Include="System.Core" />
- <Reference Include="Mono.Posix" />
+ <Reference Include="Mono.Posix">
+ <HintPath>lib\Mono.Posix.dll</HintPath>
+ </Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
diff --git a/nejdb/nejdb.sln b/nejdb/nejdb.sln
index 940045c..45aba2d 100644
--- a/nejdb/nejdb.sln
+++ b/nejdb/nejdb.sln
@@ -10,14 +10,20 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
+ DebugUnix|Any CPU = DebugUnix|Any CPU
+ ReleaseUnix|Any CPU = ReleaseUnix|Any CPU
+ DebugWindows|Any CPU = DebugWindows|Any CPU
+ ReleaseWindows|Any CPU = ReleaseWindows|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {A24C964C-771F-4359-8C93-4BFCBE451D8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {A24C964C-771F-4359-8C93-4BFCBE451D8B}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {A24C964C-771F-4359-8C93-4BFCBE451D8B}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {A24C964C-771F-4359-8C93-4BFCBE451D8B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A24C964C-771F-4359-8C93-4BFCBE451D8B}.DebugUnix|Any CPU.ActiveCfg = DebugUnix|Any CPU
+ {A24C964C-771F-4359-8C93-4BFCBE451D8B}.DebugUnix|Any CPU.Build.0 = DebugUnix|Any CPU
+ {A24C964C-771F-4359-8C93-4BFCBE451D8B}.DebugWindows|Any CPU.ActiveCfg = DebugWindows|Any CPU
+ {A24C964C-771F-4359-8C93-4BFCBE451D8B}.DebugWindows|Any CPU.Build.0 = DebugWindows|Any CPU
+ {A24C964C-771F-4359-8C93-4BFCBE451D8B}.ReleaseUnix|Any CPU.ActiveCfg = ReleaseUnix|Any CPU
+ {A24C964C-771F-4359-8C93-4BFCBE451D8B}.ReleaseUnix|Any CPU.Build.0 = ReleaseUnix|Any CPU
+ {A24C964C-771F-4359-8C93-4BFCBE451D8B}.ReleaseWindows|Any CPU.ActiveCfg = ReleaseWindows|Any CPU
+ {A24C964C-771F-4359-8C93-4BFCBE451D8B}.ReleaseWindows|Any CPU.Build.0 = ReleaseWindows|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
EndGlobalSection
diff --git a/nejdb/nejdb.userprefs b/nejdb/nejdb.userprefs
index beed88f..6afa03e 100644
--- a/nejdb/nejdb.userprefs
+++ b/nejdb/nejdb.userprefs
@@ -1,13 +1,13 @@
<Properties>
- <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
+ <MonoDevelop.Ide.Workspace ActiveConfiguration="DebugUnix" />
<MonoDevelop.Ide.Workbench ActiveDocument="Ejdb.DB/EJDB.cs">
<Files>
- <File FileName="Ejdb.DB/EJDB.cs" Line="599" Column="5" />
- <File FileName="Ejdb.DB/EJDBQuery.cs" Line="124" Column="5" />
- <File FileName="Ejdb.BSON/BSONDocument.cs" Line="334" Column="60" />
- <File FileName="Ejdb.Tests/TestEJDB.cs" Line="176" Column="13" />
- <File FileName="Ejdb.BSON/BSONType.cs" Line="24" Column="17" />
- <File FileName="Ejdb.BSON/BSONIterator.cs" Line="78" Column="29" />
+ <File FileName="Ejdb.DB/EJDB.cs" Line="356" Column="17" />
+ <File FileName="Ejdb.BSON/BSONDocument.cs" Line="1" Column="1" />
+ <File FileName="Ejdb.Tests/TestEJDB.cs" Line="28" Column="19" />
+ <File FileName="Ejdb.BSON/BSONType.cs" Line="1" Column="1" />
+ <File FileName="Ejdb.IO/ExtBinaryReader.cs" Line="48" Column="12" />
+ <File FileName="Ejdb.IO/ExtBinaryWriter.cs" Line="41" Column="4" />
</Files>
<Pads>
<Pad Id="ProjectPad">
@@ -37,14 +37,11 @@
<State selected="True" />
</Pad>
<Pad Id="MonoDevelop.NUnit.TestPad">
- <State expanded="True">
+ <State expanded="True" selected="True">
<Node name="nejdb" expanded="True">
<Node name="Ejdb" expanded="True">
<Node name="Tests" expanded="True">
- <Node name="TestBSON" expanded="True" />
- <Node name="TestEJDB" expanded="True">
- <Node name="Test4Q2" selected="True" />
- </Node>
+ <Node name="TestEJDB" expanded="True" />
</Node>
</Node>
</Node>