5 #include <node_object_wrap.h>
11 class ObjectID : public ObjectWrap {
14 static const int32_t OBJECTID_SIZE = 24+1;
16 char oid[OBJECTID_SIZE];
21 static inline bool HasInstance(Handle<Value> val) {
22 if (!val->IsObject()) return false;
23 Local<Object> obj = val->ToObject();
24 return constructor_template->HasInstance(obj);
27 // Functions available from V8
28 static void Initialize(Handle<Object> target);
29 static Handle<Value> ToString(const Arguments &args);
30 static Handle<Value> Inspect(const Arguments &args);
31 static Handle<Value> ToHexString(const Arguments &args);
32 static Handle<Value> ToJSON(const Arguments &args);
33 static Handle<Value> CreatePk(const Arguments &args);
34 static Handle<Value> CreateFromHexString(const Arguments &args);
35 static Handle<Value> Equals(const Arguments &args);
38 static Handle<Value> IdGetter(Local<String> property, const AccessorInfo& info);
39 static void IdSetter(Local<String> property, Local<Value> value, const AccessorInfo& info);
41 // Constructor used for creating new Long objects from C++
42 static Persistent<FunctionTemplate> constructor_template;
44 char *convert_hex_oid_to_bin();
45 bool equals(ObjectID *object_id);
47 static Handle<Value> New(const Arguments &args);
49 // Generates oid's (Based on BSON C lib)
50 static char *oid_id_generator(char* buffer);
51 static char *uint32_to_char(uint32_t value, char* buffer);