~drizzle-trunk/drizzle/development

390.1.2 by Monty Taylor
Fixed copyright headers in drizzled/
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
212.5.42 by Monty Taylor
Ding dong include is dead.
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
1999.6.1 by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
212.5.42 by Monty Taylor
Ding dong include is dead.
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
390.1.2 by Monty Taylor
Fixed copyright headers in drizzled/
8
 *  the Free Software Foundation; version 2 of the License.
212.5.42 by Monty Taylor
Ding dong include is dead.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License
16
 *  along with this program; if not, write to the Free Software
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 */
19
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
20
2234 by Brian Aker
Mass removal of ifdef/endif in favor of pragma once.
21
#pragma once
212.5.42 by Monty Taylor
Ding dong include is dead.
22
1271.7.9 by Tim Penhey
Almost there.
23
#include <string>
1996.3.2 by Monty Taylor
Add API for getting at ErrorMap information.
24
#include <boost/unordered_map.hpp>
25
2252.1.1 by Olaf van der Spek
Common fwd
26
#include <drizzled/common_fwd.h>
2187.2.3 by Brian Aker
This cleans up the the error message system by providing for the ability to
27
#include <drizzled/definitions.h>
2440.4.3 by Brian Aker
Update naming convention for priority.
28
#include <drizzled/error/priority_t.h>
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
29
#include <drizzled/error_t.h>
30
#include <drizzled/identifier.h>
31
#include <drizzled/visibility.h>
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
32
2241.3.15 by Olaf van der Spek
Refactor
33
namespace drizzled {
34
1271.5.1 by Tim Penhey
Move the bits from my_error.h and my_error.cc into error.h and error.cc.
35
/* Max width of screen (for error messages) */
36
#define SC_MAXWIDTH 256
37
#define ERRMSGSIZE	(SC_MAXWIDTH)	/* Max length of a error message */
38
#define MY_FILE_ERROR	((size_t) -1)
39
#define ME_FATALERROR   1024    /* Fatal statement error */
40
1996.3.2 by Monty Taylor
Add API for getting at ErrorMap information.
41
/*
42
 * Provides a mapping from the error enum values to std::strings.
43
 */
2385.3.16 by Olaf van der Spek
Remove unnecessary constructors and destructors
44
class ErrorMap : boost::noncopyable
1996.3.2 by Monty Taylor
Add API for getting at ErrorMap information.
45
{
46
public:
47
  typedef std::pair<std::string, std::string> value_type;
2241.3.15 by Olaf van der Spek
Refactor
48
  typedef boost::unordered_map<error_t, value_type> ErrorMessageMap;
1996.3.2 by Monty Taylor
Add API for getting at ErrorMap information.
49
50
  ErrorMap();
51
52
  // Insert the message for the error.  If the error already has an existing
53
  // mapping, an error is logged, but the function continues.
2241.3.15 by Olaf van der Spek
Refactor
54
  void add(error_t error_num, const std::string &error_name, const std::string &message);
1996.3.2 by Monty Taylor
Add API for getting at ErrorMap information.
55
2246.4.2 by Olaf van der Spek
Refactor Identifier::getSQLPath()
56
  const std::string* find(error_t error_num) const;
1996.3.2 by Monty Taylor
Add API for getting at ErrorMap information.
57
58
  static const ErrorMessageMap& get_error_message_map();
59
private:
60
  ErrorMessageMap mapping_;
61
};
62
2241.3.15 by Olaf van der Spek
Refactor
63
typedef void (*error_handler_func)(error_t my_err,
1271.5.7 by Monty Taylor
Merged up with trunk.
64
                                   const char *str,
65
                                   myf MyFlags);
1271.5.1 by Tim Penhey
Move the bits from my_error.h and my_error.cc into error.h and error.cc.
66
extern error_handler_func error_handler_hook;
1241.9.57 by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined.
67
1271.7.9 by Tim Penhey
Almost there.
68
// TODO: kill this method. Too much to do with this branch.
69
// This is called through the ER(x) macro.
2241.3.15 by Olaf van der Spek
Refactor
70
DRIZZLED_API const char * error_message(error_t err_index);
202.3.6 by Monty Taylor
First pass at gettexizing the error messages.
71
1271.7.9 by Tim Penhey
Almost there.
72
// Adds the message to the global error dictionary.
2241.3.15 by Olaf van der Spek
Refactor
73
void add_error_message(error_t error_code, const std::string &error_name,
1996.3.1 by Monty Taylor
Add error code name into ErrorMap.
74
                       const std::string& message);
75
#define DRIZZLE_ADD_ERROR_MESSAGE(code, msg) add_error_message(code, STRINGIFY_ARG(code), msg)
1271.5.1 by Tim Penhey
Move the bits from my_error.h and my_error.cc into error.h and error.cc.
76
2159.2.8 by Brian Aker
Merge in fixes for error messages with privs.
77
namespace error {
78
2241.3.15 by Olaf van der Spek
Refactor
79
void access(const identifier::User&);
80
void access(const identifier::User&, const identifier::Schema&);
81
void access(const identifier::User&, const identifier::Table&);
2159.2.8 by Brian Aker
Merge in fixes for error messages with privs.
82
2187.2.3 by Brian Aker
This cleans up the the error message system by providing for the ability to
83
const std::string &verbose_string();
2440.4.3 by Brian Aker
Update naming convention for priority.
84
error::priority_t &verbosity();
2187.2.3 by Brian Aker
This cleans up the the error message system by providing for the ability to
85
void check_verbosity(const std::string &arg);
86
2159.2.8 by Brian Aker
Merge in fixes for error messages with privs.
87
} // namespace error
88
89
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
90
DRIZZLED_API void my_error(const std::string &ref, error_t nr, myf MyFlags= MYF(0));
2241.3.15 by Olaf van der Spek
Refactor
91
DRIZZLED_API void my_error(error_t nr, const Identifier&, myf MyFlags= MYF(0));
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
92
DRIZZLED_API void my_error(error_t nr);
93
DRIZZLED_API void my_error(error_t nr, myf MyFlags, ...);
2241.3.15 by Olaf van der Spek
Refactor
94
void my_message(error_t my_err, const char *str, myf MyFlags);
95
void my_printf_error(error_t my_err, const char *format,
1271.5.1 by Tim Penhey
Move the bits from my_error.h and my_error.cc into error.h and error.cc.
96
                     myf MyFlags, ...)
97
                     __attribute__((format(printf, 2, 4)));
98
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
99
} /* namespace drizzled */
1271.7.4 by Tim Penhey
Another incremental commit.
100