replaced boost::lexical_cast with c++11 functions

This commit is contained in:
badaix 2015-11-12 09:21:44 +01:00
parent 734adb8852
commit c8e58f272f
9 changed files with 10 additions and 36 deletions

View file

@ -16,7 +16,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
***/ ***/
#include <boost/lexical_cast.hpp>
#include <iostream> #include <iostream>
#include <mutex> #include <mutex>
#include "common/log.h" #include "common/log.h"
@ -59,7 +58,7 @@ void ClientConnection::socketRead(void* _to, size_t _bytes)
void ClientConnection::start() void ClientConnection::start()
{ {
tcp::resolver resolver(io_service_); tcp::resolver resolver(io_service_);
tcp::resolver::query query(tcp::v4(), host_, boost::lexical_cast<string>(port_), boost::asio::ip::resolver_query_base::numeric_service); tcp::resolver::query query(tcp::v4(), host_, std::to_string(port_), boost::asio::ip::resolver_query_base::numeric_service);
auto iterator = resolver.resolve(query); auto iterator = resolver.resolve(query);
logO << "Connecting\n"; logO << "Connecting\n";
socket_.reset(new tcp::socket(io_service_)); socket_.reset(new tcp::socket(io_service_));

View file

@ -18,7 +18,6 @@
#include <iostream> #include <iostream>
#include <sys/resource.h> #include <sys/resource.h>
#include <boost/lexical_cast.hpp>
#include <boost/program_options.hpp> #include <boost/program_options.hpp>
#include "common/daemon.h" #include "common/daemon.h"
@ -41,7 +40,7 @@ PcmDevice getPcmDevice(const std::string& soundcard)
try try
{ {
soundcardIdx = boost::lexical_cast<int>(soundcard); soundcardIdx = std::stoi(soundcard);
for (auto dev: pcmDevices) for (auto dev: pcmDevices)
if (dev.idx == soundcardIdx) if (dev.idx == soundcardIdx)
return dev; return dev;

View file

@ -24,6 +24,7 @@
#include <iostream> #include <iostream>
#include <cstring> #include <cstring>
#include <sstream> #include <sstream>
#include <boost/lexical_cast.hpp>
#define logD std::clog << kDbg #define logD std::clog << kDbg
#define logO std::clog << kOut #define logO std::clog << kOut

View file

@ -18,7 +18,6 @@
#include <vector> #include <vector>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
#include <iostream> #include <iostream>
#include "sampleFormat.h" #include "sampleFormat.h"
@ -62,9 +61,9 @@ void SampleFormat::setFormat(const std::string& format)
boost::split(strs, format, boost::is_any_of(":")); boost::split(strs, format, boost::is_any_of(":"));
if (strs.size() == 3) if (strs.size() == 3)
setFormat( setFormat(
boost::lexical_cast<uint32_t>(strs[0]), std::stoul(strs[0]),
boost::lexical_cast<uint16_t>(strs[1]), std::stoul(strs[1]),
boost::lexical_cast<uint16_t>(strs[2])); std::stoul(strs[2]));
} }

View file

@ -16,7 +16,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
***/ ***/
#include <boost/lexical_cast.hpp>
#include <iostream> #include <iostream>
#include <mutex> #include <mutex>
#include "controlSession.h" #include "controlSession.h"

View file

@ -16,7 +16,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
***/ ***/
#include <boost/lexical_cast.hpp>
#include <iostream> #include <iostream>
#include "flacEncoder.h" #include "flacEncoder.h"
@ -139,9 +138,9 @@ void FlacEncoder::initEncoder()
int quality(2); int quality(2);
try try
{ {
quality = boost::lexical_cast<int>(codecOptions_); quality = std::stoi(codecOptions_);
} }
catch(boost::bad_lexical_cast) catch(...)
{ {
throw SnapException("Invalid codec option: \"" + codecOptions_ + "\""); throw SnapException("Invalid codec option: \"" + codecOptions_ + "\"");
} }

View file

@ -16,7 +16,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
***/ ***/
#include <boost/lexical_cast.hpp>
#include <iostream> #include <iostream>
#include <cstring> #include <cstring>
@ -137,9 +136,9 @@ void OggEncoder::initEncoder()
double quality = 1.0; double quality = 1.0;
try try
{ {
quality = boost::lexical_cast<double>(qual); quality = std::stod(qual);
} }
catch(boost::bad_lexical_cast) catch(...)
{ {
throw SnapException("Invalid codec option: \"" + codecOptions_ + "\""); throw SnapException("Invalid codec option: \"" + codecOptions_ + "\"");
} }

View file

@ -21,7 +21,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <boost/lexical_cast.hpp>
#include "json.hpp" #include "json.hpp"
#include "jsonrpcException.h" #include "jsonrpcException.h"
@ -63,25 +62,6 @@ public:
return value; return value;
} }
// bool isParam(size_t idx, const std::string& param);
/* template<typename T>
T getParam(size_t idx)
{
if (idx >= params.size())
throw JsonInvalidParamsException(*this);
try
{
return boost::lexical_cast<T>(params[idx]);
}
catch(...)
{
throw JsonInvalidParamsException(*this);
}
}
bool isParam(size_t idx, const std::string& param);
*/
protected: protected:
Json json_; Json json_;

View file

@ -18,7 +18,6 @@
#include "streamSession.h" #include "streamSession.h"
#include <boost/lexical_cast.hpp>
#include <iostream> #include <iostream>
#include <mutex> #include <mutex>
#include "common/log.h" #include "common/log.h"