X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Flilypond-version.cc;h=fd76deec67e1ea33654c1a44db35381fed1d9d6a;hb=058370efc7e9710f149d0f444328bb1fcd7bdec1;hp=5af0c899fdd49e152a792fa0ea3ad13a52a185b8;hpb=f7c306cacfbdf6229e9414c691e36e49b41ea71a;p=lilypond.git diff --git a/lily/lilypond-version.cc b/lily/lilypond-version.cc index 5af0c899fd..fd76deec67 100644 --- a/lily/lilypond-version.cc +++ b/lily/lilypond-version.cc @@ -1,47 +1,69 @@ /* - lilypond-version.cc -- implement Lilypond_version + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 1998--2014 Jan Nieuwenhuizen - (c) 1998--2001 Jan Nieuwenhuizen + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . */ -#include "lilypond-input-version.hh" +#include + +#include "lilypond-version.hh" #include "string-convert.hh" -#include "array.hh" +#include "misc.hh" Lilypond_version::Lilypond_version (int major, int minor, int patch) { - major_i_ = major; - minor_i_ = minor; - patch_i_ = patch; + major_ = major; + minor_ = minor; + patch_ = patch; } -Lilypond_version::Lilypond_version (String str) +Lilypond_version::Lilypond_version (const string &str) { - Array version; - version = String_convert::split_arr (str, '.'); - - major_i_ = version[0].value_i (); - minor_i_ = version[1].value_i (); - patch_i_ = 0; - if (version.size () >= 3) - patch_i_ = version[2].value_i (); + major_ = 0; + minor_ = 0; + patch_ = 0; + + vector version; + version = string_split (str, '.'); + + if (version.size () > 0 && isdigit (version[0][0])) + major_ = String_convert::dec2int (version[0]); + if (version.size () > 1 && isdigit (version[1][0])) + minor_ = String_convert::dec2int (version[1]); + + patch_ = 0; + if (version.size () >= 3 + && isdigit (version[2][0])) + patch_ = String_convert::dec2int (version[2]); if (version.size () >= 4) - extra_patch_str_ = version[3]; + extra_patch_string_ = version[3]; } -String -Lilypond_version::str () const +string +Lilypond_version::to_string () const { - return to_str (major_i_) + "." + to_str (minor_i_) + "." + to_str (patch_i_); + return ::to_string (major_) + + "." + ::to_string (minor_) + + "." + ::to_string (patch_); } Lilypond_version::operator int () const { - // ugh - return 100000 * major_i_ + 1000 * minor_i_ + patch_i_; + // ugh + return 100000 * major_ + 1000 * minor_ + patch_; }