summaryrefslogtreecommitdiff
path: root/other/Kermit/lib/SystemMap.cpp
blob: 03e2fb4c6c5f9c7f9a53940c52095c360e3d1c34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
 * SystemMap.cpp:
 * written by palmers / teso
 */
#include <SystemMap.hpp>


  SystemMap::SystemMap (string a)
  {
    string		tmp;
    unsigned int	num = 0;
    ifstream		f;

    f.open (a.c_str ());
    if (!f.is_open ())
      {
	cerr << "Error opening file \"" << a << "\"!" << endl;
	abort ();
      }

    f.setf (ios::skipws);
    f.setf (ios::hex, ios::basefield);

    while (!f.eof ())
      {
	f >> num;
	f >> tmp;
	f >> tmp;

        add_map.insert (add_map.end (), bla_val (tmp, num));       
      }
    f.close ();
  }


  SystemMap::SystemMap ()
  {
  }


  SystemMap::~SystemMap ()
  {
    add_map.clear ();
  }


  bool SystemMap::contains (string a)
  {
    if (add_map.find (a) == add_map.end ())
      return false;
    return true;
  }


  void SystemMap::add (string a, unsigned int x)
  {
    add_map.insert (add_map.end (), bla_val (a, x));       
  }


  unsigned int SystemMap::operator[] (string a)
  {
    if (add_map.find (a) == add_map.end ())
      return 0;
    return add_map[a];
  }