Compare commits

...

12 Commits

Author SHA1 Message Date
Ayaz Salikhov
0bb037286c Add string_view include to ProtocolVersion.cpp 2026-07-02 12:55:23 +01:00
Ayaz Salikhov
183284e7df Fix style 2026-07-02 12:54:52 +01:00
Ayaz Salikhov
7e8d64bc05 Update include/xrpl/beast/rfc2616.h
Co-authored-by: xrplf-ai-reviewer[bot] <266832837+xrplf-ai-reviewer[bot]@users.noreply.github.com>
2026-07-02 12:54:01 +01:00
Ayaz Salikhov
a3becc5580 Merge branch 'develop' into copilot/convert-boost-to-std-string-view 2026-07-02 12:36:41 +01:00
Mayukha Vadari
f17e15971d Merge branch 'develop' into copilot/convert-boost-to-std-string-view 2026-06-18 12:26:50 -04:00
Mayukha Vadari
651ec66aa5 Merge branch 'develop' into copilot/convert-boost-to-std-string-view 2026-05-27 16:51:30 -04:00
copilot-swe-agent[bot]
243ca1bdec Pass std::string_view by value, fix dangling reference in ServerHandler
Agent-Logs-Url: https://github.com/XRPLF/rippled/sessions/3aef40d0-f51b-484c-a5d3-43dd37d6187f

Co-authored-by: mvadari <8029314+mvadari@users.noreply.github.com>
2026-04-10 17:53:48 +00:00
Mayukha Vadari
40a5871c41 Merge branch 'develop' into copilot/convert-boost-to-std-string-view 2026-04-01 16:25:53 -04:00
copilot-swe-agent[bot]
6c64a2cc3f Remove unnecessary boost/beast/core/string.hpp includes
Co-authored-by: mvadari <8029314+mvadari@users.noreply.github.com>
2026-04-01 16:24:15 -04:00
copilot-swe-agent[bot]
c8fc57b76a Fix lambda return type inconsistency in ServerHandler
Co-authored-by: mvadari <8029314+mvadari@users.noreply.github.com>
2026-04-01 16:24:15 -04:00
copilot-swe-agent[bot]
c7627adeba Fix std::string_view constructor usage in BaseWSPeer
Co-authored-by: mvadari <8029314+mvadari@users.noreply.github.com>
2026-04-01 16:24:14 -04:00
copilot-swe-agent[bot]
25e6606056 Replace all boost::beast::string_view with std::string_view
Co-authored-by: mvadari <8029314+mvadari@users.noreply.github.com>
2026-04-01 16:24:01 -04:00
7 changed files with 26 additions and 22 deletions

View File

@@ -11,6 +11,7 @@
#include <cstddef> #include <cstddef>
#include <iterator> #include <iterator>
#include <string> #include <string>
#include <string_view>
#include <vector> #include <vector>
namespace beast::rfc2616 { namespace beast::rfc2616 {
@@ -182,7 +183,7 @@ splitCommas(FwdIt first, FwdIt last)
template <class Result = std::vector<std::string>> template <class Result = std::vector<std::string>>
Result Result
splitCommas(boost::beast::string_view const& s) splitCommas(std::string_view s)
{ {
return splitCommas(s.begin(), s.end()); return splitCommas(s.begin(), s.end());
} }

View File

@@ -1,20 +1,19 @@
#pragma once #pragma once
#include <boost/beast/core/string.hpp>
#include <functional> #include <functional>
#include <string> #include <string>
#include <string_view>
namespace json { namespace json {
class Value; class Value;
using Output = std::function<void(boost::beast::string_view const&)>; using Output = std::function<void(std::string_view)>;
inline Output inline Output
stringOutput(std::string& s) stringOutput(std::string& s)
{ {
return [&](boost::beast::string_view const& b) { s.append(b.data(), b.size()); }; return [&](std::string_view b) { s.append(b.data(), b.size()); };
} }
/** Writes a minimal representation of a Json value to an Output in O(n) time. /** Writes a minimal representation of a Json value to an Output in O(n) time.

View File

@@ -24,6 +24,7 @@
#include <iterator> #include <iterator>
#include <list> #include <list>
#include <memory> #include <memory>
#include <string_view>
#include <utility> #include <utility>
#include <vector> #include <vector>
@@ -57,8 +58,7 @@ private:
bool pingActive_ = false; bool pingActive_ = false;
boost::beast::websocket::ping_data payload_; boost::beast::websocket::ping_data payload_;
error_code ec_; error_code ec_;
std::function<void(boost::beast::websocket::frame_type, boost::beast::string_view)> std::function<void(boost::beast::websocket::frame_type, std::string_view)> controlCallback_;
controlCallback_;
public: public:
template <class Body, class Headers> template <class Body, class Headers>
@@ -146,7 +146,7 @@ protected:
onPing(error_code const& ec); onPing(error_code const& ec);
void void
onPingPong(boost::beast::websocket::frame_type kind, boost::beast::string_view payload); onPingPong(boost::beast::websocket::frame_type kind, std::string_view payload);
void void
onTimer(error_code ec); onTimer(error_code ec);
@@ -427,11 +427,11 @@ template <class Handler, class Impl>
void void
BaseWSPeer<Handler, Impl>::onPingPong( BaseWSPeer<Handler, Impl>::onPingPong(
boost::beast::websocket::frame_type kind, boost::beast::websocket::frame_type kind,
boost::beast::string_view payload) std::string_view payload)
{ {
if (kind == boost::beast::websocket::frame_type::pong) if (kind == boost::beast::websocket::frame_type::pong)
{ {
boost::beast::string_view const p(payload_.begin()); std::string_view const p(payload_.begin(), payload_.size());
if (payload == p) if (payload == p)
{ {
closeOnTimer_ = false; closeOnTimer_ = false;

View File

@@ -9,6 +9,7 @@
#include <set> // IWYU pragma: keep #include <set> // IWYU pragma: keep
#include <stack> #include <stack>
#include <string> #include <string>
#include <string_view>
#include <utility> #include <utility>
#include <vector> #include <vector>
@@ -87,14 +88,14 @@ public:
} }
void void
output(boost::beast::string_view const& bytes) output(std::string_view bytes)
{ {
markStarted(); markStarted();
output_(bytes); output_(bytes);
} }
void void
stringOutput(boost::beast::string_view const& bytes) stringOutput(std::string_view bytes)
{ {
markStarted(); markStarted();
std::size_t position = 0, writtenUntil = 0; std::size_t position = 0, writtenUntil = 0;

View File

@@ -15,6 +15,7 @@
#include <iterator> #include <iterator>
#include <optional> #include <optional>
#include <string> #include <string>
#include <string_view>
#include <vector> #include <vector>
namespace xrpl { namespace xrpl {
@@ -64,7 +65,7 @@ to_string(ProtocolVersion const& p)
} }
std::vector<ProtocolVersion> std::vector<ProtocolVersion>
parseProtocolVersions(boost::beast::string_view const& value) parseProtocolVersions(std::string_view value)
{ {
static boost::regex const kRE( static boost::regex const kRE(
"^" // start of line "^" // start of line
@@ -131,7 +132,7 @@ negotiateProtocolVersion(std::vector<ProtocolVersion> const& versions)
} }
std::optional<ProtocolVersion> std::optional<ProtocolVersion>
negotiateProtocolVersion(boost::beast::string_view const& versions) negotiateProtocolVersion(std::string_view versions)
{ {
auto const them = parseProtocolVersions(versions); auto const them = parseProtocolVersions(versions);

View File

@@ -1,10 +1,9 @@
#pragma once #pragma once
#include <boost/beast/core/string.hpp>
#include <cstdint> #include <cstdint>
#include <optional> #include <optional>
#include <string> #include <string>
#include <string_view>
#include <utility> #include <utility>
#include <vector> #include <vector>
@@ -39,7 +38,7 @@ to_string(ProtocolVersion const& p);
no duplicates and will be sorted in ascending protocol order. no duplicates and will be sorted in ascending protocol order.
*/ */
std::vector<ProtocolVersion> std::vector<ProtocolVersion>
parseProtocolVersions(boost::beast::string_view const& s); parseProtocolVersions(std::string_view s);
/** Given a list of supported protocol versions, choose the one we prefer. */ /** Given a list of supported protocol versions, choose the one we prefer. */
std::optional<ProtocolVersion> std::optional<ProtocolVersion>
@@ -47,7 +46,7 @@ negotiateProtocolVersion(std::vector<ProtocolVersion> const& versions);
/** Given a list of supported protocol versions, choose the one we prefer. */ /** Given a list of supported protocol versions, choose the one we prefer. */
std::optional<ProtocolVersion> std::optional<ProtocolVersion>
negotiateProtocolVersion(boost::beast::string_view const& versions); negotiateProtocolVersion(std::string_view versions);
/** The list of all the protocol versions we support. */ /** The list of all the protocol versions we support. */
std::string const& std::string const&

View File

@@ -264,7 +264,7 @@ ServerHandler::onHandoff(
static inline json::Output static inline json::Output
makeOutput(Session& session) makeOutput(Session& session)
{ {
return [&](boost::beast::string_view const& b) { session.write(b.data(), b.size()); }; return [&](std::string_view b) { session.write(b.data(), b.size()); };
} }
static std::map<std::string, std::string> static std::map<std::string, std::string>
@@ -564,11 +564,14 @@ ServerHandler::processSession(
makeOutput(*session), makeOutput(*session),
coro, coro,
forwardedFor(session->request()), forwardedFor(session->request()),
[&] { [&]() -> std::string_view {
auto const iter = session->request().find("X-User"); auto const iter = session->request().find("X-User");
if (iter != session->request().end()) if (iter != session->request().end())
return iter->value(); {
return boost::beast::string_view{}; auto const& val = iter->value();
return std::string_view(val.data(), val.size());
}
return std::string_view{};
}()); }());
if (beast::rfc2616::isKeepAlive(session->request())) if (beast::rfc2616::isKeepAlive(session->request()))