Audio plugin host https://kx.studio/carla
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.

zyn-version.h 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. version.h - declaration of version_type class
  4. contains the current zynaddsubfx version
  5. Copyright (C) 2016 Johannes Lorenz
  6. Author: Johannes Lorenz
  7. This program is free software; you can redistribute it and/or
  8. modify it under the terms of the GNU General Public License
  9. as published by the Free Software Foundation; either version 2
  10. of the License, or (at your option) any later version.
  11. */
  12. #ifndef VERSION_H
  13. #define VERSION_H
  14. #include <iosfwd>
  15. namespace zyncarla {
  16. //! class containing a zynaddsubfx version
  17. class version_type
  18. {
  19. char version[3];
  20. // strcmp-like comparison against another version_type
  21. constexpr int v_strcmp(const version_type& v2, int i) const
  22. {
  23. return (i == sizeof(version))
  24. ? 0
  25. : ((version[i] == v2.version[i])
  26. ? v_strcmp(v2, i+1)
  27. : (version[i] - v2.version[i]));
  28. }
  29. public:
  30. constexpr version_type(char maj, char min, char rev) :
  31. version{maj, min, rev}
  32. {
  33. }
  34. //! constructs the current zynaddsubfx version
  35. constexpr version_type() :
  36. version_type(3,
  37. 0,
  38. 2)
  39. {
  40. }
  41. void set_major(int maj) { version[0] = maj; }
  42. void set_minor(int min) { version[1] = min; }
  43. void set_revision(int rev) { version[2] = rev; }
  44. int get_major() const { return version[0]; }
  45. int get_minor() const { return version[1]; }
  46. int get_revision() const { return version[2]; }
  47. constexpr bool operator<(const version_type& other) const
  48. {
  49. return v_strcmp(other, 0) < 0;
  50. }
  51. //! prints version as <major>.<minor>.<revision>
  52. friend std::ostream& operator<< (std::ostream& os,
  53. const version_type& v);
  54. };
  55. //! the current zynaddsubfx version
  56. constexpr version_type version;
  57. }
  58. #endif