summaryrefslogtreecommitdiff
path: root/bson
diff options
context:
space:
mode:
authordwight <dwight@10gen.com>2010-12-30 22:20:30 -0500
committerdwight <dwight@10gen.com>2010-12-30 22:20:45 -0500
commitd378223f7be244dff790c8f2de4d2e991dc37796 (patch)
tree4acef474912dfe83622c6fa9e264af3471ab623c /bson
parent93b06214ed3791d1ae6c87d0f7837e266c935925 (diff)
downloadmongo-d378223f7be244dff790c8f2de4d2e991dc37796.tar.gz
OID a little better for c++ client
Diffstat (limited to 'bson')
-rw-r--r--bson/bson.h2
-rw-r--r--bson/oid.h24
2 files changed, 10 insertions, 16 deletions
diff --git a/bson/bson.h b/bson/bson.h
index 082e1f7da9d..98b1f145bb3 100644
--- a/bson/bson.h
+++ b/bson/bson.h
@@ -25,7 +25,7 @@
*/
/**
- BSONObj and its helpers
+ bo and its helpers
"BSON" stands for "binary JSON" -- ie a binary way to represent objects that would be
represented in JSON (plus a few extensions useful for databases & other languages).
diff --git a/bson/oid.h b/bson/oid.h
index 1d86945f30e..e1246b9c718 100644
--- a/bson/oid.h
+++ b/bson/oid.h
@@ -57,23 +57,21 @@ namespace mongo {
unsigned char data[12];
};
public:
+ OID() { }
+ explicit OID(const string &s) { init(s); }
+
/** initialize to 'null' */
void clear() { a = 0; b = 0; }
const unsigned char *getData() const { return data; }
- bool operator==(const OID& r) const {
- return a==r.a&&b==r.b;
- }
- bool operator!=(const OID& r) const {
- return a!=r.a||b!=r.b;
- }
+ bool operator==(const OID& r) const { return a==r.a && b==r.b; }
+ bool operator!=(const OID& r) const { return a!=r.a || b!=r.b; }
+ int compare( const OID& other ) const { return memcmp( data , other.data , 12 ); }
+ bool operator<( const OID& other ) const { return compare( other ) < 0; }
/** The object ID output as 24 hex digits. */
- string str() const {
- return toHexLower(data, 12);
- }
-
+ string str() const { return toHexLower(data, 12); }
string toString() const { return str(); }
static OID gen() { OID o; o.init(); return o; }
@@ -92,11 +90,7 @@ namespace mongo {
bool isSet() const { return a || b; }
- int compare( const OID& other ) const { return memcmp( data , other.data , 12 ); }
-
- bool operator<( const OID& other ) const { return compare( other ) < 0; }
-
- /** call this after a fork */
+ /** call this after a fork to update the process id */
static void justForked();
static unsigned getMachineId();