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.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. //! class containing a zynaddsubfx version
  16. class version_type
  17. {
  18. char version[3];
  19. // strcmp-like comparison against another version_type
  20. constexpr int v_strcmp(const version_type& v2, int i) const
  21. {
  22. return (i == sizeof(version))
  23. ? 0
  24. : ((version[i] == v2.version[i])
  25. ? v_strcmp(v2, i+1)
  26. : (version[i] - v2.version[i]));
  27. }
  28. public:
  29. constexpr version_type(char maj, char min, char rev) :
  30. version{maj, min, rev}
  31. {
  32. }
  33. //! constructs the current zynaddsubfx version
  34. constexpr version_type() :
  35. version_type(3,
  36. 0,
  37. 1)
  38. {
  39. }
  40. void set_major(int maj) { version[0] = maj; }
  41. void set_minor(int min) { version[1] = min; }
  42. void set_revision(int rev) { version[2] = rev; }
  43. int get_major() const { return version[0]; }
  44. int get_minor() const { return version[1]; }
  45. int get_revision() const { return version[2]; }
  46. constexpr bool operator<(const version_type& other) const
  47. {
  48. return v_strcmp(other, 0) < 0;
  49. }
  50. //! prints version as <major>.<minor>.<revision>
  51. friend std::ostream& operator<< (std::ostream& os,
  52. const version_type& v);
  53. };
  54. //! the current zynaddsubfx version
  55. constexpr version_type version;
  56. #endif