|
libmongo-client
0.1.8
|
Various utility functions related to MongoDB. More...
Functions | |
| void | mongo_util_oid_init (gint32 machine_id) |
| Intitialize the static ObjectID components. More... | |
| guint8 * | mongo_util_oid_new (gint32 seq) |
| Generate a new ObjectID. More... | |
| guint8 * | mongo_util_oid_new_with_time (gint32 time, gint32 seq) |
| Generate a new ObjectID, with a predefined timestamp. More... | |
| gchar * | mongo_util_oid_as_string (const guint8 *oid) |
| Convert an ObjectID to its string representation. More... | |
| gboolean | mongo_util_parse_addr (const gchar *addr, gchar **host, gint *port) |
| Parse a HOST:IP pair. More... | |
Various utility functions related to MongoDB.
| gchar* mongo_util_oid_as_string | ( | const guint8 * | oid | ) |
Convert an ObjectID to its string representation.
Turns a binary ObjectID into a hexadecimal string.
| oid | is the binary ObjectID. |
| void mongo_util_oid_init | ( | gint32 | machine_id | ) |
Intitialize the static ObjectID components.
| machine_id | is the machine id to use, or zero to generate one automatically. |
This function needs to be called once, before any OIDs are generated. It is also a good idea to call it whenever the calling program's PID might change.
| guint8* mongo_util_oid_new | ( | gint32 | seq | ) |
Generate a new ObjectID.
Based on the current time, the pre-determined pid and machine ID and a supplied sequence number, generate a new ObjectID.
The machine id and the PID are updated whenever mongo_util_oid_init() is called.
| seq | is the sequence number to use. |
| guint8* mongo_util_oid_new_with_time | ( | gint32 | time, |
| gint32 | seq | ||
| ) |
Generate a new ObjectID, with a predefined timestamp.
Based on the suppiled time and sequence number, and the pre-determined pid and machine ID, generate a new ObjectID.
The machine id and the PID are updated whenever mongo_util_oid_init() is called.
| time | is the timestamp to use. |
| seq | is the sequence number to use. |
| gboolean mongo_util_parse_addr | ( | const gchar * | addr, |
| gchar ** | host, | ||
| gint * | port | ||
| ) |
Parse a HOST:IP pair.
Given a HOST:IP pair, split it up into a host and a port. IPv6 addresses supported, the function cuts at the last ":".
| addr | is the address to split. |
| host | is a pointer to a string where the host part will be stored. |
| port | is a pointer to an integer, where the port part will be stored. |
1.8.9.1