mirror of https://github.com/Icinga/icinga2.git
Provide a conversion function from icinga::String to boost::string_view
Boost.Beast changed the signature of boost::beast::http::basic_fields::set in version 1.74 so that no longer allows passing an icinga::String instance as value. This adds a conversion function so that it works again.
This commit is contained in:
parent
339b37a985
commit
eab07a7318
|
@ -127,6 +127,18 @@ String::operator const std::string&() const
|
||||||
return m_Data;
|
return m_Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Conversion function to boost::string_view.
|
||||||
|
*
|
||||||
|
* This allows using String as the value for HTTP headers in boost::beast::http::basic_fields::set.
|
||||||
|
*
|
||||||
|
* @return A boost::string_view representing this string.
|
||||||
|
*/
|
||||||
|
String::operator boost::string_view() const
|
||||||
|
{
|
||||||
|
return boost::string_view(m_Data);
|
||||||
|
}
|
||||||
|
|
||||||
const char *String::CStr() const
|
const char *String::CStr() const
|
||||||
{
|
{
|
||||||
return m_Data.c_str();
|
return m_Data.c_str();
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "base/i2-base.hpp"
|
#include "base/i2-base.hpp"
|
||||||
#include "base/object.hpp"
|
#include "base/object.hpp"
|
||||||
#include <boost/range/iterator.hpp>
|
#include <boost/range/iterator.hpp>
|
||||||
|
#include <boost/utility/string_view.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
|
|
||||||
|
@ -71,6 +72,7 @@ public:
|
||||||
bool operator<(const String& rhs) const;
|
bool operator<(const String& rhs) const;
|
||||||
|
|
||||||
operator const std::string&() const;
|
operator const std::string&() const;
|
||||||
|
operator boost::string_view() const;
|
||||||
|
|
||||||
const char *CStr() const;
|
const char *CStr() const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue