28#include <boost/random/mersenne_twister.hpp> 
   29#include <boost/uuid/uuid_generators.hpp> 
   30#include <boost/uuid/uuid_io.hpp> 
   32#if BOOST_VERSION >= 106700 
   33#include <boost/uuid/entropy_error.hpp> 
   52static boost::mt19937                                       
rng;
 
   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( 
"A Boost UUID entropy exception was thrown in %s:%s.",
 
   98                         __FILE__, __FUNCTION__ );
 
 
  107    wxASSERT( null == 0 );
 
 
  114    if( !aString.empty() && aString.length() <= 8
 
  115        && std::all_of( aString.begin(), aString.end(),
 
  116                        []( 
unsigned char c )
 
  118                            return std::isxdigit( c );
 
  124        for( int i = 0; i < 4; i++ )
 
  126            int start = static_cast<int>( aString.length() ) - 8 + i * 2;
 
  129            start = std::max( 0, start );
 
  130            int len = std::max( 0, end - start );
 
  132            std::string octet = aString.substr( start, len );
 
  133            m_uuid.data[i + 12] = strtol( octet.data(), nullptr, 16 );
 
  146#if BOOST_VERSION >= 106700 
  153#if BOOST_VERSION >= 106700 
  155            catch( 
const boost::uuids::entropy_error& )
 
  157                wxLogFatalError( 
"A Boost UUID entropy exception was thrown in %s:%s.",
 
  158                                 __FILE__, __FUNCTION__ );
 
 
  173        KIID( 
std::string( aString.ToUTF8() ) )
 
 
  180    static wxString niluuidStr = 
niluuid.AsString();
 
  182    if( aCandidate.Length() != niluuidStr.Length() )
 
  185    for( wxChar c : aCandidate )
 
  187        if( c >= 
'0' && c <= 
'9' )
 
  190        if( c >= 
'a' && c <= 
'f' )
 
  193        if( c >= 
'A' && c <= 
'F' )
 
 
  208    m_uuid.data[12] = 
static_cast<uint8_t
>( aTimestamp >> 24 );
 
  209    m_uuid.data[13] = 
static_cast<uint8_t
>( aTimestamp >> 16 );
 
  210    m_uuid.data[14] = 
static_cast<uint8_t
>( aTimestamp >> 8 );
 
  211    m_uuid.data[15] = 
static_cast<uint8_t
>( aTimestamp );
 
 
  225    ret |= 
m_uuid.data[12] << 24;
 
  226    ret |= 
m_uuid.data[13] << 16;
 
  227    ret |= 
m_uuid.data[14] << 8;
 
 
  236    return boost::uuids::hash_value( 
m_uuid );
 
 
  248    return boost::uuids::to_string( 
m_uuid );
 
 
  254    return boost::uuids::to_string( 
m_uuid );
 
 
  278    for( 
int i = 15; i >= 0; --i )
 
 
  303    for( 
const wxString& pathStep : wxSplit( aString, 
'/' ) )
 
  305        if( !pathStep.empty() )
 
  306            emplace_back( 
KIID( pathStep ) );
 
 
  316    if( aPath.size() > 
copy.size() )
 
  319    for( 
size_t i = 0; i < aPath.size(); ++i )
 
  321        if( 
copy.at( i ) != aPath.at( i ) )
 
  328    for( 
size_t i = aPath.size(); i < 
copy.size(); ++i )
 
  329        push_back( 
copy.at( i ) );
 
 
  337    if( aPath.size() > size() )
 
  343    while( !copyThat.empty() )
 
  345        if( *std::prev( copyThis.end() ) != *std::prev( copyThat.end() ) )
 
 
  360    for( 
const KIID& pathStep : *
this )
 
 
  375    aKIID = 
KIID( aJson.get<std::string>() );
 
 
bool EndsWith(const KIID_PATH &aPath) const
Test if aPath from the last path towards the first path.
 
bool MakeRelativeTo(const KIID_PATH &aPath)
 
wxString AsString() const
 
static void SeedGenerator(unsigned int aSeed)
Re-initialize the UUID generator with a given seed (for testing or QA purposes)
 
wxString AsString() const
 
boost::uuids::uuid m_uuid
 
void Increment()
Generates a deterministic replacement for a given ID.
 
std::string AsStdString() const
 
wxString AsLegacyTimestampString() const
 
timestamp_t AsLegacyTimestamp() const
 
static void CreateNilUuids(bool aNil=true)
A performance optimization which disables/enables the generation of pseudo-random UUIDs.
 
static bool SniffTest(const wxString &aCandidate)
Returns true if a string has the correct formatting to be a KIID.
 
void Clone(const KIID &aUUID)
 
bool IsLegacyTimestamp() const
 
void ConvertTimestampToUuid()
Change an existing time stamp based UUID into a true UUID.
 
static boost::uuids::nil_generator nilGenerator
 
static bool g_createNilUuids
 
static std::mutex rng_mutex
 
static boost::mt19937 rng
 
void from_json(const nlohmann::json &aJson, KIID &aKIID)
 
static boost::uuids::string_generator stringGenerator
 
static boost::uuids::basic_random_generator< boost::mt19937 > randomGenerator
 
void to_json(nlohmann::json &aJson, const KIID &aKIID)
 
KICOMMON_API KIID niluuid
 
uint32_t timestamp_t
timestamp_t is our type to represent unique IDs for all kinds of elements; historically simply the ti...