From: Petr Machata Date: Fri, 27 Aug 2010 16:12:59 +0000 (+0200) Subject: dwarflint: Allow sending checkgroup and checkstack into ostream X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3cf2d06afebe502e85e4ccc466a6c71640b8a12d;p=thirdparty%2Felfutils.git dwarflint: Allow sending checkgroup and checkstack into ostream --- diff --git a/dwarflint/checkdescriptor.cc b/dwarflint/checkdescriptor.cc index 0f1d514d6..5e27e0a3f 100644 --- a/dwarflint/checkdescriptor.cc +++ b/dwarflint/checkdescriptor.cc @@ -49,4 +49,17 @@ checkdescriptor::checkdescriptor (std::string const &desc) groups.erase (groups.begin ()); } - +std::ostream & +operator << (std::ostream &o, checkgroups const &groups) +{ + o << '['; + for (std::vector::const_iterator it = groups.begin (); + it != groups.end (); ++it) + { + if (it != groups.begin ()) + o << ','; + o << *it; + } + o << ']'; + return o; +} diff --git a/dwarflint/checkdescriptor.hh b/dwarflint/checkdescriptor.hh index d04b9e3bf..45e659e27 100644 --- a/dwarflint/checkdescriptor.hh +++ b/dwarflint/checkdescriptor.hh @@ -28,10 +28,20 @@ #include #include +#include + +struct checkgroups + : public std::vector +{ + checkgroups (std::vector const &v) + : std::vector (v) + {} +}; +std::ostream &operator << (std::ostream &o, checkgroups const &groups); struct checkdescriptor { - std::vector groups; + checkgroups groups; std::string const name; checkdescriptor (std::string const &desc); diff --git a/dwarflint/checks.cc b/dwarflint/checks.cc index 2337fb792..5d628ff68 100644 --- a/dwarflint/checks.cc +++ b/dwarflint/checks.cc @@ -45,24 +45,6 @@ reporter::operator () (char const *what, bool ext) std::cout << cd.name << ' ' << what; if (ext) - { - std::cout << " ["; - for (std::vector::const_iterator it = cd.groups.begin (); - it != cd.groups.end (); ++it) - { - if (it != cd.groups.begin ()) - std::cout << ','; - std::cout << *it; - } - std::cout << "] {"; - for (checkstack::const_iterator it = stack.begin (); - it != stack.end (); ++it) - { - if (it != stack.begin ()) - std::cout << ','; - std::cout << (*it)->name; - } - std::cout << "}"; - } + std::cout << ' ' << cd.groups << ' ' << stack; std::cout << std::endl; } diff --git a/dwarflint/dwarflint.cc b/dwarflint/dwarflint.cc index 541f00a5f..20ec0410b 100644 --- a/dwarflint/dwarflint.cc +++ b/dwarflint/dwarflint.cc @@ -33,6 +33,21 @@ #include #include +std::ostream & +operator << (std::ostream &o, checkstack const &stack) +{ + o << "{"; + for (checkstack::const_iterator it = stack.begin (); + it != stack.end (); ++it) + { + if (it != stack.begin ()) + o << ','; + o << (*it)->name; + } + o << "}"; + return o; +} + namespace { int diff --git a/dwarflint/dwarflint.hh b/dwarflint/dwarflint.hh index b464a598e..421703890 100644 --- a/dwarflint/dwarflint.hh +++ b/dwarflint/dwarflint.hh @@ -29,14 +29,17 @@ #include #include #include +#include +#include + #include "../libelf/libelf.h" #include "checks.ii" #include "checkdescriptor.ii" class checkstack : public std::vector -{ -}; +{}; +std::ostream &operator << (std::ostream &o, checkstack const &stack); struct check_rule {