当前位置: 首页>>代码示例>>C++>>正文


C++ error_code::category方法代码示例

本文整理汇总了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}};
 }
开发者ID:gtbjj,项目名称:dotfiles,代码行数:7,代码来源:vector_body.hpp

示例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;
 }
开发者ID:osquery,项目名称:third-party,代码行数:30,代码来源:basic_dynamic_body.hpp

示例3: equivalent

 bool
 equivalent (error_code const& code, int condition
     ) const noexcept override
 {
     return *this == code.category() &&
         code.value() == condition;
 }
开发者ID:luckfan,项目名称:vpal,代码行数:7,代码来源:joyent_parser.cpp

示例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);
        }
    }
开发者ID:gvsurenderreddy,项目名称:udp2tcp_tunnel,代码行数:17,代码来源:tcp_service.cpp

示例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());
 }
开发者ID:CustomOrthopaedics,项目名称:OTS-Boost,代码行数:11,代码来源:span_body.hpp

示例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));
 }
开发者ID:huangyt,项目名称:MyProjects,代码行数:24,代码来源:HttpProxy.cpp

示例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;
 }
开发者ID:CustomOrthopaedics,项目名称:OTS-Boost,代码行数:20,代码来源:span_body.hpp

示例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);
 }
开发者ID:gtbjj,项目名称:dotfiles,代码行数:21,代码来源:vector_body.hpp

示例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);
    }
}
开发者ID:vinniefalco,项目名称:Beast,代码行数:24,代码来源:http_examples.hpp

示例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());
 }
开发者ID:gtbjj,项目名称:dotfiles,代码行数:24,代码来源:vector_body.hpp

示例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());
}
开发者ID:solonix,项目名称:CuteTorrent,代码行数:37,代码来源:StaticHelpers.cpp

示例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);
 }
开发者ID:fpelliccioni,项目名称:hpx,代码行数:13,代码来源:wait_all_5.hpp

示例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));
 }
开发者ID:LocutusOfBorg,项目名称:poedit,代码行数:6,代码来源:http_snippets.cpp

示例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());
 }
开发者ID:gijs,项目名称:hexer,代码行数:5,代码来源:error_code.hpp

示例15: equivalent

 inline bool error_category::equivalent( const error_code & code,
   int condition ) const
 {
   return *this == code.category() && code.value() == condition;
 }
开发者ID:gijs,项目名称:hexer,代码行数:5,代码来源:error_code.hpp


注:本文中的error_code::category方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。