| 1525 | } |
| 1526 | |
| 1527 | void CPartFile_Encoder::Encode(CECTag *parent) |
| 1528 | { |
| 1529 | // |
| 1530 | // Source part frequencies |
| 1531 | // |
| 1532 | CKnownFile_Encoder::Encode(parent); |
| 1533 | |
| 1534 | // |
| 1535 | // Gaps |
| 1536 | // |
| 1537 | const CGapList& gaplist = m_PartFile()->GetGapList(); |
| 1538 | const size_t gap_list_size = gaplist.size(); |
| 1539 | ArrayOfUInts64 gaps; |
| 1540 | gaps.reserve(gap_list_size * 2); |
| 1541 | |
| 1542 | for (CGapList::const_iterator curr_pos = gaplist.begin(); |
| 1543 | curr_pos != gaplist.end(); ++curr_pos) { |
| 1544 | gaps.push_back(curr_pos.start()); |
| 1545 | gaps.push_back(curr_pos.end()); |
| 1546 | } |
| 1547 | |
| 1548 | int gap_enc_size = 0; |
| 1549 | bool changed; |
| 1550 | const uint8 *gap_enc_data = m_gap_status.Encode(gaps, gap_enc_size, changed); |
| 1551 | if (changed) { |
| 1552 | parent->AddTag(CECTag(EC_TAG_PARTFILE_GAP_STATUS, gap_enc_size, (void *)gap_enc_data)); |
| 1553 | } |
| 1554 | delete[] gap_enc_data; |
| 1555 | |
| 1556 | // |
| 1557 | // Requested blocks |
| 1558 | // |
| 1559 | ArrayOfUInts64 req_buffer; |
| 1560 | const CPartFile::CReqBlockPtrList& requestedblocks = m_PartFile()->GetRequestedBlockList(); |
| 1561 | CPartFile::CReqBlockPtrList::const_iterator curr_pos2 = requestedblocks.begin(); |
| 1562 | |
| 1563 | for ( ; curr_pos2 != requestedblocks.end(); ++curr_pos2 ) { |
| 1564 | Requested_Block_Struct* block = *curr_pos2; |
| 1565 | req_buffer.push_back(block->StartOffset); |
| 1566 | req_buffer.push_back(block->EndOffset); |
| 1567 | } |
| 1568 | int req_enc_size = 0; |
| 1569 | const uint8 *req_enc_data = m_req_status.Encode(req_buffer, req_enc_size, changed); |
| 1570 | if (changed) { |
| 1571 | parent->AddTag(CECTag(EC_TAG_PARTFILE_REQ_STATUS, req_enc_size, (void *)req_enc_data)); |
| 1572 | } |
| 1573 | delete[] req_enc_data; |
| 1574 | |
| 1575 | // |
| 1576 | // Source names |
| 1577 | // |
| 1578 | // First count occurrence of all source names |
| 1579 | // |
| 1580 | CECEmptyTag sourceNames(EC_TAG_PARTFILE_SOURCE_NAMES); |
| 1581 | typedef std::map<wxString, int> strIntMap; |
| 1582 | strIntMap nameMap; |
| 1583 | const CPartFile::SourceSet &sources = m_PartFile()->GetSourceList(); |
| 1584 | for (CPartFile::SourceSet::const_iterator it = sources.begin(); it != sources.end(); ++it) { |
no test coverage detected