libpqxx 4.0
errorhandler.hxx
00001 /*-------------------------------------------------------------------------
00002  *
00003  *   FILE
00004  *      pqxx/errorhandler.hxx
00005  *
00006  *   DESCRIPTION
00007  *      definition of the pqxx::errorhandler class.
00008  *   pqxx::errorhandler handlers errors and warnings in a database session.
00009  *   DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/connection_base instead.
00010  *
00011  * Copyright (c) 2011, Jeroen T. Vermeulen <jtv@xs4all.nl>
00012  *
00013  * See COPYING for copyright license.  If you did not receive a file called
00014  * COPYING with this source code, please notify the distributor of this mistake,
00015  * or contact the author.
00016  *
00017  *-------------------------------------------------------------------------
00018  */
00019 #ifndef PQXX_H_ERRORHANDLER
00020 #define PQXX_H_ERRORHANDLER
00021 
00022 #include "pqxx/compiler-public.hxx"
00023 #include "pqxx/compiler-internal-pre.hxx"
00024 
00025 #include <functional>
00026 
00027 
00028 namespace pqxx
00029 {
00030 class connection_base;
00031 
00032 namespace internal
00033 {
00034 namespace gate
00035 {
00036 class errorhandler_connection_base;
00037 }
00038 }
00039 
00045 
00046 
00057 class PQXX_LIBEXPORT errorhandler :
00058         public PGSTD::unary_function<const char[], bool>
00059 {
00060 public:
00061   explicit errorhandler(connection_base &);
00062   virtual ~errorhandler();
00063 
00065 
00069   virtual bool operator()(const char msg[]) throw () =0;
00070 
00071 private:
00072   connection_base *m_home;
00073 
00074   friend class internal::gate::errorhandler_connection_base;
00075   void unregister() throw ();
00076 
00077   // Not allowed:
00078   errorhandler();
00079   errorhandler(const errorhandler &);
00080   errorhandler &operator=(const errorhandler &);
00081 };
00082 
00083 
00085 class quiet_errorhandler : public errorhandler
00086 {
00087 public:
00088   quiet_errorhandler(connection_base &conn) : errorhandler(conn) {}
00089 
00090   virtual bool operator()(const char[]) throw () { return false; }
00091 };
00092 
00097 } // namespace pqxx
00098 
00099 #include "pqxx/compiler-internal-post.hxx"
00100 
00101 #endif