The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
3.8KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-11 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #ifndef __JUCE_UUID_JUCEHEADER__
  19. #define __JUCE_UUID_JUCEHEADER__
  20. #include "../text/juce_String.h"
  21. //==============================================================================
  22. /**
  23. A universally unique 128-bit identifier.
  24. This class generates very random unique numbers based on the system time
  25. and MAC addresses if any are available. It's extremely unlikely that two identical
  26. UUIDs would ever be created by chance.
  27. The class includes methods for saving the ID as a string or as raw binary data.
  28. */
  29. class JUCE_API Uuid
  30. {
  31. public:
  32. //==============================================================================
  33. /** Creates a new unique ID. */
  34. Uuid();
  35. /** Destructor. */
  36. ~Uuid() noexcept;
  37. /** Creates a copy of another UUID. */
  38. Uuid (const Uuid& other) noexcept;
  39. /** Copies another UUID. */
  40. Uuid& operator= (const Uuid& other) noexcept;
  41. //==============================================================================
  42. /** Returns true if the ID is zero. */
  43. bool isNull() const noexcept;
  44. bool operator== (const Uuid& other) const noexcept;
  45. bool operator!= (const Uuid& other) const noexcept;
  46. //==============================================================================
  47. /** Returns a stringified version of this UUID.
  48. A Uuid object can later be reconstructed from this string using operator= or
  49. the constructor that takes a string parameter.
  50. @returns a 32 character hex string.
  51. */
  52. String toString() const;
  53. /** Creates an ID from an encoded string version.
  54. @see toString
  55. */
  56. Uuid (const String& uuidString);
  57. /** Copies from a stringified UUID.
  58. The string passed in should be one that was created with the toString() method.
  59. */
  60. Uuid& operator= (const String& uuidString);
  61. //==============================================================================
  62. /** Returns a pointer to the internal binary representation of the ID.
  63. This is an array of 16 bytes. To reconstruct a Uuid from its data, use
  64. the constructor or operator= method that takes an array of uint8s.
  65. */
  66. const uint8* getRawData() const noexcept { return uuid; }
  67. /** Creates a UUID from a 16-byte array.
  68. @see getRawData
  69. */
  70. Uuid (const uint8* rawData);
  71. /** Sets this UUID from 16-bytes of raw data. */
  72. Uuid& operator= (const uint8* rawData) noexcept;
  73. private:
  74. //==============================================================================
  75. uint8 uuid[16];
  76. JUCE_LEAK_DETECTOR (Uuid);
  77. };
  78. #endif // __JUCE_UUID_JUCEHEADER__