|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * |
|
5 * This program is free software: you can redistribute it and/or modify |
|
6 * it under the terms of the GNU Lesser General Public License as published by |
|
7 * the Free Software Foundation, either version 3 of the License, or |
|
8 * (at your option) any later version. |
|
9 * |
|
10 * This program is distributed in the hope that it will be useful, |
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 * GNU Lesser General Public License for more details. |
|
14 * |
|
15 * You should have received a copy of the GNU Lesser General Public License |
|
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
17 */ |
|
18 |
|
19 #ifndef ELFSTRINGTABLE_H_ |
|
20 #define ELFSTRINGTABLE_H_ |
|
21 |
|
22 // |
|
23 // Copyright (c) 2008 Symbian Software Ltd. All rights reserved. |
|
24 // |
|
25 |
|
26 #include <vector> |
|
27 |
|
28 #include "defs.h" |
|
29 #include "filefragment.h" |
|
30 #include "outputfile.h" |
|
31 |
|
32 class ElfStringTable : public FileFragmentOwner { |
|
33 public: |
|
34 ElfStringTable() : |
|
35 iSize(0), iData(NULL) |
|
36 {} |
|
37 |
|
38 ~ElfStringTable(){ |
|
39 iStrings.clear(); |
|
40 if (iData) { |
|
41 char * d = iData; |
|
42 iData = NULL; |
|
43 delete d; |
|
44 } |
|
45 } |
|
46 |
|
47 // The FileFragmentOwner protocol |
|
48 virtual void GetFileFragmentData(FileFragmentData & aFileFragmentData ); |
|
49 virtual size_t Size(); |
|
50 virtual void SetSize(size_t aSize) |
|
51 { iSize = aSize; } |
|
52 virtual void DeleteFileFragmentData(); |
|
53 |
|
54 size_t AddString(String aName); |
|
55 size_t AllocateInitialNullString() { |
|
56 if (iSize == 0) { |
|
57 StringTableEntry sn("", 0); |
|
58 iStrings.push_back(sn); |
|
59 iSize = 1; |
|
60 } |
|
61 // The initial string is always at offset 0 in the section. |
|
62 return 0; |
|
63 } |
|
64 |
|
65 private: |
|
66 class StringTableEntry { |
|
67 public: |
|
68 StringTableEntry(String aName, size_t aOffset): |
|
69 iName(aName), iOffset(aOffset) |
|
70 {} |
|
71 |
|
72 String iName; |
|
73 size_t iOffset; |
|
74 }; |
|
75 |
|
76 typedef std::vector<StringTableEntry> StringList; |
|
77 |
|
78 StringList iStrings; |
|
79 size_t iSize; |
|
80 char * iData; |
|
81 }; |
|
82 |
|
83 #endif /*ELFSTRINGTABLE_H_*/ |