mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
integrating the existing state of TON Storage / TON Payments / CPS Fift development branches
This commit is contained in:
parent
040df63c98
commit
4e2624459b
153 changed files with 10760 additions and 1695 deletions
67
tddb/td/db/utils/BlobView.h
Normal file
67
tddb/td/db/utils/BlobView.h
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
TON Blockchain Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2019 Telegram Systems LLP
|
||||
*/
|
||||
#pragma once
|
||||
#include "td/utils/buffer.h"
|
||||
|
||||
namespace td {
|
||||
class BlobViewImpl;
|
||||
|
||||
class BlobView {
|
||||
public:
|
||||
BlobView();
|
||||
explicit BlobView(std::unique_ptr<BlobViewImpl> impl);
|
||||
BlobView(BlobView &&);
|
||||
BlobView &operator=(BlobView &&);
|
||||
~BlobView();
|
||||
td::Result<td::BufferSlice> to_buffer_slice();
|
||||
td::Result<td::Slice> view(td::MutableSlice slice, td::uint64 offset);
|
||||
td::Result<size_t> view_copy(td::MutableSlice slice, td::uint64 offset);
|
||||
td::Result<size_t> write(td::Slice data, td::uint64 offset);
|
||||
td::uint64 size();
|
||||
|
||||
explicit operator bool() const {
|
||||
return bool(impl_);
|
||||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr<BlobViewImpl> impl_;
|
||||
};
|
||||
|
||||
class BufferSliceBlobView {
|
||||
public:
|
||||
static BlobView create(td::BufferSlice slice);
|
||||
};
|
||||
class FileBlobView {
|
||||
public:
|
||||
static td::Result<BlobView> create(td::CSlice file_path, td::uint64 file_size = 0);
|
||||
};
|
||||
class FileNoCacheBlobView {
|
||||
public:
|
||||
static td::Result<BlobView> create(td::CSlice file_path, td::uint64 file_size = 0, bool may_write = false);
|
||||
};
|
||||
class FileMemoryMappingBlobView {
|
||||
public:
|
||||
static td::Result<BlobView> create(td::CSlice file_path, td::uint64 file_size = 0);
|
||||
};
|
||||
|
||||
// For testing purposes
|
||||
struct CycicBlobView {
|
||||
static td::Result<td::BlobView> create(td::BufferSlice data, td::uint64 total_size);
|
||||
};
|
||||
} // namespace td
|
Loading…
Add table
Add a link
Reference in a new issue