Skip to content

Commit

Permalink
Missing file...
Browse files Browse the repository at this point in the history
  • Loading branch information
jgaa committed Jan 18, 2025
1 parent e0570c4 commit c906d82
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/restc-cpp/boost_compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Here I try to handle the differences between the different versions of boost::asio
* in order to make it easier to maintain support for older versions of boost.
*
* So if restc-spp is the only library that you are using that requires broken parts
* So if restc-cpp is the only library that you are using that requires broken parts
* of boost, then you should be fine.
*
* I take full credits for whatever works well here. All blame goes to ChatGPT! ;)
Expand Down
34 changes: 34 additions & 0 deletions src/boost_compitability.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

#include "restc-cpp/boost_compatibility.h"

namespace restc_cpp {
boost::asio::ip::tcp::endpoint boost_create_endpoint(const std::string& ip_address, unsigned short port) {
#if BOOST_VERSION >= 106600
// For Boost 1.66.0 and later
return {boost::asio::ip::make_address(ip_address), port};
#else
// For Boost versions earlier than 1.66.0
return {boost::asio::ip::address::from_string(ip_address), port};
#endif
}

uint32_t boost_convert_ipv4_to_uint(const std::string& ip_address) {
#if BOOST_VERSION >= 106600
// For Boost 1.66.0 and later
return boost::asio::ip::make_address_v4(ip_address).to_uint();
#else
// For Boost versions earlier than 1.66.0
return boost::asio::ip::address_v4::from_string(ip_address).to_ulong();
#endif
}

std::unique_ptr<boost_work> boost_make_work(boost_io_service& ioservice) {
#if BOOST_VERSION >= 106600
return std::make_unique<boost_work>(boost::asio::make_work_guard(ioservice));
#else
return std::make_unique<boost_work>(ioservice);
#endif
}


} // namespace restc_cpp

0 comments on commit c906d82

Please sign in to comment.