uuid.hpp 700 B

12345678910111213141516171819202122232425262728
  1. // Copyright Takatoshi Kondo 2021
  2. //
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. #if !defined(MQTT_BROKER_UUID_HPP)
  7. #define MQTT_BROKER_UUID_HPP
  8. #include <string>
  9. #include <boost/uuid/uuid.hpp>
  10. #include <boost/uuid/uuid_generators.hpp>
  11. #include <boost/uuid/uuid_io.hpp>
  12. #include <mqtt/broker/broker_namespace.hpp>
  13. MQTT_BROKER_NS_BEGIN
  14. inline std::string create_uuid_string() {
  15. // See https://github.com/boostorg/uuid/issues/121
  16. thread_local boost::uuids::random_generator gen;
  17. return boost::uuids::to_string(gen());
  18. }
  19. MQTT_BROKER_NS_END
  20. #endif // MQTT_BROKER_UUID_HPP