Apply patch from Daniel Schürmann: https://sourceforge.net/p/boomerang/bugs/78/
[boomerang.git] / boomerang / loader / SymTab.h
bloba5c1bc7a7c6156730ccf983e2045e3a0bc75668f
1 /*
2 * Copyright (C) 2005, Mike Van Emmerik
4 * See the file "LICENSE.TERMS" for information on usage and
5 * redistribution of this file, and for a DISCLAIMER OF ALL
6 * WARRANTIES.
8 */
10 /*==============================================================================
11 * FILE: SymTab.h
12 * OVERVIEW: This file contains the definition of the class SymTab, a simple class to implement a symbol table
13 * than can be looked up by address or my name.
14 * NOTE: Can't readily use operator[] overloaded for address and string parameters. The main problem is
15 * that when you do symtab[0x100] = "main", the string map doesn't see the string.
16 * If you have one of the maps be a pointer to the other string and use a special comparison operator, then
17 * if the strings are ever changed, then the map's internal rb-tree becomes invalid.
18 *============================================================================*/
21 * $Revision$
23 * 12 Jul 05 - Mike: New implementation with two maps
26 #ifndef __SYMTAB_H__
27 #define __SYMTAB_H__
29 #include "types.h"
30 #include <map>
31 #include <string>
33 class SymTab
35 // The map indexed by address.
36 std::map<ADDRESS, std::string> amap;
37 // The map indexed by string. Note that the strings are stored twice.
38 std::map<std::string, ADDRESS> smap;
39 public:
40 SymTab(); // Constructor
41 ~SymTab(); // Destructor
42 void Add(ADDRESS a, char* s); // Add a new entry
43 const char* find(ADDRESS a); // Find an entry by address; NULL if none
44 ADDRESS find(const char* s); // Find an entry by name; NO_ADDRESS if none
45 #if 0
46 char* FindAfter(ADDRESS& dwAddr); // Find entry with >= given value
47 char* FindNext(ADDRESS& dwAddr); // Find next entry (after a Find())
48 int FindIndex(ADDRESS dwAddr); // Find index for entry
49 ADDRESS FindSym(char* pName); // Linear search for addr from name
50 #endif
51 std::map<ADDRESS, std::string>& getAll()
53 return amap;
57 #ifndef NULL
58 #define NULL 0 // Normally in stdio.h, it seems!
59 #endif
61 #endif // __SYMTAB_H__