version_number.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. Copyright Rene Rivera 2005-2016
  3. Distributed under the Boost Software License, Version 1.0.
  4. (See accompanying file LICENSE_1_0.txt or copy at
  5. http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. #ifndef BOOST_PREDEF_VERSION_NUMBER_H
  8. #define BOOST_PREDEF_VERSION_NUMBER_H
  9. /* tag::reference[]
  10. = `BOOST_VERSION_NUMBER`
  11. [source]
  12. ----
  13. BOOST_VERSION_NUMBER(major,minor,patch)
  14. ----
  15. Defines standard version numbers, with these properties:
  16. * Decimal base whole numbers in the range [0,1000000000).
  17. The number range is designed to allow for a (2,2,5) triplet.
  18. Which fits within a 32 bit value.
  19. * The `major` number can be in the [0,99] range.
  20. * The `minor` number can be in the [0,99] range.
  21. * The `patch` number can be in the [0,99999] range.
  22. * Values can be specified in any base. As the defined value
  23. is an constant expression.
  24. * Value can be directly used in both preprocessor and compiler
  25. expressions for comparison to other similarly defined values.
  26. * The implementation enforces the individual ranges for the
  27. major, minor, and patch numbers. And values over the ranges
  28. are truncated (modulo).
  29. */ // end::reference[]
  30. #define BOOST_VERSION_NUMBER(major,minor,patch) \
  31. ( (((major)%100)*10000000) + (((minor)%100)*100000) + ((patch)%100000) )
  32. #define BOOST_VERSION_NUMBER_MAX \
  33. BOOST_VERSION_NUMBER(99,99,99999)
  34. #define BOOST_VERSION_NUMBER_ZERO \
  35. BOOST_VERSION_NUMBER(0,0,0)
  36. #define BOOST_VERSION_NUMBER_MIN \
  37. BOOST_VERSION_NUMBER(0,0,1)
  38. #define BOOST_VERSION_NUMBER_AVAILABLE \
  39. BOOST_VERSION_NUMBER_MIN
  40. #define BOOST_VERSION_NUMBER_NOT_AVAILABLE \
  41. BOOST_VERSION_NUMBER_ZERO
  42. /* tag::reference[]
  43. [source]
  44. ----
  45. BOOST_VERSION_NUMBER_MAJOR(N), BOOST_VERSION_NUMBER_MINOR(N), BOOST_VERSION_NUMBER_PATCH(N)
  46. ----
  47. The macros extract the major, minor, and patch portion from a well formed
  48. version number resulting in a preprocessor expression in the range of
  49. [0,99] or [0,99999] for the major and minor, or patch numbers
  50. respectively.
  51. */ // end::reference[]
  52. #define BOOST_VERSION_NUMBER_MAJOR(N) \
  53. ( ((N)/10000000)%100 )
  54. #define BOOST_VERSION_NUMBER_MINOR(N) \
  55. ( ((N)/100000)%100 )
  56. #define BOOST_VERSION_NUMBER_PATCH(N) \
  57. ( (N)%100000 )
  58. #endif