本文整理汇总了C++中Marker::set_to_offset方法的典型用法代码示例。如果您正苦于以下问题:C++ Marker::set_to_offset方法的具体用法?C++ Marker::set_to_offset怎么用?C++ Marker::set_to_offset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Marker
的用法示例。
在下文中一共展示了Marker::set_to_offset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read_lib
LibInfo read_lib(const fs::path& path)
{
std::fstream fs(path, std::ios::in | std::ios::binary | std::ios::ate);
Checks::check_exit(VCPKG_LINE_INFO, fs.is_open(), "Could not open file %s for reading", path.generic_string());
read_and_verify_archive_file_signature(fs);
Marker marker;
marker.set_to_current_pos(fs);
// First Linker Member
const ArchiveMemberHeader first_linker_member_header = ArchiveMemberHeader::read(fs);
Checks::check_exit(VCPKG_LINE_INFO,
first_linker_member_header.name().substr(0, 2) == "/ ",
"Could not find proper first linker member");
marker.advance_by(ArchiveMemberHeader::HEADER_SIZE + first_linker_member_header.member_size());
marker.seek_to_marker(fs);
const ArchiveMemberHeader second_linker_member_header = ArchiveMemberHeader::read(fs);
Checks::check_exit(VCPKG_LINE_INFO,
second_linker_member_header.name().substr(0, 2) == "/ ",
"Could not find proper second linker member");
// The first 4 bytes contains the number of archive members
const auto archive_member_count = read_value_from_stream<uint32_t>(fs);
const OffsetsArray offsets = OffsetsArray::read(fs, archive_member_count);
marker.advance_by(ArchiveMemberHeader::HEADER_SIZE + second_linker_member_header.member_size());
marker.seek_to_marker(fs);
const bool has_longname_member_header = peek_value_from_stream<uint16_t>(fs) == 0x2F2F;
if (has_longname_member_header)
{
const ArchiveMemberHeader longnames_member_header = ArchiveMemberHeader::read(fs);
marker.advance_by(ArchiveMemberHeader::HEADER_SIZE + longnames_member_header.member_size());
marker.seek_to_marker(fs);
}
std::set<MachineType> machine_types;
// Next we have the obj and pseudo-object files
for (const uint32_t offset : offsets.data)
{
marker.set_to_offset(offset + ArchiveMemberHeader::HEADER_SIZE); // Skip the header, no need to read it.
marker.seek_to_marker(fs);
const auto first_two_bytes = peek_value_from_stream<uint16_t>(fs);
const bool is_import_header = to_machine_type(first_two_bytes) == MachineType::UNKNOWN;
const MachineType machine =
is_import_header ? ImportHeader::read(fs).machine_type() : CoffFileHeader::read(fs).machine_type();
machine_types.insert(machine);
}
return {std::vector<MachineType>(machine_types.cbegin(), machine_types.cend())};
}