2014-01-30 04:28:07 +01:00
|
|
|
#ifndef UTIL_H
|
|
|
|
#define UTIL_H
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
2014-12-22 21:20:39 -05:00
|
|
|
#include <iostream>
|
2014-10-31 14:17:52 -04:00
|
|
|
#include <boost/asio.hpp>
|
2016-04-27 12:08:08 -04:00
|
|
|
#include <boost/lexical_cast.hpp>
|
2014-02-01 04:09:55 +01:00
|
|
|
|
2016-06-14 11:55:44 -04:00
|
|
|
#ifdef ANDROID
|
|
|
|
namespace std
|
|
|
|
{
|
|
|
|
template <typename T>
|
|
|
|
std::string to_string(T value)
|
|
|
|
{
|
|
|
|
return boost::lexical_cast<std::string>(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-01-30 04:28:07 +01:00
|
|
|
namespace i2p
|
|
|
|
{
|
|
|
|
namespace util
|
|
|
|
{
|
2016-04-27 12:08:08 -04:00
|
|
|
/**
|
|
|
|
wrapper arround boost::lexical_cast that "never" fails
|
|
|
|
*/
|
|
|
|
template <typename T>
|
|
|
|
T lexical_cast(const std::string & str, const T fallback) {
|
|
|
|
try {
|
|
|
|
return boost::lexical_cast<T>(str);
|
|
|
|
} catch ( ... ) {
|
|
|
|
return fallback;
|
|
|
|
}
|
|
|
|
}
|
2014-10-31 14:17:52 -04:00
|
|
|
|
|
|
|
namespace net
|
|
|
|
{
|
|
|
|
int GetMTU (const boost::asio::ip::address& localAddress);
|
2016-06-29 11:06:51 -04:00
|
|
|
const boost::asio::ip::address GetInterfaceAddress(const std::string & ifname, bool ipv6=false);
|
2014-10-31 14:17:52 -04:00
|
|
|
}
|
2014-01-30 04:28:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|