~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/error_message.cc

  • Committer: Monty Taylor
  • Date: 2010-11-25 01:53:19 UTC
  • mto: (1953.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1955.
  • Revision ID: mordred@inaugust.com-20101125015319-ia85msn25uemopgc
Re-enabled -Wformat and then cleaned up the carnage.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include <algorithm>
27
27
#include <vector>
28
28
 
 
29
using namespace std;
 
30
 
29
31
namespace drizzled
30
32
{
31
33
 
32
 
std::vector<plugin::ErrorMessage *> all_errmsg_handler;
 
34
vector<plugin::ErrorMessage *> all_errmsg_handler;
33
35
bool errmsg_has= false;
34
36
 
35
37
 
42
44
 
43
45
void plugin::ErrorMessage::removePlugin(plugin::ErrorMessage *handler)
44
46
{
45
 
  all_errmsg_handler.erase(std::find(all_errmsg_handler.begin(),
46
 
                                     all_errmsg_handler.end(), handler));
 
47
  all_errmsg_handler.erase(find(all_errmsg_handler.begin(),
 
48
                                all_errmsg_handler.end(), handler));
47
49
}
48
50
 
49
51
 
50
 
class Print : public std::unary_function<plugin::ErrorMessage *, bool>
 
52
class Print : public unary_function<plugin::ErrorMessage *, bool>
51
53
{
52
54
  Session *session;
53
55
  int priority;
54
56
  const char *format;
55
57
  va_list ap;
56
 
 
57
58
public:
58
59
  Print(Session *session_arg, int priority_arg,
59
 
        const char *format_arg, va_list ap_arg) : 
60
 
    std::unary_function<plugin::ErrorMessage *, bool>(),
61
 
    session(session_arg),
62
 
    priority(priority_arg), format(format_arg)
63
 
  {
64
 
    va_copy(ap, ap_arg);
65
 
  }
 
60
        const char *format_arg, va_list ap_arg)
 
61
    : unary_function<plugin::ErrorMessage *, bool>(), session(session_arg),
 
62
      priority(priority_arg), format(format_arg)
 
63
    {
 
64
      va_copy(ap, ap_arg);
 
65
    }
66
66
 
67
67
  ~Print()  { va_end(ap); }
68
68
 
106
106
  }
107
107
 
108
108
  /* Use find_if instead of foreach so that we can collect return codes */
109
 
  std::vector<plugin::ErrorMessage *>::iterator iter=
110
 
    std::find_if(all_errmsg_handler.begin(), all_errmsg_handler.end(),
111
 
                 Print(session, priority, format, ap)); 
 
109
  vector<plugin::ErrorMessage *>::iterator iter=
 
110
    find_if(all_errmsg_handler.begin(), all_errmsg_handler.end(),
 
111
            Print(session, priority, format, ap)); 
112
112
  /* If iter is == end() here, that means that all of the plugins returned
113
113
   * false, which in this case means they all succeeded. Since we want to 
114
114
   * return false on success, we return the value of the two being !=