libpqxx: errorhandler.hxx Source File

libpqxx 4.0.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

errorhandler.hxx
1 /*-------------------------------------------------------------------------
2 *
3 * FILE
4 * pqxx/errorhandler.hxx
5 *
6 * DESCRIPTION
7 * definition of the pqxx::errorhandler class.
8 * pqxx::errorhandler handlers errors and warnings in a database session.
9 * DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/connection_base instead.
10 *
11 * Copyright (c) 2011, Jeroen T. Vermeulen <jtv@xs4all.nl>
12 *
13 * See COPYING for copyright license. If you did not receive a file called
14 * COPYING with this source code, please notify the distributor of this mistake,
15 * or contact the author.
16 *
17 *-------------------------------------------------------------------------
18 */
19 #ifndef PQXX_H_ERRORHANDLER
20 #define PQXX_H_ERRORHANDLER
21
22 #include "pqxx/compiler-public.hxx"
23 #include "pqxx/compiler-internal-pre.hxx"
24
25 #include <functional>
26
27
28 namespace pqxx
29 {
30 class connection_base;
31
32 namespace internal
33 {
34 namespace gate
35 {
36 class errorhandler_connection_base;
37 }
38 }
39
45
46
57 class PQXX_LIBEXPORT errorhandler :
58 public PGSTD::unary_function<const char[], bool>
59 {
60 public:
61 explicit errorhandler(connection_base &);
62 virtual ~errorhandler();
63
65
69 virtual bool operator()(const char msg[]) throw () =0;
70
71 private:
72 connection_base *m_home;
73
74 friend class internal::gate::errorhandler_connection_base;
75 void unregister() throw ();
76
77 // Not allowed:
78 errorhandler();
79 errorhandler(const errorhandler &);
80 errorhandler &operator=(const errorhandler &);
81 };
82
83
85 class quiet_errorhandler : public errorhandler
86 {
87 public:
88 quiet_errorhandler(connection_base &conn) : errorhandler(conn) {}
89
90 virtual bool operator()(const char[]) throw () { return false; }
91 };
92
97 } // namespace pqxx
98
99 #include "pqxx/compiler-internal-post.hxx"
100
101 #endif