]> git.donarmstrong.com Git - lilypond.git/blob - lily/lilypond-version.cc
* flower
[lilypond.git] / lily / lilypond-version.cc
1 /*
2   lilypond-version.cc -- implement Lilypond_version
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1998--2005 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9 #include "lilypond-input-version.hh"
10 #include "string-convert.hh"
11 #include "array.hh"
12
13 Lilypond_version::Lilypond_version (int major, int minor, int patch)
14 {
15   major_ = major;
16   minor_ = minor;
17   patch_ = patch;
18 }
19
20 Lilypond_version::Lilypond_version (String str)
21 {
22   Array<String> version;
23   version = String_convert::split (str, '.');
24   
25   major_ = version[0].to_int ();
26   minor_ = version[1].to_int ();
27   patch_ = 0;
28   if (version.size () >= 3)
29     patch_ = version[2].to_int ();
30
31   if (version.size () >= 4)
32     extra_patch_string_ = version[3];
33 }
34
35 String
36 Lilypond_version::to_string () const
37 {
38   return ::to_string (major_) + "." + ::to_string (minor_) + "." + ::to_string (patch_);
39 }
40
41 Lilypond_version::operator int () const
42 {
43   // ugh
44   return 100000 * major_ + 1000 * minor_ + patch_;
45 }
46