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


C++ error_code类代码示例

本文整理汇总了C++中error_code的典型用法代码示例。如果您正苦于以下问题:C++ error_code类的具体用法?C++ error_code怎么用?C++ error_code使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了error_code类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _Family

font_resource_factory::font_resource_factory(const ::std::string& family, 
	error_code& ec, ::std::experimental::io2d::font_slant fs, ::std::experimental::io2d::font_weight fw, const ::std::experimental::io2d::matrix_2d& fm, 
	const ::std::experimental::io2d::font_options& fo, const ::std::experimental::io2d::matrix_2d& sm) noexcept
	: _Family()
	, _Font_slant(fs)
	, _Font_weight(fw)
	, _Font_options(fo)
	, _Font_matrix(fm)
	, _Surface_matrix(sm) {
	auto font = cairo_toy_font_face_create(family.c_str(), _Font_slant_to_cairo_font_slant_t(fs), _Font_weight_to_cairo_font_weight_t(fw));
	unique_ptr<cairo_font_face_t, decltype(&cairo_font_face_destroy)> ff(font, &cairo_font_face_destroy);
	ec = _Cairo_status_t_to_std_error_code(cairo_font_face_status(font));
	if (static_cast<bool>(ec)) {
		return;
	}
	::std::string s;
	try {
		s = cairo_toy_font_face_get_family(font);
	}
	catch (const ::std::bad_alloc&) {
		ec = make_error_code(errc::not_enough_memory);
		return;
	}
	catch (const ::std::length_error&) {
		ec = make_error_code(errc::not_enough_memory);
		return;
	}
	_Family = move(s);
	ec.clear();
}
开发者ID:cristianadam,项目名称:io2d,代码行数:30,代码来源:font_resource_factory.cpp

示例2: on_piece_write

	void on_piece_write(size_t l,error_code ec)
	{
		if (write_cnt_>MAX_PIECE)
			return;
		if (!ec)
		{
			cache_impl_->read_piece("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",write_cnt_++,
				boost::bind(&disk_cache_test::on_piece_read,this,_1,_2)
				);


			std::string dummy=boost::lexical_cast<std::string>(write_cnt_);
			safe_buffer buf;
			safe_buffer_io io(&buf);
			io.write(dummy.c_str(),dummy.length()+1);

			cache_impl_->write_piece("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",1024*1024,write_cnt_,buf,
				boost::bind(&disk_cache_test::on_piece_write,this,_1,_2)
				);
		}
		else
		{
			std::cout<<"on_piece_write, ec.message="<<ec.message()<<std::endl;
		}
	}
开发者ID:guangzhuwu,项目名称:p2streaming,代码行数:25,代码来源:asfile_test.cpp

示例3: bytesToRead

size_t XMLClient::bytesToRead(const error_code& error, size_t bytes_read) {
    size_t result = bytes_read;
    _timer->cancel();

    // Connection closed cleanly by peer
    // asio errors http://www.boost.org/doc/libs/1_44_0/doc/html/boost_asio/reference/error__basic_errors.html 
    if (error == boost::asio::error::eof || boost::asio::error::connection_reset == error) {
        Disconnect();
        return 0;
    } else if (error == boost::asio::error::operation_aborted) {
        Globals::ErrorMessage(" In bytesToRead Timer expired error \n");
    } else if (error) {
        // This error stops asynchronous reads
        std::stringstream s;
        s << "unknown bytesToRead error = (" << error << ") " << error.message() << std::endl;
        Globals::ErrorMessage(s.str());
        return 0;
    }

    if (bytes_read > 0) {
        AppendBuffer(std::string(data_, data_ + bytes_read));
        if (_endtag == NonsenseTag()) {
            _endtag = FindLeadingElement(_current);
            if (_endtag.empty()) _endtag = NonsenseTag();
        }
        //BufferHandler(std::string(data_, data_+bytes_read), "</CRCLStatus>") ;
        BufferHandler(_endtag);
    }
    StartAyncRead();
    return result;
}
开发者ID:CubeSpawn-Research,项目名称:MTConnectToolbox,代码行数:31,代码来源:XmlSocketClient.cpp

示例4: error

static bool error(error_code ec, Twine path = Twine()) {
  if (ec) {
    error(ec.message(), path);
    return true;
  }
  return false;
}
开发者ID:ebraheemk,项目名称:llvm-picoblaze,代码行数:7,代码来源:llvm-nm.cpp

示例5: resolve

 ResolverIterator resolve(
     implementation_type & impl, 
     NetName const & name, 
     error_code & ec)
 {
     boost::mutex::scoped_lock lock(sync_data_->mtx);
     LOG_DEBUG("[resolve] (name = %1%)" 
         % name.to_string());
     resolve_no_block(impl, name, ec);
     if (ec == boost::asio::error::would_block) {
         while (impl->state == ResolveTask::waiting) {
             sync_data_->cond.wait(lock);
         }
         ec = impl->ec;
     }
     if (!ec) {
         LOG_DEBUG("[resolve] resolved (name = %1%, endpoints = %2%)" 
             % name.to_string() % format(impl->endpoints));
         return ResolverIterator(svc_, impl, impl->endpoints[0]);
     } else {
         LOG_WARN("[resolve] resolved (name = %1%, ec = %2%)" 
             % name.to_string() % ec.message());
         return ResolverIterator();
     }
 }
开发者ID:huangyt,项目名称:MyProjects,代码行数:25,代码来源:ResolverService.cpp

示例6: close

	void close(char const* fmt, error_code const& ec)
	{
		end_time = clock_type::now();
		char tmp[1024];
		std::snprintf(tmp, sizeof(tmp), fmt, ec.message().c_str());
		int time = int(total_milliseconds(end_time - start_time));
		if (time == 0) time = 1;
		float up = (boost::int64_t(blocks_sent) * 0x4000) / time / 1000.f;
		float down = (boost::int64_t(blocks_received) * 0x4000) / time / 1000.f;
		error_code e;

		char ep_str[200];
		address const& addr = s.local_endpoint(e).address();
#if TORRENT_USE_IPV6
		if (addr.is_v6())
			std::snprintf(ep_str, sizeof(ep_str), "[%s]:%d", addr.to_string(e).c_str()
				, s.local_endpoint(e).port());
		else
#endif
			std::snprintf(ep_str, sizeof(ep_str), "%s:%d", addr.to_string(e).c_str()
				, s.local_endpoint(e).port());
		std::printf("%s ep: %s sent: %d received: %d duration: %d ms up: %.1fMB/s down: %.1fMB/s\n"
			, tmp, ep_str, blocks_sent, blocks_received, time, up, down);
		if (seed) --num_seeds;
	}
开发者ID:Athorcis,项目名称:libtorrent,代码行数:25,代码来源:connection_tester.cpp

示例7: save

void save_settings::save(error_code& ec) const
{
	// back-up current settings file as .bak before saving the new one
	std::string backup = m_settings_file + ".bak";
	bool has_settings = exists(m_settings_file);
	bool has_backup = exists(backup);

	if (has_settings && has_backup)
		remove(backup, ec);

	if (has_settings)
		rename(m_settings_file, backup, ec);

	ec.clear();

	entry sett;
	m_ses.save_state(sett);

	for (std::map<std::string, int>::const_iterator i = m_ints.begin()
		, end(m_ints.end()); i != end; ++i)
	{
		sett[i->first] = i->second;
	}

	for (std::map<std::string, std::string>::const_iterator i = m_strings.begin()
		, end(m_strings.end()); i != end; ++i)
	{
		sett[i->first] = i->second;
	}
	std::vector<char> buf;
	bencode(std::back_inserter(buf), sett);
	save_file(m_settings_file, buf, ec);
}
开发者ID:arvidn,项目名称:libtorrent-webui,代码行数:33,代码来源:save_settings.cpp

示例8: complete_io

void disk_engine::complete_io(aio_task *aio, error_code err, uint32_t bytes, int delay_milliseconds)
{
    if (err != ERR_OK) {
        dinfo("disk operation failure with code %s, err = %s, aio_task_id = %016" PRIx64,
              aio->spec().name.c_str(),
              err.to_string(),
              aio->id());
    }

    // batching
    if (aio->code() == LPC_AIO_BATCH_WRITE) {
        aio->enqueue(err, (size_t)bytes);
        aio->release_ref(); // added in process_write
    }

    // no batching
    else {
        auto df = (disk_file *)(aio->aio()->file_object);
        if (aio->aio()->type == AIO_Read) {
            auto wk = df->on_read_completed(aio, err, (size_t)bytes);
            if (wk) {
                _provider->aio(wk);
            }
        }

        // write
        else {
            uint32_t sz;
            auto wk = df->on_write_completed(aio, (void *)&sz, err, (size_t)bytes);
            if (wk) {
                process_write(wk, sz);
            }
        }
    }
}
开发者ID:shengofsun,项目名称:rDSN,代码行数:35,代码来源:disk_engine.cpp

示例9: run_test

void run_test(std::string const& url, int size, int status, int connected
	, boost::optional<error_code> ec, proxy_settings const& ps)
{
	reset_globals();

	std::cerr << " ===== TESTING: " << url << " =====" << std::endl;

	std::cerr << " expecting: size: " << size
		<< " status: " << status
		<< " connected: " << connected
		<< " error: " << (ec?ec->message():"no error") << std::endl;

	boost::shared_ptr<http_connection> h(new http_connection(ios, cq
		, &::http_handler, true, &::http_connect_handler));
	h->get(url, seconds(1), 0, &ps);
	ios.reset();
	error_code e;
	ios.run(e);

	std::cerr << "connect_handler_called: " << connect_handler_called << std::endl;
	std::cerr << "handler_called: " << handler_called << std::endl;
	std::cerr << "status: " << http_status << std::endl;
	std::cerr << "size: " << data_size << std::endl;
	std::cerr << "error_code: " << g_error_code.message() << std::endl;
	TEST_CHECK(connect_handler_called == connected);
	TEST_CHECK(handler_called == 1);	
	TEST_CHECK(data_size == size || size == -1);
	TEST_CHECK(!ec || g_error_code == *ec);
	TEST_CHECK(http_status == status || status == -1);
}
开发者ID:SiderZhang,项目名称:p2pns3,代码行数:30,代码来源:test_http_connection.cpp

示例10: if

void daemon_s_service::on_update_configuration_on_meta_server_reply(
    ::dsn::replication::config_type::type type, std::shared_ptr<app_internal> &&  app,
    error_code err, dsn_message_t request, dsn_message_t response
)
{
    if (false == _online)
    {
        err.end_tracking();
        return;
    }

    configuration_update_response resp;
    if (err == ERR_OK)
    {
        ::dsn::unmarshall(response, resp);
        err = resp.err;
    }
    else if (err == ERR_TIMEOUT)
    {
        rpc::call(
            _fd->get_servers(),
            request,
            this,
            [=, cap_app = std::move(app)](error_code err, dsn_message_t reqmsg, dsn_message_t response) mutable
        {
            on_update_configuration_on_meta_server_reply(type, std::move(cap_app), err, reqmsg, response);
        }
        );
    }
    else
    {
        if (type == config_type::CT_ADD_SECONDARY)
            kill_app(std::move(app));
    }
}
开发者ID:glglwty,项目名称:rDSN,代码行数:35,代码来源:daemon.server.cpp

示例11: on_connected

	void on_connected(const error_code& ec)
	{
		if(ec)
		{
			std::cout<<ec.message()<<std::endl;
			return;
		}
		std::cout<<"connected ppc succeed!"<<std::endl;
		socket_->disconnected_signal().bind(&this_type::on_disconnected,this,_1);

		if(re_connect_timer_)
			re_connect_timer_->cancel();

		std::string tracker = "/p2p-live/127.0.0.1:9082/default_channel_key/default_channel_uuid.ts";
		std::string host = "127.0.0.1:9906";

		http::request req;		
		req.url(tracker);
		req.host(host);

		safe_buffer buf;
		safe_buffer_io bio(&buf);
		bio<<req;

		socket_->async_send(buf);
	}
开发者ID:guangzhuwu,项目名称:p2streaming,代码行数:26,代码来源:test_player.cpp

示例12: move_partfile

	void part_file::move_partfile(std::string const& path, error_code& ec)
	{
		std::lock_guard<std::mutex> l(m_mutex);

		flush_metadata_impl(ec);
		if (ec) return;

		m_file.close();

		if (!m_piece_map.empty())
		{
			std::string old_path = combine_path(m_path, m_name);
			std::string new_path = combine_path(path, m_name);

			rename(old_path, new_path, ec);
			if (ec == boost::system::errc::no_such_file_or_directory)
				ec.clear();

			if (ec)
			{
				copy_file(old_path, new_path, ec);
				if (ec) return;
				remove(old_path, ec);
			}
		}
		m_path = path;
	}
开发者ID:kmachin3,项目名称:libtorrent,代码行数:27,代码来源:part_file.cpp

示例13: callback

void callback(int mapping, address const& ip, int port, int protocol, error_code const& err)
{
	callback_info info = {mapping, port, err};
	callbacks.push_back(info);
	std::cerr << "mapping: " << mapping << ", port: " << port << ", IP: " << ip
		<< ", proto: " << protocol << ", error: \"" << err.message() << "\"\n";
}
开发者ID:Jackarain,项目名称:libtorrent,代码行数:7,代码来源:test_upnp.cpp

示例14: get_cur_time

boost::uint64_t TsDemuxer::get_end_time(
    error_code & ec)
{
    if (!is_open(ec)) {
        return 0;
    }
    boost::uint64_t beg = archive_.tellg();
    archive_.seekg(0, std::ios::end);
    assert(archive_);
    boost::uint64_t end = archive_.tellg();
    assert(end > TsPacket::PACKET_SIZE);
    end = (end / TsPacket::PACKET_SIZE) * TsPacket::PACKET_SIZE;
    if (parse_offset2_ + TsPacket::PACKET_SIZE * 20 < end) {
        parse_offset2_ = end - TsPacket::PACKET_SIZE * 20;
    }
    if (parse_offset2_ <= parse_offset_) {
        archive_.seekg(beg, std::ios::beg);
        return get_cur_time(ec);
    } else {
        archive_.seekg(parse_offset2_, std::ios::beg);
        assert(archive_);
        while (parse_offset2_ <= end && get_packet(pkt2_, ec)) {
            parse_offset2_ += TsPacket::PACKET_SIZE;
            archive_.seekg(parse_offset2_, std::ios::beg);
        }
        ec.clear();
        archive_.seekg(beg, std::ios::beg);
        boost::uint64_t pcr = time_pcr2_.transfer(
                                  ((boost::uint64_t)pkt2_.adaptation.program_clock_reference_base) << 1);
        pcr /= (TsPacket::TIME_SCALE / 1000);
        return pcr > timestamp_offset_ms_ ? pcr  - timestamp_offset_ms_ : 0;
    }
}
开发者ID:uvbs,项目名称:MyProjects,代码行数:33,代码来源:TsDemuxer.cpp

示例15: error

static bool error(error_code EC, Twine Path = Twine()) {
  if (EC) {
    error(EC.message(), Path);
    return true;
  }
  return false;
}
开发者ID:ADonut,项目名称:LLVM-GPGPU,代码行数:7,代码来源:llvm-nm.cpp


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