X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Futil.cc;h=61c9dac068479ca179f6d2935609e77a6e2bfc19;hb=1a1d4b22589d5832dd594a65054d9261f9f496cf;hp=f434f358e38982c1ee7f6c3afe9b830d070c81a3;hpb=ea35bff04d7a96f44ea595951bb0c0dd54c8ee52;p=dcpomatic.git diff --git a/src/lib/util.cc b/src/lib/util.cc index f434f358e..61c9dac06 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington + Copyright (C) 2012-2016 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -85,6 +85,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 @@ -622,3 +624,15 @@ 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); + } +}