本文整理汇总了C++中ContentFeatures::deSerialize方法的典型用法代码示例。如果您正苦于以下问题:C++ ContentFeatures::deSerialize方法的具体用法?C++ ContentFeatures::deSerialize怎么用?C++ ContentFeatures::deSerialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContentFeatures
的用法示例。
在下文中一共展示了ContentFeatures::deSerialize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deSerialize
void deSerialize(std::istream &is)
{
clear();
int version = readU8(is);
if(version != 1)
throw SerializationError("unsupported NodeDefinitionManager version");
u16 count = readU16(is);
std::istringstream is2(deSerializeLongString(is), std::ios::binary);
for(u16 n=0; n<count; n++){
u16 i = readU16(is2);
if(i > MAX_CONTENT){
errorstream<<"ContentFeatures::deSerialize(): "
<<"Too large content id: "<<i<<std::endl;
continue;
}
/*// Do not deserialize special types
if(i == CONTENT_IGNORE || i == CONTENT_AIR)
continue;*/
ContentFeatures *f = &m_content_features[i];
// Read it from the string wrapper
std::string wrapper = deSerializeString(is2);
std::istringstream wrapper_is(wrapper, std::ios::binary);
f->deSerialize(wrapper_is);
verbosestream<<"deserialized "<<f->name<<std::endl;
if(f->name != "")
addNameIdMapping(i, f->name);
}
}
示例2: deSerialize
void CNodeDefManager::deSerialize(std::istream &is)
{
clear();
int version = readU8(is);
if (version != 1)
throw SerializationError("unsupported NodeDefinitionManager version");
u16 count = readU16(is);
std::istringstream is2(deSerializeLongString(is), std::ios::binary);
ContentFeatures f;
for (u16 n = 0; n < count; n++) {
u16 i = readU16(is2);
// Read it from the string wrapper
std::string wrapper = deSerializeString(is2);
std::istringstream wrapper_is(wrapper, std::ios::binary);
f.deSerialize(wrapper_is);
// Check error conditions
if (i == CONTENT_IGNORE || i == CONTENT_AIR || i == CONTENT_UNKNOWN) {
warningstream << "NodeDefManager::deSerialize(): "
"not changing builtin node " << i << std::endl;
continue;
}
if (f.name.empty()) {
warningstream << "NodeDefManager::deSerialize(): "
"received empty name" << std::endl;
continue;
}
// Ignore aliases
u16 existing_id;
if (m_name_id_mapping.getId(f.name, existing_id) && i != existing_id) {
warningstream << "NodeDefManager::deSerialize(): "
"already defined with different ID: " << f.name << std::endl;
continue;
}
// All is ok, add node definition with the requested ID
if (i >= m_content_features.size())
m_content_features.resize((u32)(i) + 1);
m_content_features[i] = f;
addNameIdMapping(i, f.name);
verbosestream << "deserialized " << f.name << std::endl;
getNodeBoxUnion(f.selection_box, f, &m_selection_box_union);
fixSelectionBoxIntUnion();
}
}
示例3: deSerialize
void deSerialize(std::istream &is)
{
clear();
u16 count = readU16(is);
std::istringstream tmp_is(deSerializeLongString(is), std::ios::binary);
for(u16 n=0; n<count; n++){
u16 i = readU16(tmp_is);
if(i > MAX_CONTENT){
errorstream<<"ContentFeatures::deSerialize(): "
<<"Too large content id: "<<i<<std::endl;
continue;
}
/*// Do not deserialize special types
if(i == CONTENT_IGNORE || i == CONTENT_AIR)
continue;*/
ContentFeatures *f = &m_content_features[i];
f->deSerialize(tmp_is);
if(f->name != "")
addNameIdMapping(i, f->name);
}
}