e32tools/elf2e32/source/deffile.h
changeset 0 044383f39525
equal deleted inserted replaced
-1:000000000000 0:044383f39525
       
     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 // Implementation of the Class DefFile for the elf2e32 tool
       
    15 // @internalComponent
       
    16 // @released
       
    17 // 
       
    18 //
       
    19 
       
    20 #ifndef _DEF_FILE_
       
    21 #define _DEF_FILE_
       
    22 
       
    23 #include <list>
       
    24 
       
    25 class Symbol;
       
    26 typedef std::list <Symbol*>	SymbolList;
       
    27 
       
    28 /**
       
    29 Class for DEF File Handler.
       
    30 @internalComponent
       
    31 @released
       
    32 */
       
    33 class DefFile
       
    34 {
       
    35 	public:
       
    36 		DefFile():iSymbolList(NULL){};
       
    37 		virtual ~DefFile();
       
    38 		SymbolList* ReadDefFile(char *defFile);
       
    39 		void WriteDefFile(char *fileName, SymbolList *newSymbolList);
       
    40 		SymbolList* GetSymbolEntryList(char *defFile);
       
    41 		SymbolList* GetSymbolEntryList() { return iSymbolList;}
       
    42 	private:
       
    43 		char *iFileName;
       
    44 		SymbolList *iSymbolList;
       
    45 		int GetFileSize(FILE * fptrDef);
       
    46 		char* OpenDefFile(char *defFile);
       
    47 		void ParseDefFile(char *defData);
       
    48 		bool Tokenize(char* tokens, int aLineNum, Symbol& aSymbol);
       
    49 };
       
    50 
       
    51 //Different states while parsing a line in the def file.
       
    52 enum DefStates
       
    53 {
       
    54 	EInitState = 0,
       
    55 	ESymbolName = 1,
       
    56 	EAtSymbol,
       
    57 	EOrdinal,
       
    58 	EOptionals,
       
    59 	EComment,
       
    60 	EFinalState,
       
    61 	EInvalidState
       
    62 };
       
    63 
       
    64 #define CODESYM "CODE"
       
    65 #define DATASYM "DATA"
       
    66 
       
    67 /**
       
    68 Class for parsing a line from the DEF File.
       
    69 @internalComponent
       
    70 @released
       
    71 */
       
    72 class LineToken
       
    73 {
       
    74 public:
       
    75 	LineToken(char* , int , char *, Symbol *aSym);
       
    76 	char *iLine;
       
    77 	Symbol *iSymbol;
       
    78 	int iOffset;
       
    79 	DefStates iState;
       
    80 	
       
    81 	char *iFileName;
       
    82 	int iLineNum;
       
    83 
       
    84 	bool Tokenize();
       
    85 	void NextToken();
       
    86 	void IncrOffset(int aOff);
       
    87 	void SetState(DefStates aState);
       
    88 
       
    89 	bool IsWhiteSpace(char *aStr, int&);
       
    90 	bool IsPattern(char*, int&, int&);
       
    91 	bool IsDigit(char*, int&);
       
    92 	bool IsWord(char*, int&);
       
    93 };
       
    94 #endif