本文整理汇总了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();
}
示例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);
}
示例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();
}
示例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));
}
}
示例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());
}
示例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());
}
示例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();
}
示例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);
}
}
示例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);
}
示例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();
}
示例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();
}
示例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);
}
示例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)));
}
示例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());
}
示例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());
}