summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--doc/lib.rst6
-rw-r--r--lib/pure/oids.nim93
-rw-r--r--tools/kochdocs.nim1
3 files changed, 0 insertions, 100 deletions
diff --git a/doc/lib.rst b/doc/lib.rst
index fdc188ef2..d6c296e8d 100644
--- a/doc/lib.rst
+++ b/doc/lib.rst
@@ -372,12 +372,6 @@ Multimedia support
 Miscellaneous
 -------------
 
-* `oids <oids.html>`_
-  An OID is a global ID that consists of a timestamp,
-  a unique counter and a random value. This combination should suffice to
-  produce a globally distributed unique ID. This implementation was extracted
-  from the Mongodb interface and it thus binary compatible with a Mongo OID.
-
 * `endians <endians.html>`_
   This module contains helpers that deal with different byte orders.
 
diff --git a/lib/pure/oids.nim b/lib/pure/oids.nim
deleted file mode 100644
index d6369b5f9..000000000
--- a/lib/pure/oids.nim
+++ /dev/null
@@ -1,93 +0,0 @@
-#
-#
-#            Nim's Runtime Library
-#        (c) Copyright 2013 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-## Nim OID support. An OID is a global ID that consists of a timestamp,
-## a unique counter and a random value. This combination should suffice to
-## produce a globally distributed unique ID. This implementation was extracted
-## from the Mongodb interface and it thus binary compatible with a Mongo OID.
-##
-## This implementation calls ``math.randomize()`` for the first call of
-## ``genOid``.
-
-import times, endians
-
-type
-  Oid* = object ## an OID
-    time: int32  ##
-    fuzz: int32  ##
-    count: int32 ##
-
-proc `==`*(oid1: Oid, oid2: Oid): bool =
-  ## Compare two Mongo Object IDs for equality
-  return (oid1.time == oid2.time) and (oid1.fuzz == oid2.fuzz) and (oid1.count == oid2.count)
-
-proc hexbyte*(hex: char): int =
-  case hex
-  of '0'..'9': result = (ord(hex) - ord('0'))
-  of 'a'..'f': result = (ord(hex) - ord('a') + 10)
-  of 'A'..'F': result = (ord(hex) - ord('A') + 10)
-  else: discard
-
-proc parseOid*(str: cstring): Oid =
-  ## parses an OID.
-  var bytes = cast[cstring](addr(result.time))
-  var i = 0
-  while i < 12:
-    bytes[i] = chr((hexbyte(str[2 * i]) shl 4) or hexbyte(str[2 * i + 1]))
-    inc(i)
-
-proc oidToString*(oid: Oid, str: cstring) =
-  const hex = "0123456789abcdef"
-  # work around a compiler bug:
-  var str = str
-  var o = oid
-  var bytes = cast[cstring](addr(o))
-  var i = 0
-  while i < 12:
-    let b = bytes[i].ord
-    str[2 * i] = hex[(b and 0xF0) shr 4]
-    str[2 * i + 1] = hex[b and 0xF]
-    inc(i)
-  str[24] = '\0'
-
-proc `$`*(oid: Oid): string =
-  result = newString(24)
-  oidToString(oid, result)
-
-var
-  incr: int
-  fuzz: int32
-
-proc genOid*(): Oid =
-  ## generates a new OID.
-  proc rand(): cint {.importc: "rand", header: "<stdlib.h>", nodecl.}
-  proc srand(seed: cint) {.importc: "srand", header: "<stdlib.h>", nodecl.}
-
-  var t = getTime().toUnix.int32
-
-  var i = int32(atomicInc(incr))
-
-  if fuzz == 0:
-    # racy, but fine semantically:
-    srand(t)
-    fuzz = rand()
-  bigEndian32(addr result.time, addr(t))
-  result.fuzz = fuzz
-  bigEndian32(addr result.count, addr(i))
-
-proc generatedTime*(oid: Oid): Time =
-  ## returns the generated timestamp of the OID.
-  var tmp: int32
-  var dummy = oid.time
-  bigEndian32(addr(tmp), addr(dummy))
-  result = fromUnix(tmp)
-
-when not defined(testing) and isMainModule:
-  let xo = genOid()
-  echo xo.generatedTime
diff --git a/tools/kochdocs.nim b/tools/kochdocs.nim
index 32784e752..f2b09d380 100644
--- a/tools/kochdocs.nim
+++ b/tools/kochdocs.nim
@@ -196,7 +196,6 @@ lib/pure/memfiles.nim
 lib/pure/collections/critbits.nim
 lib/core/locks.nim
 lib/core/rlocks.nim
-lib/pure/oids.nim
 lib/pure/endians.nim
 lib/pure/uri.nim
 lib/pure/nimprof.nim
cd57043b8ee31aad562'>^
d01ff8994 ^
d01ff8994 ^
22a702868 ^





d01ff8994 ^
d01ff8994 ^
22a702868 ^








258aabba6 ^



258aabba6 ^
258aabba6 ^
258aabba6 ^




22a702868 ^











258aabba6 ^


8b5aa221a ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81