~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to drizzled/plugin/error_message.cc

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-12-09 06:02:39 UTC
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20101209060239-t0ujftvcvd558yno
Tags: upstream-2010.12.05
ImportĀ upstreamĀ versionĀ 2010.12.05

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
 
 
31
29
namespace drizzled
32
30
{
33
31
 
34
 
vector<plugin::ErrorMessage *> all_errmsg_handler;
 
32
std::vector<plugin::ErrorMessage *> all_errmsg_handler;
35
33
bool errmsg_has= false;
36
34
 
37
35
 
44
42
 
45
43
void plugin::ErrorMessage::removePlugin(plugin::ErrorMessage *handler)
46
44
{
47
 
  all_errmsg_handler.erase(find(all_errmsg_handler.begin(),
48
 
                                all_errmsg_handler.end(), handler));
 
45
  all_errmsg_handler.erase(std::find(all_errmsg_handler.begin(),
 
46
                                     all_errmsg_handler.end(), handler));
49
47
}
50
48
 
51
49
 
52
 
class Print : public unary_function<plugin::ErrorMessage *, bool>
 
50
class Print : public std::unary_function<plugin::ErrorMessage *, bool>
53
51
{
54
52
  Session *session;
55
53
  int priority;
56
54
  const char *format;
57
55
  va_list ap;
 
56
 
58
57
public:
59
58
  Print(Session *session_arg, int priority_arg,
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
 
    }
 
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
  }
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
 
  vector<plugin::ErrorMessage *>::iterator iter=
110
 
    find_if(all_errmsg_handler.begin(), all_errmsg_handler.end(),
111
 
            Print(session, priority, format, ap)); 
 
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)); 
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 !=