#include "subr.hh"
#include <stdexcept>
-#include <cstring>
-#include <iostream>
-#include <sstream>
#include <list>
#include <map>
#include <set>
// One DWARF object file.
class dwarf
{
- private:
- template<const char *lookup_known (int)>
- static inline std::string known_name (int code)
- {
- const char *known = lookup_known (code);
- if (known != NULL)
- return std::string (known);
- std::ostringstream os;
- os.setf(std::ios::hex, std::ios::basefield);
- os << code;
- return os.str ();
- }
-
- template<typename string>
- struct name_equal : public std::binary_function<const char *, string, bool>
- {
- bool operator () (const char *me, const string &you)
- {
- return you == me;
- }
- };
-
public:
static const char *known_attribute (int);
static const char *known_tag (int);
static inline std::string tag_name (int code)
{
- return known_name<known_tag> (code);
+ return subr::known_name<known_tag> (code);
}
template<typename attribute>
static inline std::string attribute_name (const unsigned int code)
{
- return known_name<known_attribute> (code);
+ return subr::known_name<known_attribute> (code);
}
private:
if (other_size != 0 && other_size != size ())
return false;
}
- return name_equal<typeof (other.name ())> () (name (), other.name ());
+ return subr::name_equal<typeof (other.name ())> () (name (),
+ other.name ());
}
template<typename other_file>
inline bool operator!= (const other_file &other) const
return source_column () == other.source_column ();
case VS_identifier:
- return name_equal<typeof (other.identifier ())> ()
+ return subr::name_equal<typeof (other.identifier ())> ()
(identifier (), other.identifier ());
case VS_string:
- return name_equal<typeof (other.string ())> ()
+ return subr::name_equal<typeof (other.string ())> ()
(string (), other.string ());
case VS_address:
typename table::const_iterator j = other.begin ();
return subr::container_equal
(++i, end (), ++j, other.end (),
- name_equal<typename table::value_type> ());
+ subr::name_equal<typename table::value_type> ());
}
public:
}
};
- // Explicit specialization used inside dwarf::directory_table::operator==.
- template<>
- struct dwarf::name_equal<const char *>
- : public std::binary_function<const char *, const char *, bool>
- {
- bool operator () (const char *me, const char *you)
- {
- return !strcmp (me, you);
- }
- };
-
inline class dwarf::debug_info_entry::raw_children
dwarf::debug_info_entry::raw_children () const
{
#include <iterator>
#include <functional>
+#include <cstring>
+#include <iostream>
+#include <sstream>
namespace elfutils
{
namespace subr
{
+ template<typename string>
+ struct name_equal : public std::binary_function<const char *, string, bool>
+ {
+ inline bool operator () (const char *me, const string &you)
+ {
+ return you == me;
+ }
+ };
+
+ // Explicit specialization.
+ template<>
+ struct name_equal<const char *>
+ : public std::binary_function<const char *, const char *, bool>
+ {
+ bool operator () (const char *me, const char *you)
+ {
+ return !strcmp (me, you);
+ }
+ };
+
+ template<const char *lookup_known (int)>
+ static inline std::string known_name (int code)
+ {
+ const char *known = lookup_known (code);
+ if (known != NULL)
+ return std::string (known);
+ std::ostringstream os;
+ os.setf(std::ios::hex, std::ios::basefield);
+ os << code;
+ return os.str ();
+ }
+
template<typename t1, typename t2>
struct equal_to : public std::binary_function<t1, t2, bool>
{