bson_oid_t
.The bson_oid_t
structure contains the 12-byte ObjectId notation defined by the
BSON ObjectID specificiation.
ObjectId is a 12-byte BSON type, constructed using:
mongodb $ BSONObjectId :: SELF
Type of this instance, automatically specialized in every classcore :: Pointer :: address_is_null
Is the address behind this Object at NULL?core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
mongodb :: BSONObjectId :: defaultinit
core :: Pointer :: defaultinit
core :: Object :: defaultinit
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: output_class_name
Display class name on stdout (debug only).
# Wrapper for `bson_oid_t`.
#
# The `bson_oid_t` structure contains the 12-byte ObjectId notation defined by the
# [BSON ObjectID specificiation](http://docs.mongodb.org/manual/reference/object-id/).
#
# ObjectId is a 12-byte BSON type, constructed using:
# * a 4-byte value representing the seconds since the Unix epoch (in Big Endian)
# * a 3-byte machine identifier
# * a 2-byte process id (Big Endian), and
# * a 3-byte counter (Big Endian), starting with a random value.
extern class BSONObjectId `{ bson_oid_t * `}
# Generates a new `bson_oid_t`.
new `{
bson_oid_t *self = malloc(sizeof(bson_oid_t));
bson_oid_init(self, NULL);
return self;
`}
# Object id.
fun id: String import CString.to_s `{
char str[25];
bson_oid_to_string(self, str);
return CString_to_s(str);
`}
# Destroy `self`.
fun destroy `{ free(self); `}
end
lib/mongodb/native_mongodb.nit:106,1--134,3