--[[----------------------------------------------------------------------------

KSIdGenerator.lua

--------------------------------------------------------------------------------

ADOBE CONFIDENTIAL
------------------
Copyright 2013 Adobe Systems Incorporated
All Rights Reserved.

NOTICE: All information contained herein is, and remain the property of
Adobe Systems Incorporated and its suppliers, if any. The intellectual and
technical concepts contained herein are proprietary to Adobe Systems
Incorporated and its suppliers and may be covered by U.S. and Foreign
Patents, patents in process, and are protected by trade secret or copyright
law.  Dissemination of this information or reproduction of this material is
strictly forbidden unless prior written permission is obtained from
Adobe Systems Incorporated.

------------------------------------------------------------------------------]]

	-- core.os
local KSIdGeneratorImp = require 'KSIdGeneratorImp'

--============================================================================--

-- @mark KSIdGenerator namespace

--[[!

\class KSIdGenerator

\brief This namespace provides functions for generating unique identifiers.

]]--


local KSIdGenerator = {}

--------------------------------------------------------------------------------
--[[!
	Generates an integer that is guaranteed to be unique within the
	current application session, regardless of the thread from which
	this function is called.
	Subsequent calls always return a larger number.

	\return (number) The new integer.
]]--

function KSIdGenerator.localCounter( )
	-- WFArguments.check( )
	-- This wrapper exists only for documentation purposes; real implementation
	-- comes from native code (see "Real implementation" below).
end

--------------------------------------------------------------------------------
--[[!
	Generates a unique user ID (UUID) using the OS-provided mechanism,
	as a formatted as a string value (not binary encoded).
	For example, "8C0E5B77-523C-40A2-92E0-2232FE91D87D"
	
	\return (string) A new UUID.
]]--

function KSIdGenerator.uuid( )
	-- WFArguments.check( )
	-- This wrapper exists only for documentation purposes; real implementation
	-- comes from native code (see "Real implementation" below).
end

--------------------------------------------------------------------------------
--[[!
	Generates a unique user ID (UUID) using the OS-provided mechanism,
	as a 32-character hexadecimal string.
	For example, "5be6d8253d75426683bcc6c7b5d09358".
	
	\return (string) A new uuid.
]]--

function KSIdGenerator.uuidInLowercaseHex( )
	-- WFArguments.check( )
	-- This wrapper exists only for documentation purposes; real implementation
	-- comes from native code (see "Real implementation" below).
end

--==============================================================================
-- @mark The Real implementation
--==============================================================================

KSIdGenerator = KSIdGeneratorImp

--------------------------------------------------------------------------------
--[[!
	Generates a unique user ID (UUID) using the OS-provided mechanism.
	The hexadecimal digits are grouped as 32 hexadecimal characters with four
	hyphens: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX

	\return (string) A new uuid.
]]--

function KSIdGenerator.uuidInLowercaseHexWithHyphens()

	local uuid = KSIdGenerator.uuidInLowercaseHex()

	local uuidWithHyphens = string.format( "%s-%s-%s-%s-%s",
		string.sub( uuid, 1, 8 ),
		string.sub( uuid, 9, 12 ),
		string.sub( uuid, 13, 16 ),
		string.sub( uuid, 17, 20 ),
		string.sub( uuid, 21, 32 ) )

	return uuidWithHyphens

end

--==============================================================================

return KSIdGenerator
