Fixes Issue 1504, allowing feather beam line breaking.
[lilypond/patrick.git] / lily / lilypond-version.cc
blobe7b686a208e920ac0eda5cfe00b803c8eb6744d0
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1998--2011 Jan Nieuwenhuizen <janneke@gnu.org>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #include <ctype.h>
22 #include "lilypond-version.hh"
23 #include "string-convert.hh"
24 #include "misc.hh"
26 Lilypond_version::Lilypond_version (int major, int minor, int patch)
28 major_ = major;
29 minor_ = minor;
30 patch_ = patch;
33 Lilypond_version::Lilypond_version (string str)
35 major_ = 0;
36 minor_ = 0;
37 patch_ = 0;
39 vector<string> version;
40 version = string_split (str, '.');
42 if (version.size () > 0 && isdigit (version[0][0]))
43 major_ = String_convert::dec2int (version[0]);
44 if (version.size () > 1 && isdigit (version[1][0]))
45 minor_ = String_convert::dec2int (version[1]);
47 patch_ = 0;
48 if (version.size () >= 3
49 && isdigit (version[2][0]))
50 patch_ = String_convert::dec2int (version[2]);
52 if (version.size () >= 4)
53 extra_patch_string_ = version[3];
56 string
57 Lilypond_version::to_string () const
59 return ::to_string (major_)
60 + "." + ::to_string (minor_)
61 + "." + ::to_string (patch_);
64 Lilypond_version::operator int () const
66 // ugh
67 return 100000 * major_ + 1000 * minor_ + patch_;