This repository has been archived on 2020-05-25. You can view files and clone it, but cannot push or open issues or pull requests.
tdlib-fork/td/telegram/files/FileBitmask.h
Arseny Smirnov 24f31ad888 FileManager: download big files with unknown size
GitOrigin-RevId: 3f4246f2d61127015138a32f2e93c8f932a81c50
2019-08-19 12:31:25 +03:00

42 lines
1.0 KiB
C++

//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2019
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#pragma once
#include "td/utils/common.h"
#include "td/utils/Slice.h"
#include "td/utils/StringBuilder.h"
namespace td {
class Bitmask {
public:
struct Decode {};
struct Ones {};
Bitmask() = default;
Bitmask(Decode, Slice data);
Bitmask(Ones, int64 count);
std::string encode(int32 prefix_count = -1);
int64 get_ready_prefix_size(int64 offset, int64 part_size, int64 file_size) const;
int64 get_total_size(int64 part_size, int64 file_size) const;
bool get(int64 offset_part) const;
int64 get_ready_parts(int64 offset_part) const;
std::vector<int32> as_vector() const;
void set(int64 offset_part);
int64 size() const;
Bitmask compress(int k);
private:
std::string data_;
};
StringBuilder &operator<<(StringBuilder &sb, const Bitmask &mask);
} // namespace td