#ifndef NODE_BSON_H #define NODE_BSON_H #include #include #include using namespace v8; class ObjectID : public node::ObjectWrap { public: static v8::Persistent<:functiontemplate> constructor_template; static void Initialize(Handle target); ObjectID() : ObjectWrap() {} ~ObjectID() {} static Handle ToString(const Arguments &args); bson_oid_t get() { return oid; } void str(char *); protected: static Handle New(const Arguments& args); ObjectID(const char *hex) : node::ObjectWrap() { bson_oid_from_string(&oid, hex); } private: bson_oid_t oid; }; // v8 wrappers Handle encode(const Arguments &args); Handle decode(const Arguments &args); v8::Local<:value> decodeObjectStr(const char *); bson encodeObject(const v8::Local<:value> element); #endif