Remove boost::lexical_cast for uuid and unused uuid function

This commit is contained in:
Lee Clagett 2018-12-17 19:05:27 -05:00
parent 6bc0c7e685
commit a5ffc2d5ad
6 changed files with 11 additions and 35 deletions

View file

@ -40,8 +40,6 @@
#include <cstdlib> #include <cstdlib>
#include <string> #include <string>
#include <type_traits> #include <type_traits>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <boost/algorithm/string/predicate.hpp> #include <boost/algorithm/string/predicate.hpp>
#include "hex.h" #include "hex.h"
@ -83,34 +81,6 @@ namespace epee
{ {
namespace string_tools namespace string_tools
{ {
//----------------------------------------------------------------------------
inline std::string get_str_from_guid_a(const boost::uuids::uuid& rid)
{
return boost::lexical_cast<std::string>(rid);
}
//----------------------------------------------------------------------------
inline bool get_guid_from_string(OUT boost::uuids::uuid& inetifer, const std::string& str_id)
{
std::string local_str_id = str_id;
if(local_str_id.size() < 36)
return false;
if('{' == *local_str_id.begin())
local_str_id.erase(0, 1);
if('}' == *(--local_str_id.end()))
local_str_id.erase(--local_str_id.end());
try
{
inetifer = boost::lexical_cast<boost::uuids::uuid>(local_str_id);
return true;
}
catch(...)
{
return false;
}
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
inline std::string buff_to_hex_nodelimer(const std::string& src) inline std::string buff_to_hex_nodelimer(const std::string& src)
{ {

View file

@ -1,7 +1,9 @@
#include "net/net_utils_base.h" #include "net/net_utils_base.h"
#include "string_tools.h"
#include <boost/uuid/uuid_io.hpp>
#include "string_tools.h"
#include "net/local_ip.h" #include "net/local_ip.h"
namespace epee { namespace net_utils namespace epee { namespace net_utils
@ -73,7 +75,7 @@ namespace epee { namespace net_utils
std::string print_connection_context(const connection_context_base& ctx) std::string print_connection_context(const connection_context_base& ctx)
{ {
std::stringstream ss; std::stringstream ss;
ss << ctx.m_remote_address.str() << " " << epee::string_tools::get_str_from_guid_a(ctx.m_connection_id) << (ctx.m_is_income ? " INC":" OUT"); ss << ctx.m_remote_address.str() << " " << ctx.m_connection_id << (ctx.m_is_income ? " INC":" OUT");
return ss.str(); return ss.str();
} }

View file

@ -31,6 +31,7 @@
#include <vector> #include <vector>
#include <unordered_map> #include <unordered_map>
#include <boost/uuid/nil_generator.hpp> #include <boost/uuid/nil_generator.hpp>
#include <boost/uuid/uuid_io.hpp>
#include "string_tools.h" #include "string_tools.h"
#include "cryptonote_protocol_defs.h" #include "cryptonote_protocol_defs.h"
#include "block_queue.h" #include "block_queue.h"

View file

@ -33,6 +33,7 @@
#include <algorithm> #include <algorithm>
#include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/thread/thread.hpp> #include <boost/thread/thread.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <atomic> #include <atomic>
@ -740,7 +741,7 @@ namespace nodetool
if(rsp.node_data.network_id != m_network_id) if(rsp.node_data.network_id != m_network_id)
{ {
LOG_WARNING_CC(context, "COMMAND_HANDSHAKE Failed, wrong network! (" << epee::string_tools::get_str_from_guid_a(rsp.node_data.network_id) << "), closing connection."); LOG_WARNING_CC(context, "COMMAND_HANDSHAKE Failed, wrong network! (" << rsp.node_data.network_id << "), closing connection.");
return; return;
} }
@ -1686,7 +1687,7 @@ namespace nodetool
if(arg.node_data.network_id != m_network_id) if(arg.node_data.network_id != m_network_id)
{ {
LOG_INFO_CC(context, "WRONG NETWORK AGENT CONNECTED! id=" << epee::string_tools::get_str_from_guid_a(arg.node_data.network_id)); LOG_INFO_CC(context, "WRONG NETWORK AGENT CONNECTED! id=" << arg.node_data.network_id);
drop_connection(context); drop_connection(context);
add_host_fail(context.m_remote_address); add_host_fail(context.m_remote_address);
return 1; return 1;
@ -1802,7 +1803,7 @@ namespace nodetool
{ {
ss << cntxt.m_remote_address.str() ss << cntxt.m_remote_address.str()
<< " \t\tpeer_id " << cntxt.peer_id << " \t\tpeer_id " << cntxt.peer_id
<< " \t\tconn_id " << epee::string_tools::get_str_from_guid_a(cntxt.m_connection_id) << (cntxt.m_is_income ? " INC":" OUT") << " \t\tconn_id " << cntxt.m_connection_id << (cntxt.m_is_income ? " INC":" OUT")
<< std::endl; << std::endl;
return true; return true;
}); });

View file

@ -29,6 +29,7 @@
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
#include <boost/uuid/uuid.hpp> #include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <boost/uuid/random_generator.hpp> #include <boost/uuid/random_generator.hpp>
#include <unordered_map> #include <unordered_map>

View file

@ -33,6 +33,7 @@
#include <atomic> #include <atomic>
#include <boost/asio/io_service.hpp> #include <boost/asio/io_service.hpp>
#include <boost/uuid/uuid_io.hpp>
#include "include_base_utils.h" #include "include_base_utils.h"
#include "string_tools.h" #include "string_tools.h"