Factor out UUID handling into new uuid class
We now use our portable code for handling UUIDs on all platforms, and
only use platform-specific code for generating a new UUID.
This fixes a bug with converting UUIDs to and from string representation
on FreeBSD, OpenBSD and AIX which resulted in reversed byte order in the
first three components, so the same database would report a different
UUID on these platforms compared to other platforms. With this fix, the
UUIDs of existing databases will appear to change on these platforms
(except in rare "palindronic" cases). Reported by Germán M. Bravo.
(cherry picked from commit
0c9481b22dd4f3d13724d98c2f2959122d441975)