Android-cuttlefish cvd tool
lazily_loaded_file.h
Go to the documentation of this file.
1//
2// Copyright (C) 2025 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15#pragma once
16
17#include <stddef.h>
18
19#include <memory>
20#include <string>
21
23
24namespace cuttlefish {
25
27 public:
29
30 virtual Result<size_t> Read(char* buf, size_t count) = 0;
31 virtual Result<size_t> Seek(size_t offset) = 0;
32};
33
35 public:
37 std::string filename, std::unique_ptr<LazilyLoadedFileReadCallback>);
38
42
43 Result<size_t> Read(char*, size_t);
44 Result<void> Seek(size_t);
45
46 private:
47 struct Impl;
48
49 LazilyLoadedFile(std::unique_ptr<Impl>);
50
51 std::unique_ptr<Impl> impl_;
52};
53
54} // namespace cuttlefish
Definition: expected.h:86
Definition: lazily_loaded_file.h:26
virtual Result< size_t > Seek(size_t offset)=0
virtual Result< size_t > Read(char *buf, size_t count)=0
Definition: lazily_loaded_file.h:34
LazilyLoadedFile & operator=(LazilyLoadedFile &&)
Definition: lazily_loaded_file.cc:89
Result< size_t > Read(char *, size_t)
Definition: lazily_loaded_file.cc:95
std::unique_ptr< Impl > impl_
Definition: lazily_loaded_file.h:51
Result< void > Seek(size_t)
Definition: lazily_loaded_file.cc:100
static Result< LazilyLoadedFile > Create(std::string filename, std::unique_ptr< LazilyLoadedFileReadCallback >)
Definition: lazily_loaded_file.cc:56
LazilyLoadedFile(LazilyLoadedFile &&)
Definition: lazily_loaded_file.cc:75
~LazilyLoadedFile()
Definition: lazily_loaded_file.cc:79
Definition: alloc_utils.cpp:23
Definition: lazily_loaded_file.cc:42