]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Allow sending checkgroup and checkstack into ostream
authorPetr Machata <pmachata@redhat.com>
Fri, 27 Aug 2010 16:12:59 +0000 (18:12 +0200)
committerPetr Machata <pmachata@redhat.com>
Fri, 27 Aug 2010 16:12:59 +0000 (18:12 +0200)
dwarflint/checkdescriptor.cc
dwarflint/checkdescriptor.hh
dwarflint/checks.cc
dwarflint/dwarflint.cc
dwarflint/dwarflint.hh

index 0f1d514d6d8042a9b6a0f64d4ef105810df75420..5e27e0a3f8415b190c00d85c6bb2b12846e8b1fa 100644 (file)
@@ -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<std::string>::const_iterator it = groups.begin ();
+       it != groups.end (); ++it)
+    {
+      if (it != groups.begin ())
+       o << ',';
+      o << *it;
+    }
+  o << ']';
+  return o;
+}
index d04b9e3bf14d05223e7326b79c0fa5fb52efc896..45e659e27c97635a653990e16be9b8136c9cd35f 100644 (file)
 
 #include <vector>
 #include <string>
+#include <iosfwd>
+
+struct checkgroups
+  : public std::vector<std::string>
+{
+  checkgroups (std::vector<std::string> const &v)
+    : std::vector<std::string> (v)
+  {}
+};
+std::ostream &operator << (std::ostream &o, checkgroups const &groups);
 
 struct checkdescriptor
 {
-  std::vector<std::string> groups;
+  checkgroups groups;
   std::string const name;
 
   checkdescriptor (std::string const &desc);
index 2337fb7926f3849f60b80cee5e85da39db67cafd..5d628ff6813cfa05dbc4ee4254bc3c01c23f3b9f 100644 (file)
@@ -45,24 +45,6 @@ reporter::operator () (char const *what, bool ext)
 
   std::cout << cd.name << ' ' << what;
   if (ext)
-    {
-      std::cout << " [";
-      for (std::vector<std::string>::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;
 }
index 541f00a5f721c79a7b60f6e574322def0ee54584..20ec0410b8797e7cb0bb4587c1ddcaf0a98a4a3c 100644 (file)
 #include <stdexcept>
 #include <sstream>
 
+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
index b464a598e529271da6f7d79d38bdd3a2dc6d788d..421703890f335425e1893616b5320ef42eabf62e 100644 (file)
 #include <map>
 #include <vector>
 #include <stdexcept>
+#include <string>
+#include <iosfwd>
+
 #include "../libelf/libelf.h"
 #include "checks.ii"
 #include "checkdescriptor.ii"
 
 class checkstack
   : public std::vector <checkdescriptor const *>
-{
-};
+{};
+std::ostream &operator << (std::ostream &o, checkstack const &stack);
 
 struct check_rule
 {