-
Notifications
You must be signed in to change notification settings - Fork 14
/
bson.h
41 lines (29 loc) · 904 Bytes
/
bson.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef NODE_BSON_H
#define NODE_BSON_H
#include <v8.h>
#include <node.h>
#include <node_object_wrap.h>
using namespace v8;
class ObjectID : public node::ObjectWrap {
public:
static v8::Persistent<v8::FunctionTemplate> constructor_template;
static void Initialize(Handle<Object> target);
ObjectID() : ObjectWrap() {}
~ObjectID() {}
static Handle<Value> ToString(const Arguments &args);
bson_oid_t get() { return oid; }
void str(char *);
protected:
static Handle<Value> New(const Arguments& args);
ObjectID(const char *hex) : node::ObjectWrap() {
bson_oid_from_string(&oid, hex);
}
private:
bson_oid_t oid;
};
// v8 wrappers
Handle<Value> encode(const Arguments &args);
Handle<Value> decode(const Arguments &args);
v8::Local<v8::Value> decodeObjectStr(const char *);
bson encodeObject(const v8::Local<v8::Value> element);
#endif