Common.hpp 908 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* Copyright (C) Teemu Suutari */
  2. #ifndef COMMON_HPP
  3. #define COMMON_HPP
  4. #include <cstdint>
  5. #include <string>
  6. #include <vector>
  7. namespace ancient::internal
  8. {
  9. constexpr uint16_t MultiChar2(const char (&cc)[3]) noexcept
  10. {
  11. return static_cast<uint16_t>((static_cast<uint8_t>(cc[0]) << 8) | static_cast<uint8_t>(cc[1]));
  12. }
  13. constexpr uint32_t FourCC(const char (&cc)[5]) noexcept
  14. {
  15. return static_cast<uint32_t>((static_cast<uint8_t>(cc[0]) << 24) | (static_cast<uint8_t>(cc[1]) << 16) | (static_cast<uint8_t>(cc[2]) << 8) | static_cast<uint8_t>(cc[3]));
  16. }
  17. constexpr bool isValidSize(uint64_t &value) noexcept
  18. {
  19. #if INTPTR_MAX == INT32_MAX
  20. return value<0x1'0000'0000ULL;
  21. #else
  22. return true;
  23. #endif
  24. }
  25. constexpr bool isValidSize(off_t &value) noexcept
  26. {
  27. #if INTPTR_MAX == INT32_MAX
  28. return value<0x1'0000'0000ULL;
  29. #else
  30. return true;
  31. #endif
  32. }
  33. uint32_t rotateBits(uint32_t value,uint32_t count);
  34. }
  35. #endif