lilypond-1.5.9
[lilypond.git] / lily / lilypond-version.cc
blob5af0c899fdd49e152a792fa0ea3ad13a52a185b8
1 /*
2 lilypond-version.cc -- implement Lilypond_version
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2001 Jan Nieuwenhuizen <janneke@gnu.org>
8 */
10 #include "lilypond-input-version.hh"
11 #include "string-convert.hh"
12 #include "array.hh"
14 Lilypond_version::Lilypond_version (int major, int minor, int patch)
16 major_i_ = major;
17 minor_i_ = minor;
18 patch_i_ = patch;
21 Lilypond_version::Lilypond_version (String str)
23 Array<String> version;
24 version = String_convert::split_arr (str, '.');
26 major_i_ = version[0].value_i ();
27 minor_i_ = version[1].value_i ();
28 patch_i_ = 0;
29 if (version.size () >= 3)
30 patch_i_ = version[2].value_i ();
32 if (version.size () >= 4)
33 extra_patch_str_ = version[3];
36 String
37 Lilypond_version::str () const
39 return to_str (major_i_) + "." + to_str (minor_i_) + "." + to_str (patch_i_);
42 Lilypond_version::operator int () const
44 // ugh
45 return 100000 * major_i_ + 1000 * minor_i_ + patch_i_;