本文整理汇总了C++中Sink::WriteGen方法的典型用法代码示例。如果您正苦于以下问题:C++ Sink::WriteGen方法的具体用法?C++ Sink::WriteGen怎么用?C++ Sink::WriteGen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sink
的用法示例。
在下文中一共展示了Sink::WriteGen方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Dump_
void CollectionLinkHeaderItem::Dump_(Sink& sink) const
{
Header hdr{};
hdr.offset = ToFilePos(data->ptr);
hdr.count = data->ptr.As0<CollectionLinkItem>().entries.size();
sink.WriteGen(hdr);
}
示例2: Dump_
void DataItem::Dump_(Sink& sink) const
{
Header hdr;
hdr.type = type;
hdr.offset_unit = offset_unit;
hdr.field_8 = field_8;
hdr.length = GetSize() - sizeof(Header);
sink.WriteGen(hdr);
ItemWithChildren::Dump_(sink);
}
示例3: memcpy
void Cl3::Dump_(Sink& sink) const
{
auto sections_offset = (sizeof(Header)+PAD) & ~PAD;
auto files_offset = (sections_offset+sizeof(Section)*2+PAD) & ~PAD;
auto data_offset = (files_offset+sizeof(FileEntry)*entries.size()+PAD) & ~PAD;
auto link_offset = data_offset + data_size;
Header hdr;
memcpy(hdr.magic, "CL3L", 4);
hdr.field_04 = 0;
hdr.field_08 = 3;
hdr.sections_count = 2;
hdr.sections_offset = sections_offset;
hdr.field_14 = field_14;
sink.WriteGen(hdr);
sink.Pad(sections_offset-sizeof(Header));
Section sec;
memset(&sec, 0, sizeof(Section));
sec.name = "FILE_COLLECTION";
sec.count = entries.size();
sec.data_size = link_offset - files_offset;
sec.data_offset = files_offset;
sink.WriteGen(sec);
sec.name = "FILE_LINK";
sec.count = link_count;
sec.data_size = link_count * sizeof(LinkEntry);
sec.data_offset = link_offset;
sink.WriteGen(sec);
sink.Pad((PAD_BYTES - ((2*sizeof(Section)) & PAD)) & PAD);
FileEntry fe;
fe.field_214 = fe.field_218 = fe.field_21c = 0;
fe.field_220 = fe.field_224 = fe.field_228 = fe.field_22c = 0;
// file entry header
uint32_t offset = data_offset-files_offset, link_i = 0;
for (auto& e : entries)
{
fe.name = e.name;
fe.field_200 = e.field_200;
fe.data_offset = offset;
auto size = e.src ? e.src->GetSize() : 0;
fe.data_size = size;
fe.link_start = link_i;
fe.link_count = e.links.size();
sink.WriteGen(fe);
offset = (offset+size+PAD) & ~PAD;
link_i += e.links.size();
}
sink.Pad((PAD_BYTES - ((entries.size()*sizeof(FileEntry)) & PAD)) & PAD);
// file data
for (auto& e : entries)
{
if (!e.src) continue;
e.src->Dump(sink);
sink.Pad((PAD_BYTES - (e.src->GetSize() & PAD)) & PAD);
}
// links
LinkEntry le;
memset(&le, 0, sizeof(LinkEntry));
for (auto& e : entries)
{
uint32_t i = 0;
for (auto l : e.links)
{
le.linked_file_id = l;
le.link_id = i++;
sink.WriteGen(le);
}
}
}