guid.h 909 B

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef WASABI2_FOUNDATION_GUID_H
  2. #define WASABI2_FOUNDATION_GUID_H
  3. #pragma once
  4. #include "types.h"
  5. #if !defined(_WIN32)
  6. #ifdef __cplusplus
  7. #if !defined(GUID_EQUALS_DEFINED) || !defined(_SYS_GUID_OPERATOR_EQ_)
  8. #define GUID_EQUALS_DEFINED
  9. #include <memory.h>
  10. #include <string.h>
  11. static __inline int operator ==(const GUID &a, const GUID &b) {
  12. return !memcmp(&a, &b, sizeof(GUID));
  13. }
  14. static __inline int operator !=(const GUID &a, const GUID &b) {
  15. return !!memcmp(&a, &b, sizeof(GUID));
  16. }
  17. #endif //GUID_EQUALS_DEFINED
  18. #endif //__cplusplus
  19. #else
  20. #include <guiddef.h>
  21. #endif
  22. #ifdef __cplusplus
  23. static __inline int operator <(const GUID &a, const GUID &b) {
  24. return memcmp(&a, &b, sizeof(GUID)) < 0;
  25. }
  26. #endif
  27. static const GUID INVALID_GUID = { 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0} };
  28. static const GUID GENERIC_GUID = { 0xFFFFFFFF, 0xFFFF, 0xFFFF, {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF} };
  29. #endif