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 19 namespace panda::panda_file { ModuleDataAccessor(const panda_file::File & panda_file,panda_file::File::EntityId module_data_id)20ModuleDataAccessor::ModuleDataAccessor(const panda_file::File &panda_file, panda_file::File::EntityId module_data_id) 21 : panda_file_(panda_file), module_data_id_(module_data_id) 22 { 23 auto sp = panda_file_.GetSpanFromId(module_data_id); 24 25 auto module_sp = sp.SubSpan(panda_file::ID_SIZE); // skip literalnum 26 27 num_module_requests_ = panda_file::helpers::Read<panda_file::ID_SIZE>(&module_sp); 28 29 for (size_t idx = 0; idx < num_module_requests_; idx++) { 30 auto value = static_cast<uint32_t>(panda_file::helpers::Read<sizeof(uint32_t)>(&module_sp)); 31 module_requests_.emplace_back(value); 32 } 33 34 entry_data_sp_ = module_sp; 35 } 36 } // namespace panda::panda_file