本文整理汇总了C++中error_code::category方法的典型用法代码示例。如果您正苦于以下问题:C++ error_code::category方法的具体用法?C++ error_code::category怎么用?C++ error_code::category使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类error_code
的用法示例。
在下文中一共展示了error_code::category方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get
boost::optional<std::pair<const_buffers_type, bool>>
get(error_code& ec)
{
ec.assign(0, ec.category());
return {{const_buffers_type{
body_.data(), body_.size()}, false}};
}
示例2: put
std::size_t
put(ConstBufferSequence const& buffers,
error_code& ec)
{
using boost::asio::buffer_copy;
using boost::asio::buffer_size;
auto const n = buffer_size(buffers);
if(body_.size() > body_.max_size() - n)
{
ec = error::buffer_overflow;
return 0;
}
boost::optional<typename
DynamicBuffer::mutable_buffers_type> b;
try
{
b.emplace(body_.prepare((std::min)(n,
body_.max_size() - body_.size())));
}
catch(std::length_error const&)
{
ec = error::buffer_overflow;
return 0;
}
ec.assign(0, ec.category());
auto const bytes_transferred =
buffer_copy(*b, buffers);
body_.commit(bytes_transferred);
return bytes_transferred;
}
示例3: equivalent
bool
equivalent (error_code const& code, int condition
) const noexcept override
{
return *this == code.category() &&
code.value() == condition;
}
示例4: on_error
void on_error(error_code const& code)
{
if (code)
{
if // usually, by on_receive
((code.category() == error::misc_category && code.value () == error::eof) ||
// and these - by on_send
(code.category() == error::system_category && code.value () == error::connection_reset) ||
(code.category() == error::system_category && code.value () == error::broken_pipe ))
{
on_discon_(code);
}
else
on_error_(code);
}
}
示例5: init
void
init(boost::optional<
std::uint64_t> const& length, error_code& ec)
{
if(length && *length > body_.size())
{
ec = error::buffer_overflow;
return;
}
ec.assign(0, ec.category());
}
示例6: response_error
void HttpProxy::response_error(
error_code const & ec,
response_type const & resp)
{
HttpResponseHead & head = response_.head();
error_code ec1;
if (ec.category() == http_error::get_category()) {
ec1 = ec;
} else if (ec.category() == boost::asio::error::get_system_category()
|| ec.category() == boost::asio::error::get_netdb_category()
|| ec.category() == boost::asio::error::get_addrinfo_category()
|| ec.category() == boost::asio::error::get_misc_category()) {
ec1 = http_error::service_unavailable;
} else {
ec1 = http_error::internal_server_error;
}
head.err_code = ec1.value();
head.err_msg = ec1.message();
if (!head.content_length.is_initialized())
head.content_length.reset(0);
response_.head().connection = http_field::Connection::close;
async_write(response_.head(),
boost::bind(resp, _1, _2));
}
示例7: put
std::size_t
put(ConstBufferSequence const& buffers,
error_code& ec)
{
using boost::asio::buffer_size;
using boost::asio::buffer_copy;
auto const n = buffer_size(buffers);
auto const len = body_.size();
if(n > len)
{
ec = error::buffer_overflow;
return 0;
}
ec.assign(0, ec.category());
buffer_copy(boost::asio::buffer(
body_.data(), n), buffers);
body_ = value_type{
body_.data() + n, body_.size() - n};
return n;
}
示例8: buffer_copy
std::size_t
put(ConstBufferSequence const& buffers,
error_code& ec)
{
using boost::asio::buffer_size;
using boost::asio::buffer_copy;
auto const n = buffer_size(buffers);
auto const len = body_.size();
try
{
body_.resize(len + n);
}
catch(std::exception const&)
{
ec = error::buffer_overflow;
return 0;
}
ec.assign(0, ec.category());
return buffer_copy(boost::asio::buffer(
&body_[0] + len, n), buffers);
}
示例9: while
void
read_and_print_body(
std::ostream& os,
SyncReadStream& stream,
DynamicBuffer& buffer,
error_code& ec)
{
parser<isRequest, buffer_body> p;
read_header(stream, buffer, p, ec);
if(ec)
return;
while(! p.is_done())
{
char buf[512];
p.get().body.data = buf;
p.get().body.size = sizeof(buf);
read(stream, buffer, p, ec);
if(ec == error::need_buffer)
ec.assign(0, ec.category());
if(ec)
return;
os.write(buf, sizeof(buf) - p.get().body.size);
}
}
示例10: init
void
init(boost::optional<
std::uint64_t> const& length, error_code& ec)
{
if(length)
{
if(static_cast<std::size_t>(*length) != *length)
{
ec = error::buffer_overflow;
return;
}
try
{
body_.reserve(
static_cast<std::size_t>(*length));
}
catch(std::exception const&)
{
ec = error::buffer_overflow;
return;
}
}
ec.assign(0, ec.category());
}
示例11: translateLibTorrentError
QString StaticHelpers::translateLibTorrentError(error_code const& ec)
{
#if LIBTORRENT_VERSION_NUM >= 10000
if (ec.category() == get_libtorrent_category())
{
return translateSessionError(ec);
}
if (ec.category() == get_bdecode_category())
{
return translateBEncodeError(ec);
}
if (ec.category() == get_gzip_category())
{
return translateGzipError(ec);
}
if (ec.category() == get_i2p_category())
{
return translateI2PError(ec);
}
if (ec.category() == get_socks_category())
{
return translateSocksError(ec);
}
if (ec.category() == get_upnp_category())
{
return translateUpnpError(ec);
}
#endif
return QString::fromLocal8Bit(ec.message().c_str());
}
示例12: result_type
std::vector<lcos::future<T> >
wait_all(lcos::future<T> f0 , lcos::future<T> f1 , lcos::future<T> f2,
error_code& ec = throws)
{
typedef std::vector<lcos::future<T> > result_type;
lcos::future<result_type> f = when_all(
f0 , f1 , f2);
if (!f.valid()) {
{ if (&ec == &hpx::throws) { HPX_THROW_EXCEPTION( uninitialized_value, "lcos::wait_all", "lcos::when_all didn't return a valid future"); } else { ec = make_error_code(static_cast<hpx::error>( uninitialized_value), "lcos::when_all didn't return a valid future", "lcos::wait_all", "D:/Devel\\hpx\\hpx\\lcos\\wait_all.hpp", 435, (ec.category() == hpx::get_lightweight_hpx_category()) ? hpx::lightweight : hpx::plain); } };
return result_type();
}
return f.get(ec);
}
示例13: operator
void operator()(error_code& ec, ConstBufferSequence const& buffer) const
{
ec.assign(0, ec.category());
std::cout << buffers(buffer);
sr.consume(boost::asio::buffer_size(buffer));
}
示例14:
inline std::size_t hash_value( const error_code & ec )
{
return static_cast<std::size_t>(ec.value())
+ reinterpret_cast<std::size_t>(&ec.category());
}
示例15: equivalent
inline bool error_category::equivalent( const error_code & code,
int condition ) const
{
return *this == code.category() && code.value() == condition;
}