constants.hpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //
  2. // Copyright (c) 2019-2023 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. #ifndef BHO_MYSQL_IMPL_INTERNAL_PROTOCOL_CONSTANTS_HPP
  8. #define BHO_MYSQL_IMPL_INTERNAL_PROTOCOL_CONSTANTS_HPP
  9. #include <cstddef>
  10. #include <cstdint>
  11. namespace bho {
  12. namespace mysql {
  13. namespace detail {
  14. constexpr std::size_t MAX_PACKET_SIZE = 0xffffff;
  15. constexpr std::size_t HEADER_SIZE = 4;
  16. // The binary collation number, used to distinguish blobs from strings
  17. constexpr std::uint16_t binary_collation = 63;
  18. // Prepared statements
  19. namespace cursor_types {
  20. constexpr std::uint8_t no_cursor = 0;
  21. constexpr std::uint8_t read_only = 1;
  22. constexpr std::uint8_t for_update = 2;
  23. constexpr std::uint8_t scrollable = 4;
  24. } // namespace cursor_types
  25. // Binary protocol (de)serialization constants
  26. namespace binc {
  27. constexpr std::size_t length_sz = 1; // length byte, for date, datetime and time
  28. constexpr std::size_t year_sz = 2;
  29. constexpr std::size_t month_sz = 1;
  30. constexpr std::size_t date_day_sz = 1;
  31. constexpr std::size_t time_days_sz = 4;
  32. constexpr std::size_t hours_sz = 1;
  33. constexpr std::size_t mins_sz = 1;
  34. constexpr std::size_t secs_sz = 1;
  35. constexpr std::size_t micros_sz = 4;
  36. constexpr std::size_t time_sign_sz = 1;
  37. constexpr std::size_t date_sz = year_sz + month_sz + date_day_sz; // does not include length
  38. constexpr std::size_t datetime_d_sz = date_sz;
  39. constexpr std::size_t datetime_dhms_sz = datetime_d_sz + hours_sz + mins_sz + secs_sz;
  40. constexpr std::size_t datetime_dhmsu_sz = datetime_dhms_sz + micros_sz;
  41. constexpr std::size_t time_dhms_sz = time_sign_sz + time_days_sz + hours_sz + mins_sz + secs_sz;
  42. constexpr std::size_t time_dhmsu_sz = time_dhms_sz + micros_sz;
  43. constexpr std::size_t time_max_days = 34; // equivalent to the 839 hours, in the broken format
  44. } // namespace binc
  45. } // namespace detail
  46. } // namespace mysql
  47. } // namespace bho
  48. #endif