Merge branch 'fixes' into main/gingo-test
[ryzomcore.git] / ryzom / common / data_common / r2 / r2_refid.lua
blob7c3159d22a7f4b3146238fa11e5baab4795e7729
1 -- A reference id : object like a string but for reference ids
4 r2.RefIdMetatable =
6 __eq = function(op1, op2) return op1.Value == op2.Value end,
7 __le = function(op1, op2) return op1.Value <= op2.Value end,
8 __lt = function(op1, op2) return op1.Value < op2.Value end,
9 __tostring = function(op) return op.Value end
14 function r2.RefId(value)
15 assert(value ~= r2) -- in case of r2:RefId(value)
16 if value == nil then value = "" end
17 local refId = { Value = tostring(value) }
18 setmetatable(refId, r2.RefIdMetatable)
19 return refId
20 end
22 function r2.isRefId(value)
23 return type(value) == "table" and getmetatable(value) == r2.RefIdMetatable
24 end