X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Futil.cc;h=784aacf4e0232ee01555bfa6f9163c94217be7cb;hb=7a0c2256cbf94d2434ba6e7485517df0a7f894af;hp=81963e0aa5bdac0cb4f3ca31f9392d4845cd76cb;hpb=a9936a35fbae63311b1132e6283bf28db1d8c233;p=dcpomatic.git diff --git a/src/lib/util.cc b/src/lib/util.cc index 81963e0aa..784aacf4e 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -1,19 +1,20 @@ /* - Copyright (C) 2012-2015 Carl Hetherington + Copyright (C) 2012-2016 Carl Hetherington - This program is free software; you can redistribute it and/or modify + This file is part of DCP-o-matic. + + DCP-o-matic 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 2 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + DCP-o-matic 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 this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with DCP-o-matic. If not, see . */ @@ -85,6 +86,8 @@ using std::set_terminate; using boost::shared_ptr; using boost::thread; using boost::optional; +using boost::lexical_cast; +using boost::bad_lexical_cast; using dcp::Size; /** Path to our executable, required by the stacktrace stuff and filled @@ -617,3 +620,21 @@ audio_asset_filename (shared_ptr asset) { return "pcm_" + asset->id() + ".mxf"; } + +float +relaxed_string_to_float (string s) +{ + try { + boost::algorithm::replace_all (s, ",", "."); + return lexical_cast (s); + } catch (bad_lexical_cast) { + boost::algorithm::replace_all (s, ".", ","); + return lexical_cast (s); + } +} + +bool +string_not_empty (string s) +{ + return !s.empty (); +}