2 * Copyright 2013 Sveriges Television AB http://casparcg.com/
4 * This file is part of CasparCG (www.casparcg.com).
6 * CasparCG 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 * CasparCG 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 CasparCG. If not, see <http://www.gnu.org/licenses/>.
19 * Author: Helge Norberg, helge.norberg@svt.se
27 #include <boost/array.hpp>
28 #include <boost/algorithm/string/split.hpp>
33 class software_version
35 boost::array<int, NUM> numbers_;
38 software_version(std::string version)
39 : version_(std::move(version))
41 std::fill(numbers_.begin(), numbers_.end(), 0);
42 std::vector<std::string> tokens;
43 boost::split(tokens, version_, boost::is_any_of("."));
44 auto num = std::min(NUM, tokens.size());
46 for (size_t i = 0; i < num; ++i)
50 numbers_[i] = boost::lexical_cast<int>(tokens[i]);
52 catch (const boost::bad_lexical_cast&)
59 const std::string& to_string() const
64 bool operator<(const software_version<NUM>& other) const
66 for (int i = 0; i < NUM; ++i)
68 int this_num = numbers_[i];
69 int other_num = other.numbers_[i];
71 if (this_num < other_num)
73 else if (this_num > other_num)