Make wrapper for boost::lexical_cast
This makes it easier to eventually get rid of boost::lexical_cast.
This commit is contained in:
parent
b5f3e543d8
commit
6fd18bd0f0
7 changed files with 19 additions and 17 deletions
|
@ -265,6 +265,11 @@ bool regex_match(const std::string& regex, const std::string& str, enum regex_ma
|
|||
*/
|
||||
int string_to_bool(const std::string& cast_to_bool);
|
||||
|
||||
template<typename T> T raw_lexical_cast(const std::string& value)
|
||||
{
|
||||
return boost::lexical_cast<T>(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Typeconvert string.
|
||||
*/
|
||||
|
@ -315,7 +320,7 @@ template<typename T> inline T parse_value(const std::string& value) throw(std::b
|
|||
}
|
||||
return val;
|
||||
}
|
||||
return boost::lexical_cast<T>(value);
|
||||
return raw_lexical_cast<T>(value);
|
||||
} catch(std::exception& e) {
|
||||
throw std::runtime_error("Can't parse value '" + value + "': " + e.what());
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include <map>
|
||||
#include <stdexcept>
|
||||
#include <ao/ao.h>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "core/settings.hpp"
|
||||
#include "core/window.hpp"
|
||||
#include "library/framebuffer.hpp"
|
||||
#include "library/string.hpp"
|
||||
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
|
@ -25,7 +26,6 @@
|
|||
#include <map>
|
||||
#include <stdexcept>
|
||||
#include <portaudio.h>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -320,7 +320,7 @@ namespace
|
|||
idx = paNoDevice;
|
||||
} else {
|
||||
try {
|
||||
idx = boost::lexical_cast<PaDeviceIndex>(dev);
|
||||
idx = raw_lexical_cast<PaDeviceIndex>(dev);
|
||||
if(idx < 0 || !Pa_GetDeviceInfo(idx))
|
||||
throw std::runtime_error("foo");
|
||||
} catch(std::exception& e) {
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
|
||||
#include <math.h>
|
||||
#include <cassert>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/event.h>
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "library/directory.hpp"
|
||||
#include "library/string.hpp"
|
||||
#include "library/zip.hpp"
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include "platform/wxwidgets/platform.hpp"
|
||||
#include "platform/wxwidgets/loadsave.hpp"
|
||||
|
@ -624,8 +623,8 @@ void wxwin_project::on_filename_change(wxCommandEvent& e)
|
|||
{
|
||||
CHECK_UI_THREAD;
|
||||
try {
|
||||
boost::lexical_cast<int64_t>(tostdstring(rtc_sec->GetValue()));
|
||||
if(boost::lexical_cast<int64_t>(tostdstring(rtc_subsec->GetValue())) < 0)
|
||||
raw_lexical_cast<int64_t>(tostdstring(rtc_sec->GetValue()));
|
||||
if(raw_lexical_cast<int64_t>(tostdstring(rtc_subsec->GetValue())) < 0)
|
||||
throw 42;
|
||||
size_t lines = authors->GetNumberOfLines();
|
||||
for(size_t i = 0; i < lines; i++) {
|
||||
|
@ -705,9 +704,9 @@ struct moviefile& wxwin_project::make_movie()
|
|||
*target = zip::readrel(sf, "");
|
||||
}
|
||||
}
|
||||
f.movie_rtc_second = f.dyn.rtc_second = boost::lexical_cast<int64_t>(tostdstring(rtc_sec->GetValue()));
|
||||
f.movie_rtc_second = f.dyn.rtc_second = raw_lexical_cast<int64_t>(tostdstring(rtc_sec->GetValue()));
|
||||
f.movie_rtc_subsecond = f.dyn.rtc_subsecond =
|
||||
boost::lexical_cast<int64_t>(tostdstring(rtc_subsec->GetValue()));
|
||||
raw_lexical_cast<int64_t>(tostdstring(rtc_subsec->GetValue()));
|
||||
if(f.movie_rtc_subsecond < 0)
|
||||
throw std::runtime_error("RTC subsecond must be positive");
|
||||
auto ctrldata = inst.rom->controllerconfig(f.settings);
|
||||
|
|
|
@ -88,15 +88,15 @@ namespace
|
|||
|
||||
try {
|
||||
bad_what = "Bad low calibration value";
|
||||
minus = boost::lexical_cast<int64_t>(tostdstring(low->GetValue()));
|
||||
minus = raw_lexical_cast<int64_t>(tostdstring(low->GetValue()));
|
||||
bad_what = "Bad middle calibration value";
|
||||
zero = boost::lexical_cast<int64_t>(tostdstring(mid->GetValue()));
|
||||
zero = raw_lexical_cast<int64_t>(tostdstring(mid->GetValue()));
|
||||
bad_what = "Bad high calibration value";
|
||||
plus = boost::lexical_cast<int32_t>(tostdstring(hi->GetValue()));
|
||||
plus = raw_lexical_cast<int32_t>(tostdstring(hi->GetValue()));
|
||||
bad_what = "Bad neutral zone width";
|
||||
neutral = boost::lexical_cast<int64_t>(tostdstring(null->GetValue()));
|
||||
neutral = raw_lexical_cast<int64_t>(tostdstring(null->GetValue()));
|
||||
bad_what = "Bad threshold (range is 0 - 1)";
|
||||
threshold = boost::lexical_cast<double>(tostdstring(thresh->GetValue()));
|
||||
threshold = raw_lexical_cast<double>(tostdstring(thresh->GetValue()));
|
||||
if(threshold <= 0 || threshold >= 1)
|
||||
throw 42;
|
||||
pressure = _pressure->GetValue();
|
||||
|
|
|
@ -217,7 +217,7 @@ namespace
|
|||
prefix = a.substr(9);
|
||||
else if(a.length() >= 9 && a.substr(0, 9) == "--length=")
|
||||
try {
|
||||
length = boost::lexical_cast<uint64_t>(a.substr(9));
|
||||
length = raw_lexical_cast<uint64_t>(a.substr(9));
|
||||
if(!length)
|
||||
throw std::runtime_error("Length out of range (1-)");
|
||||
if(overdump_mode)
|
||||
|
@ -229,7 +229,7 @@ namespace
|
|||
}
|
||||
else if(a.length() >= 18 && a.substr(0, 18) == "--overdump-length=")
|
||||
try {
|
||||
overdump_length = boost::lexical_cast<uint64_t>(a.substr(18));
|
||||
overdump_length = raw_lexical_cast<uint64_t>(a.substr(18));
|
||||
overdump_mode = true;
|
||||
if(length)
|
||||
throw std::runtime_error("--length and --overdump-length are "
|
||||
|
|
Loading…
Add table
Reference in a new issue