I want to generate guids to insert into a SQLite database (i.e. no support from the db itself). However, I would like to have control over certain properties:
You can either use or look at the code of Boost.Uuid :
http://www.boost.org/doc/libs/1_47_0/libs/uuid/index.html
It is a C++ library, but still, you can find inside how the code author retrieved the Uuid on multiple systems. Last time I checked (january 2010), I found at least the following implementations for Windows and Linux/Solaris (this info could be outdated):
Open a file to /dev/urandom
and read enough bytes (16) to make up a GUID/UUID.
Use the following WinAPI functions
The Wikipedia page on GUID/UUID has a list of alternative implementations you could use/study:
https://en.wikipedia.org/wiki/UUID#Implementations
There is a GUID/UUID type which is always random (the version 4), meaning that to be compatible with other GUID/UUID semantics, you should respect that.
Now, you want the GUID/UUID to be ordered in time. The only way to do that without weakening the GUID/UUID randomness would be to prefix the 16-byte GUID/UUID with an unsigned integer (which would make your identifier data 20-bytes, or more, depending on your integer). Just generate a GUID/UUID, and increase the integer.