本文整理汇总了C++中OutputStream::WriteData方法的典型用法代码示例。如果您正苦于以下问题:C++ OutputStream::WriteData方法的具体用法?C++ OutputStream::WriteData怎么用?C++ OutputStream::WriteData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutputStream
的用法示例。
在下文中一共展示了OutputStream::WriteData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Write
void PropertyMapWriter::Write (OutputStream& stream, const common::PropertyMap& properties)
{
size_t saved_position = stream.Position ();
try
{
bool need_send_layout_id = false;
//поиск карты и лэйаута
const common::PropertyLayout& layout = properties.Layout ();
Impl::LayoutDescPtr layout_desc;
Impl::MapDescPtr map_desc;
Impl::MapDescMap::iterator map_iter = impl->property_maps.find (properties.Id ());
if (map_iter != impl->property_maps.end ())
{
map_desc = map_iter->second;
layout_desc = map_desc->layout;
if (properties.Hash () == map_desc->hash)
return;
if (layout_desc->id != layout.Id ())
{
layout_desc = Impl::LayoutDescPtr ();
Impl::LayoutMap::iterator layout_iter = impl->layouts.find (layout.Id ());
if (layout_iter != impl->layouts.end ())
layout_desc = layout_iter->second;
}
}
else
{
Impl::LayoutMap::iterator layout_iter = impl->layouts.find (layout.Id ());
if (layout_iter != impl->layouts.end ())
layout_desc = layout_iter->second;
}
//синхронизация идентификатора карты
PropertyMapHeader header = {static_cast<object_id_t> (properties.Id ()), false, false};
if (!layout_desc || layout_desc->hash != layout.Hash ())
{
header.has_layout = true;
}
else //we always send layout id so reader will have possibility to restore layout after exception
{
header.has_layout_id = true;
}
stream.BeginCommand (CommandId_UpdatePropertyMap);
stream.Write (header);
//синхронизация лэйаута
if (header.has_layout)
{
impl->WriteLayout (stream, layout, layout_desc);
}
if (header.has_layout_id)
{
write (stream, static_cast<object_id_t> (layout.Id ()));
}
//создание объекта слежения за картой свойств
bool need_add_new_map = !map_desc;
if (!map_desc)
{
map_desc = Impl::MapDescPtr (new Impl::MapDesc, false);
map_desc->layout = layout_desc;
}
//синхронизация буфера карты свойств
write (stream, static_cast<uint32> (properties.BufferSize ()));
stream.WriteData (properties.BufferData (), properties.BufferSize ());
//синхронизация строк
for (IndexArray::iterator iter=layout_desc->string_indices.begin (), end=layout_desc->string_indices.end (); iter!=end; ++iter)
write (stream, properties.GetString (*iter));
//обновление полей и карт
if (need_add_new_map)
{
properties.Trackable ().connect_tracker (xtl::bind (&Impl::RemovePropertyMap, impl.get (), properties.Id ()), *impl);
impl->property_maps.insert_pair (properties.Id (), map_desc);
}
//.........这里部分代码省略.........