GuidUtil.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. // Description : Utility functions to work with GUIDs.
  9. #ifndef CRYINCLUDE_EDITOR_UTIL_GUIDUTIL_H
  10. #define CRYINCLUDE_EDITOR_UTIL_GUIDUTIL_H
  11. #pragma once
  12. #include <AzCore/Math/Guid.h>
  13. #ifndef _REFGUID_DEFINED
  14. #define _REFGUID_DEFINED
  15. typedef const GUID& REFGUID;
  16. #endif
  17. struct GuidUtil
  18. {
  19. //! Convert GUID to string in the valid format.
  20. //! The valid format for a GUID is {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} where X is a hex digit.
  21. static const char* ToString(REFGUID guid);
  22. //! Convert from guid string in valid format to GUID class.
  23. static GUID FromString(const char* guidString);
  24. };
  25. /** Used to compare GUID keys.
  26. */
  27. struct guid_less_predicate
  28. {
  29. bool operator()(REFGUID guid1, REFGUID guid2) const
  30. {
  31. return memcmp(&guid1, &guid2, sizeof(GUID)) < 0;
  32. }
  33. };
  34. #endif // CRYINCLUDE_EDITOR_UTIL_GUIDUTIL_H