コード例 #1
0
void Metalink4Writer::write_piece_hash(const MetalinkFile& file)
{
    if(file.get_piece_hashes().empty()) return;
    if(file.get_piece_hash_type().empty()) return;
    start(wxT("pieces"));
    add_attr(wxT("length"),
             wxString::Format(wxT("%lu"), file.get_piece_length()));
    add_attr(wxT("type"), file.get_piece_hash_type());
    close_start();
    const std::vector<wxString>& hashes = file.get_piece_hashes();
    for(std::vector<wxString>::const_iterator i = hashes.begin(),
            eoi = hashes.end(); i != eoi; ++i) {
        add_element(wxT("hash"), *i);
    }
    end(wxT("pieces"));
}
コード例 #2
0
void Metalink3Writer::write_piece_hashes(const MetalinkFile& file)
{
    if(!has_piece_hashes(file)) return;
    start(wxT("pieces"));
    add_attr(wxT("length"),
             wxString::Format(wxT("%lu"), file.get_piece_length()));
    add_attr(wxT("type"), file.get_piece_hash_type());
    close_start();
    const std::vector<wxString>& hashes = file.get_piece_hashes();
    long index = 0;
    for(std::vector<wxString>::const_iterator i = hashes.begin(),
            eoi = hashes.end(); i != eoi; ++i) {
        start(wxT("hash"));
        add_attr(wxT("piece"), wxString::Format(wxT("%ld"), index));
        end(wxT("hash"), *i);
        index++;
    }
    end(wxT("pieces"));
}