28 #include <boost/uuid/uuid_generators.hpp> 29 #include <boost/uuid/uuid_io.hpp> 30 #include <boost/functional/hash.hpp> 32 #if BOOST_VERSION >= 106700 33 #include <boost/uuid/entropy_error.hpp> 45 #if BOOST_VERSION >= 106700 46 static boost::uuids::detail::random_provider
seeder;
48 static boost::uuids::detail::seed_rng
seeder;
78 #if BOOST_VERSION >= 106700 89 std::lock_guard<std::mutex> lock(
rng_mutex );
93 #if BOOST_VERSION >= 106700 95 catch(
const boost::uuids::entropy_error& )
97 wxLogFatalError( wxT(
"A Boost UUID entropy exception was thrown in %s:%s." ),
98 __FILE__, __FUNCTION__ );
106 wxASSERT(
null == 0 );
110 KIID::KIID(
const wxString& aString ) : m_uuid(), m_cached_timestamp( 0 )
112 if( aString.length() == 8 )
117 for(
int i = 0; i < 4; ++i )
119 wxString octet = aString.substr( i * 2, 2 );
120 m_uuid.data[i + 12] = strtol( octet.data(),
nullptr, 16 );
138 #if BOOST_VERSION >= 106700 145 #if BOOST_VERSION >= 106700 147 catch(
const boost::uuids::entropy_error& )
149 wxLogFatalError( wxT(
"A Boost UUID entropy exception was thrown in %s:%s." ),
150 __FILE__, __FUNCTION__ );
162 if( aCandidate.Length() != niluuidStr.Length() )
165 for( wxChar c : aCandidate )
167 if( c >=
'0' && c <=
'9' )
170 if( c >=
'a' && c <=
'f' )
173 if( c >=
'A' && c <=
'F' )
195 for(
int i = 0; i < 4; ++i )
197 wxString octet = str.substr( i * 2, 2 );
198 m_uuid.data[i + 12] = strtol( octet.data(),
nullptr, 16 );
222 for(
int i = 0; i < 4; ++i )
238 return boost::uuids::to_string(
m_uuid );
263 for(
int i = 15; i >= 0; --i )
287 for(
const wxString& pathStep : wxSplit( aString,
'/' ) )
289 if( !pathStep.empty() )
290 emplace_back(
KIID( pathStep ) );
300 if( aPath.size() >
copy.size() )
303 for(
size_t i = 0; i < aPath.size(); ++i )
305 if(
copy.at( i ).AsString() != aPath.at( i ).
AsString() )
309 for(
size_t i = aPath.size(); i <
copy.size(); ++i )
310 push_back(
copy.at( i ) );
320 for(
const KIID& pathStep : *
this )
wxString AsString() const
boost::uuids::uuid m_uuid
static boost::uuids::detail::seed_rng seeder
static boost::uuids::basic_random_generator< boost::mt19937 > randomGenerator(rng)
static void SeedGenerator(unsigned int aSeed)
Re-initialize the UUID generator with a given seed (for testing or QA purposes)
static void hash_combine(std::size_t &seed)
This is a dummy function to take the final case of hash_combine below.
bool IsLegacyTimestamp() const
timestamp_t m_cached_timestamp
static boost::uuids::nil_generator nilGenerator
bool MakeRelativeTo(const KIID_PATH &aPath)
timestamp_t AsLegacyTimestamp() const
static bool g_createNilUuids
static bool SniffTest(const wxString &aCandidate)
Returns true if a string has the correct formatting to be a KIID.
void ConvertTimestampToUuid()
Change an existing time stamp based UUID into a true UUID.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
static std::mutex rng_mutex
uint32_t timestamp_t
timestamp_t is our type to represent unique IDs for all kinds of elements; historically simply the ti...
void Clone(const KIID &aUUID)
void Increment()
Generates a deterministic replacement for a given ID.
wxString AsLegacyTimestampString() const
static void CreateNilUuids(bool aNil=true)
A performance optimization which disables/enables the generation of pseudo-random UUIDs.
wxString AsString() const
static boost::mt19937 rng(seeder)
static boost::uuids::string_generator stringGenerator