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

C++ serializeLongString函数代码示例

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

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



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

示例1: os

std::string LuaEntitySAO::getStaticData()
{
/*
	verbosestream<<FUNCTION_NAME<<std::endl;
*/
	std::ostringstream os(std::ios::binary);
	// version
	writeU8(os, 1);
	// name
	os<<serializeString(m_init_name);
	// state
	if(m_registered){
		std::string state = m_env->getScriptIface()->
			luaentity_GetStaticdata(m_id);
		os<<serializeLongString(state);
	} else {
		os<<serializeLongString(m_init_state);
	}
	// hp
	writeS16(os, m_hp);
	// velocity
	writeV3F1000(os, m_velocity);
	// yaw
	writeF1000(os, m_yaw);
	return os.str();
}
开发者ID:alexxvk,项目名称:freeminer,代码行数:26,代码来源:content_sao.cpp


示例2: UASSERT

void TestSerialization::testSerializeLongString()
{
	// Test blank string
	UASSERT(serializeLongString("") == mkstr("\0\0\0\0"));

	// Test basic string
	UASSERT(serializeLongString("Hello world!") == mkstr("\0\0\0\14Hello world!"));

	// Test character range
	UASSERT(serializeLongString(teststring2) == mkstr("\0\0\1\0") + teststring2);
}
开发者ID:MultiCraftProject,项目名称:MultiCraft,代码行数:11,代码来源:test_serialization.cpp


示例3: os

std::string PlayerSAO::getClientInitializationData()
{
	std::ostringstream os(std::ios::binary);
	writeU8(os, 0); // version
	os<<serializeString(m_player->getName()); // name
	writeU8(os, 1); // is_player
	writeV3F1000(os, m_player->getPosition() + v3f(0,BS*1,0));
	writeF1000(os, m_player->getYaw());
	writeS16(os, getHP());
	writeU8(os, 2); // number of messages stuffed in here
	os<<serializeLongString(getPropertyPacket()); // message 1
	os<<serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
	return os.str();
}
开发者ID:AMDmi3,项目名称:minetest,代码行数:14,代码来源:content_sao.cpp


示例4: is

void TestSerialization::testDeSerializeLongString()
{
	// Test deserialize
	{
		std::istringstream is(serializeLongString(teststring2), std::ios::binary);
		UASSERT(deSerializeLongString(is) == teststring2);
		UASSERT(!is.eof());
		is.get();
		UASSERT(is.eof());
	}

	// Test deserialize an incomplete length specifier
	{
		std::istringstream is(mkstr("\x53"), std::ios::binary);
		EXCEPTION_CHECK(SerializationError, deSerializeLongString(is));
	}

	// Test deserialize a string with incomplete data
	{
		std::istringstream is(mkstr("\x00\x00\x00\x05 abc"), std::ios::binary);
		EXCEPTION_CHECK(SerializationError, deSerializeLongString(is));
	}

	// Test deserialize a string with a length too large
	{
		std::istringstream is(mkstr("\xFF\xFF\xFF\xFF blah"), std::ios::binary);
		EXCEPTION_CHECK(SerializationError, deSerializeLongString(is));
	}
}
开发者ID:MultiCraftProject,项目名称:MultiCraft,代码行数:29,代码来源:test_serialization.cpp


示例5: writeU8

void CNodeDefManager::serialize(std::ostream &os, u16 protocol_version) const
{
	writeU8(os, 1); // version
	u16 count = 0;
	std::ostringstream os2(std::ios::binary);
	for (u32 i = 0; i < m_content_features.size(); i++) {
		if (i == CONTENT_IGNORE || i == CONTENT_AIR
				|| i == CONTENT_UNKNOWN)
			continue;
		const ContentFeatures *f = &m_content_features[i];
		if (f->name.empty())
			continue;
		writeU16(os2, i);
		// Wrap it in a string to allow different lengths without
		// strict version incompatibilities
		std::ostringstream wrapper_os(std::ios::binary);
		f->serialize(wrapper_os, protocol_version);
		os2<<serializeString(wrapper_os.str());

		// must not overflow
		u16 next = count + 1;
		FATAL_ERROR_IF(next < count, "Overflow");
		count++;
	}
	writeU16(os, count);
	os << serializeLongString(os2.str());
}
开发者ID:EXio4,项目名称:minetest,代码行数:27,代码来源:nodedef.cpp


示例6: serialize

	void serialize(std::ostream &os, u16 protocol_version)
	{
		writeU8(os, 1); // version
		u16 count = 0;
		std::ostringstream os2(std::ios::binary);
		for(u32 i=0; i<m_content_features.size(); i++)
		{
			if(i == CONTENT_IGNORE || i == CONTENT_AIR
					|| i == CONTENT_UNKNOWN)
				continue;
			ContentFeatures *f = &m_content_features[i];
			if(f->name == "")
				continue;
			writeU16(os2, i);
			// Wrap it in a string to allow different lengths without
			// strict version incompatibilities
			std::ostringstream wrapper_os(std::ios::binary);
			f->serialize(wrapper_os, protocol_version);
			os2<<serializeString(wrapper_os.str());

			assert(count + 1 > count); // must not overflow
			count++;
		}
		writeU16(os, count);
		os<<serializeLongString(os2.str());
	}
开发者ID:BobMikfillin,项目名称:minetest,代码行数:26,代码来源:nodedef.cpp


示例7: os

std::string LuaEntitySAO::getStaticData()
{
	infostream<<__FUNCTION_NAME<<std::endl;
	std::ostringstream os(std::ios::binary);
	// version
	writeU8(os, 0);
	// name
	os<<serializeString(m_init_name);
	// state
	if(m_registered){
		lua_State *L = m_env->getLua();
		std::string state = scriptapi_luaentity_get_staticdata(L, m_id);
		os<<serializeLongString(state);
	} else {
		os<<serializeLongString(m_init_state);
	}
	return os.str();
}
开发者ID:basicinside,项目名称:minetest,代码行数:18,代码来源:content_sao.cpp


示例8: serializeBody

	void serializeBody(std::ostream &os)
	{
		m_inventory->serialize(os);
		os<<serializeLongString(m_text);
		os<<serializeString(m_owner);

		os<<serializeString(m_infotext);
		os<<serializeString(m_inventorydrawspec);
		writeU8(os, m_allow_text_input);
		writeU8(os, m_removal_disabled);
		writeU8(os, m_enforce_owner);

		int num_vars = m_stringvars.size();
		writeU32(os, num_vars);
		for(std::map<std::string, std::string>::iterator
				i = m_stringvars.begin(); i != m_stringvars.end(); i++){
			os<<serializeString(i->first);
			os<<serializeLongString(i->second);
		}
	}
开发者ID:Anchakor,项目名称:minetest,代码行数:20,代码来源:content_nodemeta.cpp


示例9: writeU32

void NodeMetadata::serialize(std::ostream &os) const
{
	int num_vars = m_stringvars.size();
	writeU32(os, num_vars);
	for(std::map<std::string, std::string>::const_iterator
			i = m_stringvars.begin(); i != m_stringvars.end(); i++){
		os<<serializeString(i->first);
		os<<serializeLongString(i->second);
	}

	m_inventory->serialize(os);
}
开发者ID:FunKetApp,项目名称:minetest,代码行数:12,代码来源:nodemetadata.cpp


示例10: gob_cmd_update_infant

std::string gob_cmd_update_infant(u16 id, u8 type,
		const std::string &client_initialization_data)
{
	std::ostringstream os(std::ios::binary);
	// command
	writeU8(os, GENERIC_CMD_SPAWN_INFANT);
	// parameters
	writeU16(os, id);
	writeU8(os, type);
	os<<serializeLongString(client_initialization_data);
	return os.str();
}
开发者ID:EXio4,项目名称:minetest,代码行数:12,代码来源:genericobject.cpp


示例11: os

std::string PlayerSAO::getClientInitializationData(u16 protocol_version)
{
	std::ostringstream os(std::ios::binary);

	if(protocol_version >= 15)
	{
		writeU8(os, 1); // version
		os<<serializeString(m_player->getName()); // name
		writeU8(os, 1); // is_player
		writeS16(os, getId()); //id
		writeV3F1000(os, m_player->getPosition() + v3f(0,BS*1,0));
		writeF1000(os, m_player->getYaw());
		writeS16(os, getHP());

		writeU8(os, 6 + m_bone_position.size()); // number of messages stuffed in here
		os<<serializeLongString(getPropertyPacket()); // message 1
		os<<serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
		os<<serializeLongString(gob_cmd_update_animation(
			m_animation_range, m_animation_speed, m_animation_blend, m_animation_loop)); // 3
		for(std::map<std::string, core::vector2d<v3f> >::const_iterator ii = m_bone_position.begin(); ii != m_bone_position.end(); ++ii){
			os<<serializeLongString(gob_cmd_update_bone_position((*ii).first, (*ii).second.X, (*ii).second.Y)); // m_bone_position.size
		}
		os<<serializeLongString(gob_cmd_update_attachment(m_attachment_parent_id, m_attachment_bone, m_attachment_position, m_attachment_rotation)); // 4
		os<<serializeLongString(gob_cmd_update_physics_override(m_physics_override_speed,
				m_physics_override_jump, m_physics_override_gravity, m_physics_override_sneak,
				m_physics_override_sneak_glitch)); // 5
		os << serializeLongString(gob_cmd_update_nametag_attributes(m_nametag_color)); // 6
	}
	else
	{
		writeU8(os, 0); // version
		os<<serializeString(m_player->getName()); // name
		writeU8(os, 1); // is_player
		writeV3F1000(os, m_player->getPosition() + v3f(0,BS*1,0));
		writeF1000(os, m_player->getYaw());
		writeS16(os, getHP());
		writeU8(os, 2); // number of messages stuffed in here
		os<<serializeLongString(getPropertyPacket()); // message 1
		os<<serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
	}

	// return result
	return os.str();
}
开发者ID:t0suj4,项目名称:minetest,代码行数:44,代码来源:content_sao.cpp


示例12: writeU32

void NodeMetadata::serialize(std::ostream &os) const
{
	int num_vars = m_stringvars.size();
	writeU32(os, num_vars);
	for (StringMap::const_iterator
			it = m_stringvars.begin();
			it != m_stringvars.end(); ++it) {
		os << serializeString(it->first);
		os << serializeLongString(it->second);
	}

	m_inventory->serialize(os);
}
开发者ID:hondalyfe88,项目名称:MultiCraft,代码行数:13,代码来源:nodemetadata.cpp


示例13: os

void TestSerialization::testStreamWrite()
{
	std::ostringstream os(std::ios_base::binary);
	std::string data;

	writeU8(os, 0x11);
	writeU16(os, 0x2233);
	writeU32(os, 0x44556677);
	writeU64(os, 0x8899AABBCCDDEEFF);

	writeS8(os, -128);
	writeS16(os, 30000);
	writeS32(os, -6);
	writeS64(os, -43);

	writeF1000(os, 53.53467f);
	writeF1000(os, -300000.32f);
	writeF1000(os, F1000_MIN);
	writeF1000(os, F1000_MAX);

	os << serializeString("foobar!");

	data = os.str();
	UASSERT(data.size() < sizeof(test_serialized_data));
	UASSERT(!memcmp(&data[0], test_serialized_data, data.size()));

	writeV2S16(os, v2s16(500, 500));
	writeV3S16(os, v3s16(4207, 604, -30));
	writeV2S32(os, v2s32(1920, 1080));
	writeV3S32(os, v3s32(-400, 6400054, 290549855));
	writeV2F1000(os, v2f(500.65661f, 350.34567f));

	os << serializeWideString(L"\x02~woof~\x5455");

	writeV3F1000(os, v3f(500, 10024.2f, -192.54f));
	writeARGB8(os, video::SColor(255, 128, 50, 128));

	os << serializeLongString("some longer string here");

	writeU16(os, 0xF00D);

	data = os.str();
	UASSERT(data.size() == sizeof(test_serialized_data));
	UASSERT(!memcmp(&data[0], test_serialized_data, sizeof(test_serialized_data)));
}
开发者ID:MultiCraftProject,项目名称:MultiCraft,代码行数:45,代码来源:test_serialization.cpp


示例14: serialize

	void serialize(std::ostream &os)
	{
		u16 count = 0;
		std::ostringstream tmp_os(std::ios::binary);
		for(u16 i=0; i<=MAX_CONTENT; i++)
		{
			if(i == CONTENT_IGNORE || i == CONTENT_AIR)
				continue;
			ContentFeatures *f = &m_content_features[i];
			if(f->name == "")
				continue;
			writeU16(tmp_os, i);
			f->serialize(tmp_os);
			count++;
		}
		writeU16(os, count);
		os<<serializeLongString(tmp_os.str());
	}
开发者ID:fusionlightcat,项目名称:minetest,代码行数:18,代码来源:nodedef.cpp


示例15: serialize

	void serialize(std::ostream &os)
	{
		writeU8(os, 1); // version
		u16 count = 0;
		std::ostringstream os2(std::ios::binary);
		for(u16 i=0; i<=MAX_CONTENT; i++)
		{
			if(i == CONTENT_IGNORE || i == CONTENT_AIR)
				continue;
			ContentFeatures *f = &m_content_features[i];
			if(f->name == "")
				continue;
			writeU16(os2, i);
			// Wrap it in a string to allow different lengths without
			// strict version incompatibilities
			std::ostringstream wrapper_os(std::ios::binary);
			f->serialize(wrapper_os);
			os2<<serializeString(wrapper_os.str());
			count++;
		}
		writeU16(os, count);
		os<<serializeLongString(os2.str());
	}
开发者ID:ajbetteridge,项目名称:minetest,代码行数:23,代码来源:nodedef.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ serializePacket函数代码示例发布时间:2022-05-30
下一篇:
C++ serialize8函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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