ResourceTraitsKeystone.hpp 740 B

123456789101112131415161718192021222324252627282930313233
  1. #pragma once
  2. #include <keystone/keystone.h>
  3. struct KeystoneHandleTraits {
  4. using HandleType = ks_engine*;
  5. static inline const HandleType InvalidValue = nullptr;
  6. [[nodiscard]]
  7. static bool IsValid(const HandleType& Handle) noexcept {
  8. return Handle != InvalidValue;
  9. }
  10. static void Releasor(const HandleType& Handle) noexcept {
  11. ks_close(Handle);
  12. }
  13. };
  14. struct KeystoneMallocTraits {
  15. using HandleType = uint8_t*;
  16. static inline const HandleType InvalidValue = nullptr;
  17. [[nodiscard]]
  18. static bool IsValid(const HandleType& Handle) noexcept {
  19. return Handle != InvalidValue;
  20. }
  21. static void Releasor(const HandleType& Handle) noexcept {
  22. ks_free(Handle);
  23. }
  24. };