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.

41 lines
783 B

1 year ago
  1. #pragma once
  2. namespace vlc
  3. {
  4. struct VLC_LIBRARY_API Library
  5. {
  6. using LibraryHandle = void*;
  7. LibraryHandle _handle = nullptr;
  8. Library() = default;
  9. ~Library();
  10. Library(const Library&) = delete;
  11. Library& operator = (const Library&) = delete;
  12. Library(Library&& src)
  13. {
  14. std::swap(_handle, src._handle);
  15. }
  16. Library& operator = (Library&& src)
  17. {
  18. std::swap(_handle, src._handle);
  19. return *this;
  20. }
  21. explicit operator bool() const
  22. {
  23. return _handle != nullptr;
  24. }
  25. bool load(const char* name, bool auto_ext = true);
  26. void* symbol(const char* name);
  27. template<typename F> F get(const char* name)
  28. {
  29. return reinterpret_cast<F>(symbol(name));
  30. }
  31. };
  32. }