abi.cpp

Go to the documentation of this file.
00001 
00012 #include "abi.h"
00013 #include "op_abi.h"
00014 #include "odb.h"
00015 #include "op_sample_file.h"
00016 
00017 #include <iostream>
00018 #include <cassert>
00019 
00020 using namespace std;
00021 
00022 typedef map<string, int> abi_map;
00023 typedef abi_map::const_iterator abi_iter;
00024 
00025 abi_exception::abi_exception(string const d) : desc(d) {}
00026 
00027 
00028 abi::abi()
00029 {
00030     op_abi_entry const * entry = get_abi();
00031     for ( ; entry->name != 0; ++entry)
00032         slots[entry->name] = entry->offset;
00033 
00034     slots["little_endian"] = op_little_endian();
00035 }
00036 
00037 
00038 int abi::need(string const key) const throw (abi_exception)
00039 {
00040     if (slots.find(key) != slots.end())
00041         return slots.find(key)->second;
00042     else
00043         throw abi_exception(string("missing ABI key: ") + key);
00044 }
00045 
00046 
00047 bool abi::operator==(abi const & other) const
00048 {
00049     return slots == other.slots;
00050 }
00051 
00052 
00053 ostream & operator<<(ostream & o, abi const & abi)
00054 {
00055     abi_iter i = abi.slots.begin();
00056     abi_iter e = abi.slots.end();
00057 
00058     for (; i != e; ++i)
00059         o << i->first << " " << i->second << endl;
00060 
00061     return o;
00062 }
00063 
00064 
00065 istream & operator>>(istream & i, abi & abi)
00066 {
00067     string key;
00068     int val;
00069     abi.slots.clear();
00070 
00071     while(i >> key >> val)
00072         abi.slots[key] = val;
00073 
00074     return i;
00075 }

Generated on 8 Nov 2012 for Oprofile by  doxygen 1.6.1