From e6e3ee2f8d9c346761c0e1b55886ca26a5f69534 Mon Sep 17 00:00:00 2001 From: adam Date: Wed, 5 Jun 2013 21:06:33 +0700 Subject: [PATCH] #24 --- .gitignore | 2 + nejdb/AssemblyInfo.cs | 27 ++++++++++ nejdb/Ejdb.BS/BSONMarshaller.cs | 11 +++++ nejdb/Ejdb.Bson/BSONMarshaller.cs | 11 +++++ nejdb/Ejdb.DB/EJDB.cs | 27 ++++++++++ nejdb/Ejdb.Db/EJDB.cs | 11 +++++ nejdb/Ejdb.SON/BSONIterator.cs | 79 ++++++++++++++++++++++++++++++ nejdb/Ejdb.SON/BSONMarshaller.cs | 28 +++++++++++ nejdb/Ejdb.SON/BSONType.cs | 46 +++++++++++++++++ nejdb/Ejdb.SON/InvalidBSONDataException.cs | 30 ++++++++++++ nejdb/Ejdb.Tests/TestOne.cs | 36 ++++++++++++++ nejdb/NEJDB.BSON/BSONMarshaller.cs | 10 ++++ nejdb/NEJDB.DB/EJDB.cs | 10 ++++ nejdb/README.md | 0 nejdb/nejdb.csproj | 63 ++++++++++++++++++++++++ nejdb/nejdb.sln | 34 +++++++++++++ nejdb/nejdb.userprefs | 37 ++++++++++++++ 17 files changed, 462 insertions(+) create mode 100644 nejdb/AssemblyInfo.cs create mode 100644 nejdb/Ejdb.BS/BSONMarshaller.cs create mode 100644 nejdb/Ejdb.Bson/BSONMarshaller.cs create mode 100644 nejdb/Ejdb.DB/EJDB.cs create mode 100644 nejdb/Ejdb.Db/EJDB.cs create mode 100644 nejdb/Ejdb.SON/BSONIterator.cs create mode 100644 nejdb/Ejdb.SON/BSONMarshaller.cs create mode 100644 nejdb/Ejdb.SON/BSONType.cs create mode 100644 nejdb/Ejdb.SON/InvalidBSONDataException.cs create mode 100644 nejdb/Ejdb.Tests/TestOne.cs create mode 100644 nejdb/NEJDB.BSON/BSONMarshaller.cs create mode 100644 nejdb/NEJDB.DB/EJDB.cs create mode 100644 nejdb/README.md create mode 100644 nejdb/nejdb.csproj create mode 100644 nejdb/nejdb.sln create mode 100644 nejdb/nejdb.userprefs diff --git a/.gitignore b/.gitignore index 00e2263..75db4a7 100644 --- a/.gitignore +++ b/.gitignore @@ -146,5 +146,7 @@ __pycache__ /jejdb/*.so.* /jejdb/Makefile +/nejdb/bin/ +/nejdb/test-results/ diff --git a/nejdb/AssemblyInfo.cs b/nejdb/AssemblyInfo.cs new file mode 100644 index 0000000..8ff11a8 --- /dev/null +++ b/nejdb/AssemblyInfo.cs @@ -0,0 +1,27 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle("nejdb")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Softmotions Ltd.")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("Copyright (C) 2012-2013 Softmotions Ltd ")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion("1.0.*")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/nejdb/Ejdb.BS/BSONMarshaller.cs b/nejdb/Ejdb.BS/BSONMarshaller.cs new file mode 100644 index 0000000..72a890c --- /dev/null +++ b/nejdb/Ejdb.BS/BSONMarshaller.cs @@ -0,0 +1,11 @@ +using System; + +namespace Ejdb.Bson { + + public class BSONMarshaller { + + public BSONMarshaller() { + } + } +} + diff --git a/nejdb/Ejdb.Bson/BSONMarshaller.cs b/nejdb/Ejdb.Bson/BSONMarshaller.cs new file mode 100644 index 0000000..78014a0 --- /dev/null +++ b/nejdb/Ejdb.Bson/BSONMarshaller.cs @@ -0,0 +1,11 @@ +using System; + +namespace NEJDB.BSON { + + public class BSONMarshaller { + + public BSONMarshaller() { + } + } +} + diff --git a/nejdb/Ejdb.DB/EJDB.cs b/nejdb/Ejdb.DB/EJDB.cs new file mode 100644 index 0000000..a15f337 --- /dev/null +++ b/nejdb/Ejdb.DB/EJDB.cs @@ -0,0 +1,27 @@ +// ============================================================================================ +// .NET API for EJDB database library http://ejdb.org +// Copyright (C) 2012-2013 Softmotions Ltd +// +// 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 EJDB { + + public EJDB() { + } + } +} + diff --git a/nejdb/Ejdb.Db/EJDB.cs b/nejdb/Ejdb.Db/EJDB.cs new file mode 100644 index 0000000..3aa69ab --- /dev/null +++ b/nejdb/Ejdb.Db/EJDB.cs @@ -0,0 +1,11 @@ +using System; + +namespace NEJDB.DB { + + public class EJDB { + + public EJDB() { + } + } +} + diff --git a/nejdb/Ejdb.SON/BSONIterator.cs b/nejdb/Ejdb.SON/BSONIterator.cs new file mode 100644 index 0000000..c340c43 --- /dev/null +++ b/nejdb/Ejdb.SON/BSONIterator.cs @@ -0,0 +1,79 @@ +// ============================================================================================ +// .NET API for EJDB database library http://ejdb.org +// Copyright (C) 2012-2013 Softmotions Ltd +// +// 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; +using System.IO; +using System.Collections.Generic; +using System.Collections; + +namespace Ejdb.SON { + + public class BSONIterator : IDisposable, IEnumerable, IEnumerator { + + private readonly BinaryReader _input; + private BSONType _ctype; + private int _doclen; + private bool _first = true; + + public int DocumentLength { + get { return this._doclen; } + private set { this._doclen = value; } + } + + public BSONIterator(byte[] bbuf) : this(new MemoryStream(bbuf)) { + } + + public BSONIterator(Stream input) { + this._input = new BinaryReader(input); + this._doclen = _input.ReadInt32(); + byte bv = _input.ReadByte(); + if (!Enum.IsDefined(typeof(BSONType), (object) bv)) { + throw new InvalidBSONDataException("Unknown bson type: " + bv); + } + this._ctype = (BSONType) bv; + } + + ~BSONIterator() { + Dispose(); + } + + public BSONType Current { + get { + return this._ctype; + } + } + + BSONType IEnumerator.Current { + get { + return this._ctype; + } + } + + IEnumerator IEnumerable.GetEnumerator() { + return GetEnumerator(); + } + + public IEnumerator GetEnumerator() { + return this; + } + + public void Dispose() { + if (_input != null) { + _input.Close(); + } + } + } +} + diff --git a/nejdb/Ejdb.SON/BSONMarshaller.cs b/nejdb/Ejdb.SON/BSONMarshaller.cs new file mode 100644 index 0000000..a5cf262 --- /dev/null +++ b/nejdb/Ejdb.SON/BSONMarshaller.cs @@ -0,0 +1,28 @@ +// ============================================================================================ +// .NET API for EJDB database library http://ejdb.org +// Copyright (C) 2012-2013 Softmotions Ltd +// +// 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.SON { + + + public class BSONMarshaller { + + public BSONMarshaller() { + } + } +} + diff --git a/nejdb/Ejdb.SON/BSONType.cs b/nejdb/Ejdb.SON/BSONType.cs new file mode 100644 index 0000000..f0592b5 --- /dev/null +++ b/nejdb/Ejdb.SON/BSONType.cs @@ -0,0 +1,46 @@ +// ============================================================================================ +// .NET API for EJDB database library http://ejdb.org +// Copyright (C) 2012-2013 Softmotions Ltd +// +// 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.SON { + + /** BSON types according to the bsonspec (http://bsonspec.org/) */ + + public enum BSONType : byte { + BSON_EOO = 0, + BSON_DOUBLE = 1, + BSON_STRING = 2, + BSON_OBJECT = 3, + BSON_ARRAY = 4, + BSON_BINDATA = 5, + BSON_UNDEFINED = 6, + BSON_OID = 7, + BSON_BOOL = 8, + BSON_DATE = 9, + BSON_NULL = 10, + BSON_REGEX = 11, + BSON_DBREF = 12, /**< Deprecated. */ + BSON_CODE = 13, + BSON_SYMBOL = 14, + BSON_CODEWSCOPE = 15, + BSON_INT = 16, + BSON_TIMESTAMP = 17, + BSON_LONG = 18 + } +} + diff --git a/nejdb/Ejdb.SON/InvalidBSONDataException.cs b/nejdb/Ejdb.SON/InvalidBSONDataException.cs new file mode 100644 index 0000000..d832a8e --- /dev/null +++ b/nejdb/Ejdb.SON/InvalidBSONDataException.cs @@ -0,0 +1,30 @@ +// ============================================================================================ +// .NET API for EJDB database library http://ejdb.org +// Copyright (C) 2012-2013 Softmotions Ltd +// +// 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.SON { + + /** Invalid BSON binary data. */ + + public class InvalidBSONDataException : Exception { + public InvalidBSONDataException() { + } + + public InvalidBSONDataException(string msg) : base(msg) { + } + } +} + diff --git a/nejdb/Ejdb.Tests/TestOne.cs b/nejdb/Ejdb.Tests/TestOne.cs new file mode 100644 index 0000000..2f6a625 --- /dev/null +++ b/nejdb/Ejdb.Tests/TestOne.cs @@ -0,0 +1,36 @@ +// ============================================================================================ +// .NET API for EJDB database library http://ejdb.org +// Copyright (C) 2012-2013 Softmotions Ltd +// +// 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; +using NUnit.Framework; +using Ejdb.SON; + +namespace Ejdb.Tests { + + [TestFixture()] + public class TestOne { + [Test()] + public void TestCase() { + //BSONType t; + Console.WriteLine("isdef=" + Enum.IsDefined(typeof(BSONType), (byte)1)); + } + + [Test] + public void TestCase2() { + } + } +} + diff --git a/nejdb/NEJDB.BSON/BSONMarshaller.cs b/nejdb/NEJDB.BSON/BSONMarshaller.cs new file mode 100644 index 0000000..9908ba8 --- /dev/null +++ b/nejdb/NEJDB.BSON/BSONMarshaller.cs @@ -0,0 +1,10 @@ +using System; + +namespace nejdb { + + public class BSONMarshaller { + public BSONMarshaller() { + } + } +} + diff --git a/nejdb/NEJDB.DB/EJDB.cs b/nejdb/NEJDB.DB/EJDB.cs new file mode 100644 index 0000000..8d964da --- /dev/null +++ b/nejdb/NEJDB.DB/EJDB.cs @@ -0,0 +1,10 @@ +using System; + +namespace nejdb { + + public class EJDB { + public EJDB() { + } + } +} + diff --git a/nejdb/README.md b/nejdb/README.md new file mode 100644 index 0000000..e69de29 diff --git a/nejdb/nejdb.csproj b/nejdb/nejdb.csproj new file mode 100644 index 0000000..ea04393 --- /dev/null +++ b/nejdb/nejdb.csproj @@ -0,0 +1,63 @@ + + + + Debug + AnyCPU + 10.0.0 + 2.0 + {A24C964C-771F-4359-8C93-4BFCBE451D8B} + Library + Ejdb + nejdb + EJDB .Net binding (http://ejdb.org) + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + false + + + none + true + bin\Release + prompt + 4 + false + + + + + False + mono-nunit + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/nejdb/nejdb.sln b/nejdb/nejdb.sln new file mode 100644 index 0000000..3d9f109 --- /dev/null +++ b/nejdb/nejdb.sln @@ -0,0 +1,34 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nejdb", "nejdb.csproj", "{A24C964C-771F-4359-8C93-4BFCBE451D8B}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CD348FF1-5470-450A-A708-2EFF6259355D}" + ProjectSection(SolutionItems) = preProject + README.md = README.md + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|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 + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + EndGlobalSection + GlobalSection(MonoDevelopProperties) = preSolution + StartupItem = nejdb.csproj + Policies = $0 + $0.StandardHeader = $1 + $1.Text = @============================================================================================\n .NET API for EJDB database library http://ejdb.org\n Copyright (C) 2012-2013 Softmotions Ltd \n\n This file is part of EJDB.\n EJDB is free software; you can redistribute it and/or modify it under the terms of\n the GNU Lesser General Public License as published by the Free Software Foundation; either\n version 2.1 of the License or any later version. EJDB is distributed in the hope\n that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public\n License for more details.\n You should have received a copy of the GNU Lesser General Public License along with EJDB;\n if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,\n Boston, MA 02111-1307 USA.\n============================================================================================ + $1.IncludeInNewFiles = True + $0.DotNetNamingPolicy = $2 + $2.DirectoryNamespaceAssociation = Flat + $2.ResourceNamePolicy = FileFormatDefault + EndGlobalSection +EndGlobal diff --git a/nejdb/nejdb.userprefs b/nejdb/nejdb.userprefs new file mode 100644 index 0000000..1215bde --- /dev/null +++ b/nejdb/nejdb.userprefs @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- 2.7.4