• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ entry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: wx_entry_print

void wx_entry_print(entry e, int depth)
{
	wxString padding(wxT(""));
	switch(e.type())
	{
		case entry::int_t:
			wxLogMessage(wxT("print:")+padding.Pad(depth, '\t')+wxString::Format(_T("int: %u"), e.integer()));
			break;

		case entry::string_t:
			wxLogMessage(wxT("print:")+padding.Pad(depth, '\t')+wxString::Format(wxT("str-len: %u "), e.string().length())+wxT("str: ")+wxString(e.string().c_str(), wxConvUTF8));
			break;

		case entry::list_t:
			for (entry::list_type::const_iterator i = e.list().begin(); i != e.list().end(); ++i)
			{
				wx_entry_print(*i, depth+1);
			}
			break;

		case entry::dictionary_t:
			for (entry::dictionary_type::const_iterator i = e.dict().begin(); i != e.dict().end(); ++i)
			{
				wx_entry_print(i->first, depth+1);// write key
				wx_entry_print(i->second, depth+1);// write value
			}
			break;

		default:
			break;
	}
}
开发者ID:audiohacked,项目名称:audiohacked,代码行数:32,代码来源:wxbencode_print.cpp


示例2: start

	void dht_tracker::start(entry const& bootstrap)
	{
		std::vector<udp::endpoint> initial_nodes;

		if (bootstrap.type() == entry::dictionary_t)
		{
			try
			{
			if (entry const* nodes = bootstrap.find_key("nodes"))
				read_endpoint_list<udp::endpoint>(nodes, initial_nodes);
			} catch (std::exception&) {}
		}

		error_code ec;
		m_timer.expires_from_now(seconds(1), ec);
		m_timer.async_wait(bind(&dht_tracker::tick, self(), _1));

		m_connection_timer.expires_from_now(seconds(10), ec);
		m_connection_timer.async_wait(
			bind(&dht_tracker::connection_timeout, self(), _1));

		m_refresh_timer.expires_from_now(seconds(5), ec);
		m_refresh_timer.async_wait(bind(&dht_tracker::refresh_timeout, self(), _1));

		m_dht.bootstrap(initial_nodes, boost::bind(&dht_tracker::on_bootstrap, self()));
	}
开发者ID:svn2github,项目名称:libtorrent-rasterbar,代码行数:26,代码来源:dht_tracker.cpp


示例3: swap

void entry::swap(entry& e)
{
    bool clear_this = false;
    bool clear_that = false;

    if (m_type == undefined_t && e.m_type == undefined_t)
        return;

    if (m_type == undefined_t)
    {
        construct((data_type)e.m_type);
        clear_that = true;
    }

    if (e.m_type == undefined_t)
    {
        e.construct((data_type)m_type);
        clear_this = true;
    }

    if (m_type == e.m_type)
    {
        switch (m_type)
        {
        case int_t:
            std::swap(*reinterpret_cast<integer_type*>(data)
                      , *reinterpret_cast<integer_type*>(e.data));
            break;
        case string_t:
            std::swap(*reinterpret_cast<string_type*>(data)
                      , *reinterpret_cast<string_type*>(e.data));
            break;
        case list_t:
            std::swap(*reinterpret_cast<list_type*>(data)
                      , *reinterpret_cast<list_type*>(e.data));
            break;
        case dictionary_t:
            std::swap(*reinterpret_cast<dictionary_type*>(data)
                      , *reinterpret_cast<dictionary_type*>(e.data));
            break;
        default:
            break;
        }

        if (clear_this)
            destruct();

        if (clear_that)
            e.destruct();
    }
    else
    {
        // currently, only swapping entries of the same type or where one
        // of the entries is uninitialized is supported.
        TORRENT_ASSERT(false && "not implemented");
    }
}
开发者ID:kknet,项目名称:PopcornTV,代码行数:57,代码来源:entry.cpp


示例4: start

void dht_tracker::start(entry const& bootstrap)
{
    std::vector<udp::endpoint> initial_nodes;

    if (bootstrap.type() == entry::dictionary_t)
    {
        TORRENT_TRY {
            if (entry const* nodes = bootstrap.find_key("nodes"))
                read_endpoint_list<udp::endpoint>(nodes, initial_nodes);
        } TORRENT_CATCH(std::exception&) {}
    }
开发者ID:zebbra2014,项目名称:twister-core,代码行数:11,代码来源:dht_tracker.cpp


示例5: write_entry

 static void  write_entry(serializer & s, entry const & e) {
     s << static_cast<char>(e.kind()) << e.overload() << e.parse_only() << e.get_expr();
     if (e.is_numeral()) {
         s << e.get_num();
     } else {
         s << static_cast<char>(e.group()) << length(e.get_transitions());
         for (auto const & t : e.get_transitions())
             s << t;
         s << e.priority();
     }
 }
开发者ID:cpehle,项目名称:lean,代码行数:11,代码来源:parser_config.cpp


示例6: fillstr

strings fillstr(entry& e) {
  // oh this is so stupid. Normalise requires strings, which it then countpaths
  // for me. So I have to take my clean-room hashes and recreate the strings so
  //  that normalise can turn them back into hashes.
  strings ss;
  for(entry::const_iterator i = e.begin(); i!=e.end(); i++) {
    for(int j = 0; j < (int)i->second; j++) {
      ss.push_back(i->first);
    }
  }
  return ss;
}
开发者ID:sandersn,项目名称:dialect,代码行数:12,代码来源:test.cpp


示例7: TORRENT_ASSERT

void dht_tracker::start(entry const& bootstrap
                        , find_data::nodes_callback const& f)
{
    TORRENT_ASSERT(m_ses.is_network_thread());
    std::vector<udp::endpoint> initial_nodes;

    if (bootstrap.type() == entry::dictionary_t)
    {
        TORRENT_TRY {
            if (entry const* nodes = bootstrap.find_key("nodes"))
                read_endpoint_list<udp::endpoint>(nodes, initial_nodes);
        } TORRENT_CATCH(std::exception&) {}
    }
开发者ID:kknet,项目名称:PopcornTV,代码行数:13,代码来源:dht_tracker.cpp


示例8: copy

	void entry::copy(entry const& e)
	{
		switch (e.type())
		{
		case int_t:
			new (&data) integer_type(e.integer());
			break;
		case string_t:
			new (&data) string_type(e.string());
			break;
		case list_t:
			new (&data) list_type(e.list());
			break;
		case dictionary_t:
			new (&data) dictionary_type(e.dict());
			break;
		case undefined_t:
			TORRENT_ASSERT(e.type() == undefined_t);
			break;
		case preformatted_t:
			new (&data) preformatted_type(e.preformatted());
			break;
		}
		m_type = e.type();
#if TORRENT_USE_ASSERTS
		m_type_queried = true;
#endif
	}
开发者ID:pavel-pimenov,项目名称:flylinkdc-r5xx,代码行数:28,代码来源:entry.cpp


示例9: TORRENT_ASSERT_PRECOND

	torrent_handle session_handle::add_torrent(
		char const* tracker_url
		, sha1_hash const& info_hash
		, char const* name
		, std::string const& save_path
		, entry const& resume_data
		, storage_mode_t storage_mode
		, bool paused
		, storage_constructor_type sc
		, void* userdata)
	{
		TORRENT_ASSERT_PRECOND(!save_path.empty());

		add_torrent_params p(sc);
		p.trackers.push_back(tracker_url);
		p.info_hash = info_hash;
		p.save_path = save_path;
		p.storage_mode = storage_mode;

		if (paused) p.flags |= add_torrent_params::flag_paused;
		else p.flags &= ~add_torrent_params::flag_paused;

		p.userdata = userdata;
		p.name = name;
		if (resume_data.type() != entry::undefined_t)
		{
			bencode(std::back_inserter(p.resume_data), resume_data);
		}
		return add_torrent(p);
	}
开发者ID:krattai,项目名称:AEBL,代码行数:30,代码来源:session_handle.cpp


示例10: convert0

 static object convert0(entry const& e)
 {
     switch (e.type())
     {
     case entry::int_t:
         return object(e.integer());
     case entry::string_t:
         return object(e.string());
     case entry::list_t:
         return convert(e.list());
     case entry::dictionary_t:
         return convert(e.dict());
     default:
         return object();
     }
 }
开发者ID:svn2github,项目名称:libtorrent-rasterbar,代码行数:16,代码来源:entry.cpp


示例11: extract_single_file

	void extract_single_file(const entry& dict, file_entry& target
		, std::string const& root_dir)
	{
		target.size = dict["length"].integer();
		target.path = root_dir;


		// prefer the name.utf-8
		// because if it exists, it is more
		// likely to be correctly encoded

		const entry::list_type* list = 0;
		if (entry const* p = dict.find_key("path.utf-8"))
		{
			list = &p->list();
		}
		else
		{
			list = &dict["path"].list();
		}

		for (entry::list_type::const_iterator i = list->begin();
			i != list->end(); ++i)
		{
			if (i->string() != "..")
				target.path /= i->string();
		}
		verify_encoding(target);
		if (target.path.is_complete()) throw std::runtime_error("torrent contains "
			"a file with an absolute path: '"
			+ target.path.native_file_string() + "'");
	}
开发者ID:svn2github,项目名称:libtorrent-rasterbar,代码行数:32,代码来源:torrent_info.cpp


示例12: cache_

void repository::builder::unpack_source(
    const entry &package, const boost::filesystem::path &destination,
    snapshot &snapshot_) {
  BUNSAN_LOG_DEBUG << "Starting " << package << " import unpack";
  const index deps = cache_().read_index(package);
  // extract sources
  for (const auto &i : deps.source.self)
    extractor_().extract_source(package, i.source, destination / i.path);
  // dump package checksum into snapshot
  {
    const auto iter = snapshot_.find(package);
    const snapshot_entry checksum = cache_().read_checksum(package);
    if (iter != snapshot_.end())
      BOOST_ASSERT(iter->second == checksum);
    else
      snapshot_[package.name()] = checksum;
  }
  // extract source imports
  for (const auto &i : deps.source.import.source)
    unpack_source(i.package, destination / i.path, snapshot_);
  // extract package imports
  for (const auto &i : deps.source.import.package) {
    extractor_().extract_installation(i.package, destination / i.path);
    merge_maps(snapshot_, cache_().read_installation_snapshot(i.package));
  }
}
开发者ID:bunsanorg,项目名称:pm,代码行数:26,代码来源:builder.cpp


示例13: fail

	bool http_tracker_connection::extract_peer_info(const entry& info, peer_entry& ret)
	{
		// extract peer id (if any)
		if (info.type() != entry::dictionary_t)
		{
			fail(-1, "invalid response from tracker (invalid peer entry)");
			return false;
		}
		entry const* i = info.find_key("peer id");
		if (i != 0)
		{
			if (i->type() != entry::string_t || i->string().length() != 20)
			{
				fail(-1, "invalid response from tracker (invalid peer id)");
				return false;
			}
			std::copy(i->string().begin(), i->string().end(), ret.pid.begin());
		}
		else
		{
			// if there's no peer_id, just initialize it to a bunch of zeroes
			std::fill_n(ret.pid.begin(), 20, 0);
		}

		// extract ip
		i = info.find_key("ip");
		if (i == 0 || i->type() != entry::string_t)
		{
			fail(-1, "invalid response from tracker");
			return false;
		}
		ret.ip = i->string();

		// extract port
		i = info.find_key("port");
		if (i == 0 || i->type() != entry::int_t)
		{
			fail(-1, "invalid response from tracker");
			return false;
		}
		ret.port = (unsigned short)i->integer();

		return true;
	}
开发者ID:huyang819,项目名称:cdn-partner,代码行数:44,代码来源:http_tracker_connection.cpp


示例14: integer

	bool entry::operator==(entry const& e) const
	{
		if (m_type != e.m_type) return false;

		switch(m_type)
		{
		case int_t:
			return integer() == e.integer();
		case string_t:
			return string() == e.string();
		case list_t:
			return list() == e.list();
		case dictionary_t:
			return dict() == e.dict();
		default:
			assert(m_type == undefined_t);
			return true;
		}
	}
开发者ID:340211173,项目名称:P2PCenter,代码行数:19,代码来源:entry.cpp


示例15: bencode_recursive

		int bencode_recursive(OutIt& out, const entry& e)
		{
			int ret = 0;
			switch(e.type())
			{
			case entry::int_t:
				write_char(out, 'i');
				ret += write_integer(out, e.integer());
				write_char(out, 'e');
				ret += 2;
				break;
			case entry::string_t:
				ret += write_integer(out, e.string().length());
				write_char(out, ':');
				ret += write_string(e.string(), out);
				ret += 1;
				break;
			case entry::list_t:
				write_char(out, 'l');
				for (entry::list_type::const_iterator i = e.list().begin(); i != e.list().end(); ++i)
					ret += bencode_recursive(out, *i);
				write_char(out, 'e');
				ret += 2;
				break;
			case entry::dictionary_t:
				write_char(out, 'd');
				for (entry::dictionary_type::const_iterator i = e.dict().begin();
					i != e.dict().end(); ++i)
				{
					// write key
					ret += write_integer(out, i->first.length());
					write_char(out, ':');
					ret += write_string(i->first, out);
					// write value
					ret += bencode_recursive(out, i->second);
					ret += 1;
				}
				write_char(out, 'e');
				ret += 2;
				break;
			default:
				// trying to encode a structure with uninitialized values!
				TORRENT_ASSERT_VAL(false, e.type());
				// do nothing
				break;
			}
			return ret;
		}
开发者ID:EricMyers47,项目名称:OpenSpace,代码行数:48,代码来源:bencode.hpp


示例16: get_device_id

 bool operator==(const entry& other) const {
   return get_device_id() == other.get_device_id() &&
          get_event_time_stamp() == other.get_event_time_stamp() &&
          get_valid() == other.get_valid() &&
          get_lazy() == other.get_lazy() &&
          get_event() == other.get_event() &&
          get_event_type() == other.get_event_type() &&
          get_original_event() == other.get_original_event();
 }
开发者ID:tekezo,项目名称:Karabiner-Elements,代码行数:9,代码来源:entry.hpp


示例17: push_back_entry

 void push_back_entry(const entry& entry) {
   emplace_back_entry(entry.get_device_id(),
                      entry.get_event_time_stamp(),
                      entry.get_event(),
                      entry.get_event_type(),
                      entry.get_original_event(),
                      entry.get_lazy());
   events_.back().set_valid(entry.get_valid());
 }
开发者ID:tekezo,项目名称:Karabiner-Elements,代码行数:9,代码来源:queue.hpp


示例18: bencode

	void session::load_state(entry const& ses_state)
	{
		if (ses_state.type() == entry::undefined_t) return;
		std::vector<char> buf;
		bencode(std::back_inserter(buf), ses_state);
		lazy_entry e;
		error_code ec;
		int ret = lazy_bdecode(&buf[0], &buf[0] + buf.size(), e, ec);
		TORRENT_ASSERT(ret == 0);
		TORRENT_SYNC_CALL1(load_state, &e);
	}
开发者ID:pedia,项目名称:raidget,代码行数:11,代码来源:session.cpp


示例19: save_struct

	void save_struct(entry& e, void const* s, bencode_map_entry const* m, int num, void const* def)
	{
		if (e.type() != entry::dictionary_t) e = entry(entry::dictionary_t);
		for (int i = 0; i < num; ++i)
		{
			char const* key = m[i].name;
			void const* src = ((char*)s) + m[i].offset;
			if (def)
			{
				// if we have a default value for this field
				// and it is the default, don't save it
				void const* default_value = ((char*)def) + m[i].offset;
				switch (m[i].type)
				{
					case std_string:
						if (*((std::string*)src) == *((std::string*)default_value)) continue;
						break;
					case character:
						if (*((char*)src) == *((char*)default_value)) continue;
						break;
					case integer:
						if (*((int*)src) == *((int*)default_value)) continue;
						break;
					case size_integer:
						if (*((size_type*)src) == *((size_type*)default_value)) continue;
						break;
					case time_integer:
						if (*((time_t*)src) == *((time_t*)default_value)) continue;
						break;
					case floating_point:
						if (*((float*)src) == *((float*)default_value)) continue;
						break;
					case boolean:
						if (*((bool*)src) == *((bool*)default_value)) continue;
						break;
					default: TORRENT_ASSERT(false);
				}
			}
			entry& val = e[key];
			TORRENT_ASSERT_VAL(val.type() == entry::undefined_t, val.type());
			switch (m[i].type)
			{
				case std_string: val = *((std::string*)src); break;
				case character: val = *((char*)src); break;
				case integer: val = *((int*)src); break;
				case size_integer: val = *((size_type*)src); break;
				case time_integer: val = *((time_t*)src); break;
				case floating_point: val = size_type(*((float*)src) * 1000.f); break;
				case boolean: val = *((bool*)src); break;
				default: TORRENT_ASSERT(false);
			}
		}
	}
开发者ID:kknet,项目名称:PopcornTV,代码行数:53,代码来源:settings.cpp


示例20: copy

	void entry::copy(const entry& e)
	{
		m_type = e.m_type;
		switch(m_type)
		{
		case int_t:
			new(data) integer_type(e.integer());
			break;
		case string_t:
			new(data) string_type(e.string());
			break;
		case list_t:
			new(data) list_type(e.list());
			break;
		case dictionary_t:
			new (data) dictionary_type(e.dict());
			break;
		default:
			m_type = undefined_t;
		}
	}
开发者ID:340211173,项目名称:P2PCenter,代码行数:21,代码来源:entry.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ env_var_t类代码示例发布时间:2022-05-31
下一篇:
C++ entity_pos_t类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap