bson only c++ library?

522 views
Skip to first unread message

sptrakesh

unread,
Mar 7, 2011, 2:56:59 PM3/7/11
to mongodb-user
Hello,

Is there any way to build a pure bson library from the sources? A
brief look at the bson sources does not look very promising (includes
from other sections). I would have liked to build a static c++ bson
library from use from a iOS application. I supposed, sticking with
JSON is the only option at present. Any plans on decoupling the bson
implementation from the mongodb sources?

Thanks
Rakesh

Gates

unread,
Mar 7, 2011, 5:53:52 PM3/7/11
to mongodb-user
Have you tried building the C++ drivers?
How close are they to what you need?

The C++ drivers should include BSON, but will exclude a lot of the
other core code.
Looking at the includes, a lot of them seem to be "utils". Are those
utils too dependent?

- Gates

sptrakesh

unread,
Mar 7, 2011, 7:29:21 PM3/7/11
to mongodb-user


On Mar 7, 4:53 pm, Gates <ga...@10gen.com> wrote:
> Have you tried building the C++ drivers?
> How close are they to what you need?

I do not need the client driver itself, just the ability to consume
bson data.

>
> The C++ drivers should include BSON, but will exclude a lot of the
> other core code.
> Looking at the includes, a lot of them seem to be "utils". Are those
> utils too dependent?

I have not looked too far, but just the first file in the bson
directory bson_db.h included ../util/optime.h which in turn includes
db/concurrency.h.

I shall try and pull out the sources and try building to see how far I
get.

Rakesh

Nat

unread,
Mar 7, 2011, 9:17:18 PM3/7/11
to mongodb-user
you should just need to include bson.h or jsobj.h. bson_db.h is
internal to mongodb hence the namespace is mongo instead of bson.
http://www.mongodb.org/pages/viewpage.action?pageId=16646453

sptrakesh

unread,
Mar 8, 2011, 3:08:48 PM3/8/11
to mongodb-user


On Mar 7, 8:17 pm, Nat <nat.lu...@gmail.com> wrote:
> you should just need to include bson.h or jsobj.h. bson_db.h is
> internal to mongodb hence the namespace is mongo instead of bson.http://www.mongodb.org/pages/viewpage.action?pageId=16646453

I copied over the required files and created an Xcode Cocoa Touch
Static library project, and after a bit of hacking got the sources to
compile. I need to write a unit test suite to ensure that the
compiled library works properly. Once that is done, I shall make the
library project sources available to any one who is interested.

sptrakesh

unread,
Mar 9, 2011, 4:19:36 PM3/9/11
to mongodb-user
I have uploaded a cocoa touch static library project with some simple
unit tests to http://sptci.com/uploads/mongodb/bson.zip. I have not
tested on a device yet, but the tests run on the simulator.

Rakesh

Gaetan Voyer-Perrault

unread,
Mar 9, 2011, 4:42:48 PM3/9/11
to mongod...@googlegroups.com
If you can confirm this works on the device, please let us know and we can include this link somewhere in our driver docs.


--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.


sptrakesh

unread,
Mar 10, 2011, 12:40:03 PM3/10/11
to mongodb-user


On Mar 9, 3:42 pm, Gaetan Voyer-Perrault <ga...@10gen.com> wrote:
> If you can confirm this works on the device, please let us know and we can
> include this link somewhere in our driver docs.

Yes, it does work on the device (iPhone 4 running 4.2). I have
updated the zip file to contain the simple test application as well.
I have also attempted to document the main changes we had to make to
the sources at http://sptci.com/docs/ios/bson/

Rakesh

Eliot Horowitz

unread,
Mar 10, 2011, 12:52:30 PM3/10/11
to mongod...@googlegroups.com
Have/had you considered using the c bson library instead of c++?

sptrakesh

unread,
Mar 10, 2011, 3:33:04 PM3/10/11
to mongodb-user


On Mar 10, 11:52 am, Eliot Horowitz <eliothorow...@gmail.com> wrote:
> Have/had you considered using the c bson library instead of c++?

No, the Magnolia documentation indicated a preference for the C++
library over the C library, hence the decision to stick with it. I am
also more familiar with the C++ API, since I have used it before.
There will also be some code reuse for the iOS app being built, which
again requires the C++ API.

Rakesh
Reply all
Reply to author
Forward
0 new messages