|
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Message Implementation Class for elf2e32 tool |
|
15 // @internalComponent |
|
16 // @released |
|
17 // |
|
18 // |
|
19 |
|
20 |
|
21 #ifndef _MESSAGE_IMPLEMENTATION_ |
|
22 #define _MESSAGE_IMPLEMENTATION_ |
|
23 |
|
24 #ifdef _MSC_VER |
|
25 #pragma warning(disable: 4514) // unreferenced inline function has been removed |
|
26 #pragma warning(disable: 4702) // unreachable code |
|
27 #pragma warning(disable: 4710) // function not inlined |
|
28 #pragma warning(disable: 4786) // identifier was truncated to '255' characters in the debug information |
|
29 #endif |
|
30 |
|
31 #include<map> |
|
32 #include<string> |
|
33 |
|
34 typedef std::map<int,char*> Map; |
|
35 typedef std::string String; |
|
36 |
|
37 enum { MAXMSSGNOLENGTH=5, BASEMSSGNO=1000 }; |
|
38 |
|
39 enum { ERROR = 0, |
|
40 WARNING, |
|
41 INFORMATION |
|
42 }; |
|
43 |
|
44 enum { FILEOPENERROR=1, |
|
45 FILEREADERROR, |
|
46 FILEWRITEERROR, |
|
47 ELFMAGICERROR, |
|
48 ELFCLASSERROR, |
|
49 ELFABIVERSIONERROR, |
|
50 ELFLEERROR, |
|
51 ELFARMERROR, |
|
52 ELFEXECUTABLEERROR, |
|
53 ELFSHSTRINDEXERROR, |
|
54 NAMELIBRARYNOTCORRECT, |
|
55 ORDINALSEQUENCEERROR, |
|
56 ARGUMENTNAMEERROR, |
|
57 OPTIONNAMEERROR, |
|
58 NOARGUMENTERROR, |
|
59 OPTIONPREFIXERROR, |
|
60 NOREQUIREDOPTIONERROR, |
|
61 NOFILENAMEERROR, |
|
62 INVALIDARGUMENTERROR, |
|
63 HUFFMANBUFFEROVERFLOWERROR, |
|
64 HUFFMANTOOMANYCODESERROR, |
|
65 HUFFMANINVALIDCODINGERROR, |
|
66 CAPABILITYALLINVERSIONERROR, |
|
67 CAPABILITYNONEINVERSIONERROR, |
|
68 UNRECOGNISEDCAPABILITYERROR, |
|
69 NOSTATICSYMBOLSERROR, |
|
70 DLLHASINITIALISEDDATAERROR, |
|
71 DLLHASUNINITIALISEDDATAERROR, |
|
72 ENTRYPOINTCORRUPTERROR, |
|
73 ENTRYPOINTNOTSUPPORTEDERROR, |
|
74 EXCEPTIONDESCRIPTOROUTSIDEROERROR, |
|
75 NOEXCEPTIONDESCRIPTORERROR, |
|
76 NEEDSECTIONVIEWERROR, |
|
77 DSONOTFOUNDERROR, |
|
78 UNDEFINEDSYMBOLERROR, |
|
79 SYMBOLMISSINGFROMELFERROR, |
|
80 MEMORYALLOCATIONERROR, |
|
81 E32IMAGEERROR, |
|
82 INVALIDINVOCATIONERROR, |
|
83 TARGETTYPENOTSPECIFIEDERROR, |
|
84 UNSUPPORTEDTARGETTYPEERROR, |
|
85 INDEXNOMESSAGEERROR, |
|
86 INDEXNOTREQUIREDERROR, |
|
87 INDEXNOTFOUNDERROR, |
|
88 NOMESSAGEFILEERROR, |
|
89 ENTRYPOINTNOTSETERROR, |
|
90 UNDEFINEDENTRYPOINTERROR, |
|
91 ORDINALNOTANUMBER, |
|
92 UNRECOGNIZEDTOKEN, |
|
93 NONAMEMISSING, |
|
94 EXPORTSEXPECTED, |
|
95 ATRATEMISSING, |
|
96 SYSDEFSMISMATCHERROR, |
|
97 SYSDEFERROR, |
|
98 INVALIDE32IMAGEERROR, |
|
99 HUFFMANBUFFERUNDERFLOWERROR, |
|
100 HUFFMANINCONSISTENTSIZEERROR, |
|
101 MULTIPLESYSDEFERROR, |
|
102 SYSDEFNOSYMBOLERROR, |
|
103 VALUEIGNOREDWARNING, |
|
104 ELFFILEERROR, |
|
105 SYMBOLCOUNTMISMATCHERROR, |
|
106 POSTLINKERERROR, |
|
107 BYTEPAIRINCONSISTENTSIZEERROR, |
|
108 ILLEGALEXPORTFROMDATASEGMENT, |
|
109 VALIDATIONERROR |
|
110 }; |
|
111 |
|
112 |
|
113 /** |
|
114 Abstract base Class for Message Implementation. |
|
115 @internalComponent |
|
116 @released |
|
117 */ |
|
118 class Message |
|
119 { |
|
120 public: |
|
121 virtual ~Message(){}; |
|
122 // get error string from message file |
|
123 virtual char * GetMessageString(int errorIndex)=0; |
|
124 // display message to output device |
|
125 virtual void Output(const char *aName) =0; |
|
126 // start logging to a file |
|
127 virtual void StartLogging(char *fileName)=0; |
|
128 // virtual void ReportWarning(int warnIndex,...)=0; |
|
129 virtual void ReportMessage(int aMsgType, int aMsgIndex,...)=0; |
|
130 virtual void CreateMessageFile(char *fileName)=0; |
|
131 virtual void InitializeMessages(char *fileName)=0; |
|
132 }; |
|
133 |
|
134 /** |
|
135 Class for Message Implementation. |
|
136 @internalComponent |
|
137 @released |
|
138 */ |
|
139 class MessageImplementation : public Message |
|
140 { |
|
141 public: |
|
142 MessageImplementation(); |
|
143 ~MessageImplementation(); |
|
144 |
|
145 //override base class methods |
|
146 char* GetMessageString(int errorIndex); |
|
147 void Output(const char *aName); |
|
148 void StartLogging(char *fileName); |
|
149 // void ReportWarning(int warnIndex,...); |
|
150 void ReportMessage(int aMsgType, int aMsgIndex,...); |
|
151 void CreateMessageFile(char *fileName); |
|
152 void InitializeMessages(char *fileName); |
|
153 private: |
|
154 |
|
155 bool iLogging; |
|
156 char* iLogFileName; |
|
157 FILE *iLogPtr; |
|
158 Map iMessage; |
|
159 }; |
|
160 |
|
161 /** |
|
162 Structure for Messages. |
|
163 @internalComponent |
|
164 @released |
|
165 */ |
|
166 struct EnglishMessage |
|
167 { |
|
168 int index; |
|
169 char message[1024]; |
|
170 }; |
|
171 |
|
172 #endif |
|
173 |