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