• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2024 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 #ifndef ABC2PROGRAM_ABC_STRING_TABLE_H
17 #define ABC2PROGRAM_ABC_STRING_TABLE_H
18 
19 #include <set>
20 #include <cstdint>
21 #include <string>
22 #include <iostream>
23 #include <assembly-program.h>
24 #include "file-inl.h"
25 #include "file.h"
26 
27 namespace ark::abc2program {
28 
29 class AbcStringTable {
30 public:
AbcStringTable(const panda_file::File & file)31     explicit AbcStringTable(const panda_file::File &file) : file_(file) {}
32     std::string GetStringById(uint32_t stringId) const;
33     std::string GetStringById(panda_file::File::EntityId entityId) const;
34     void AddStringId(uint32_t stringId);
35     void AddStringId(panda_file::File::EntityId entityId);
36     std::set<std::string> GetStringSet() const;
37     std::string StringDataToString(panda_file::File::StringData sd) const;
38     void Dump(std::ostream &os) const;
39 
40 private:
41     void DumpStringById(std::ostream &os, uint32_t stringId) const;
42     const panda_file::File &file_;
43     std::set<uint32_t> stingIdSet_;
44 };
45 
46 }  // namespace ark::abc2program
47 
48 #endif  // ABC2PROGRAM_ABC_STRING_TABLE_H
49