1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "module_data_accessor.h" 17 #include "file_items.h" 18 #include "helpers.h" 19 20 namespace panda::panda_file { ModuleDataAccessor(const panda_file::File & panda_file,panda_file::File::EntityId module_data_id)21ModuleDataAccessor::ModuleDataAccessor(const panda_file::File &panda_file, panda_file::File::EntityId module_data_id) 22 : panda_file_(panda_file), module_data_id_(module_data_id) 23 { 24 auto sp = panda_file_.GetSpanFromId(module_data_id); 25 26 auto module_sp = sp.SubSpan(panda_file::ID_SIZE); // skip literalnum 27 28 num_module_requests_ = panda_file::helpers::Read<panda_file::ID_SIZE>(&module_sp); 29 30 for (size_t idx = 0; idx < num_module_requests_; idx++) { 31 auto value = static_cast<uint32_t>(panda_file::helpers::Read<sizeof(uint32_t)>(&module_sp)); 32 module_requests_.emplace_back(value); 33 } 34 35 entry_data_sp_ = module_sp; 36 } 37 } // namespace panda::panda_file