Fix InstrumentSwitch grob definition.
[lilypond.git] / lily / lilypond-version.cc
blob9c0e938547d6d4c0381a50272e29bb60ca1acdbf
1 /*
2 lilypond-version.cc -- implement Lilypond_version
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2007 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
9 #include <ctype.h>
11 #include "lilypond-version.hh"
12 #include "string-convert.hh"
13 #include "misc.hh"
15 Lilypond_version::Lilypond_version (int major, int minor, int patch)
17 major_ = major;
18 minor_ = minor;
19 patch_ = patch;
22 Lilypond_version::Lilypond_version (string str)
24 major_ = 0;
25 minor_ = 0;
26 patch_ = 0;
28 vector<string> version;
29 version = string_split (str, '.');
31 if (version.size () > 0 && isdigit (version[0][0]))
32 major_ = String_convert::dec2int (version[0]);
33 if (version.size () > 1 && isdigit (version[1][0]))
34 minor_ = String_convert::dec2int (version[1]);
36 patch_ = 0;
37 if (version.size () >= 3
38 && isdigit (version[2][0]))
39 patch_ = String_convert::dec2int (version[2]);
41 if (version.size () >= 4)
42 extra_patch_string_ = version[3];
45 string
46 Lilypond_version::to_string () const
48 return ::to_string (major_)
49 + "." + ::to_string (minor_)
50 + "." + ::to_string (patch_);
53 Lilypond_version::operator int () const
55 // ugh
56 return 100000 * major_ + 1000 * minor_ + patch_;