MySQL++  3.3.0
Public Member Functions | Protected Member Functions | Friends | List of all members
mysqlpp::OptionalExceptions Class Reference

Interface allowing a class to have optional exceptions. More...

#include <noexceptions.h>

Inheritance diagram for mysqlpp::OptionalExceptions:
Inheritance graph
[legend]

Public Member Functions

 OptionalExceptions (bool e=true)
 Default constructor. More...
 
virtual ~OptionalExceptions ()
 Destroy object.
 
void enable_exceptions () const
 Enable exceptions from the object.
 
void disable_exceptions () const
 Disable exceptions from the object.
 
bool throw_exceptions () const
 Returns true if exceptions are enabled.
 

Protected Member Functions

void set_exceptions (bool e) const
 Sets the exception state to a particular value. More...
 

Friends

class NoExceptions
 Declare NoExceptions to be our friend so it can access our protected functions.
 

Detailed Description

Interface allowing a class to have optional exceptions.

A class derives from this one to acquire a standard interface for disabling exceptions, possibly only temporarily. By default, exceptions are enabled.

Note that all methods are const even though some of them change our internal flag indicating whether exceptions should be thrown. This is justifiable because this is just an interface class, and it changes the behavior of our subclass literally only in exceptional conditions. This Jesuitical interpretation of "const" is required because you may want to disable exceptions on const subclass instances.

If it makes you feel better about this, consider that the real change isn't within the const OptionalExceptions subclass instance. What changes is the code wrapping the method call on that instance that can optionally throw an exception. This outside code is in a better position to say what "const" means than the subclass instance.

Constructor & Destructor Documentation

◆ OptionalExceptions()

mysqlpp::OptionalExceptions::OptionalExceptions ( bool  e = true)
inline

Default constructor.

Parameters
eif true, exceptions are enabled (this is the default)

Member Function Documentation

◆ set_exceptions()

void mysqlpp::OptionalExceptions::set_exceptions ( bool  e) const
inlineprotected

Sets the exception state to a particular value.

This method is protected because it is only intended for use by subclasses' copy constructors and the like.

Referenced by mysqlpp::Connection::copy(), mysqlpp::ResultBase::copy(), and mysqlpp::Query::operator=().


The documentation for this class was generated from the following file: