VSQLite++  0.3
include/sqlite/transaction.hpp
Go to the documentation of this file.
00001 /*##############################################################################
00002  VSQLite++ - virtuosic bytes SQLite3 C++ wrapper
00003 
00004  Copyright (c) 2006-2014 Vinzenz Feenstra vinzenz.feenstra@gmail.com
00005  Copyright (c) 2014 mickey mickey.mouse-1985@libero.it
00006  All rights reserved.
00007 
00008  Redistribution and use in source and binary forms, with or without modification,
00009  are permitted provided that the following conditions are met:
00010 
00011  * Redistributions of source code must retain the above copyright notice,
00012    this list of conditions and the following disclaimer.
00013  * Redistributions in binary form must reproduce the above copyright notice,
00014    this list of conditions and the following disclaimer in the documentation
00015    and/or other materials provided with the distribution.
00016  * Neither the name of virtuosic bytes nor the names of its contributors may
00017    be used to endorse or promote products derived from this software without
00018    specific prior written permission.
00019 
00020  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00021  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00022  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00023  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00024  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00025  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00026  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00027  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00028  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00029  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00030  POSSIBILITY OF SUCH DAMAGE.
00031 
00032 ##############################################################################*/
00033 #ifndef GUARD_SQLITE_TRANSACTION_HPP_INCLUDED
00034 #define GUARD_SQLITE_TRANSACTION_HPP_INCLUDED
00035 
00036 namespace sqlite{
00037     struct connection;
00038 
00052     enum class transaction_type {
00053         undefined,
00054         deferred,
00055         immediate,
00056         exclusive
00057     };
00058 
00062     struct transaction{
00063     public:
00069         transaction(connection & con, transaction_type type = transaction_type::undefined);
00070 
00074         ~transaction();
00075 
00079         void begin(transaction_type type = transaction_type::undefined);
00080 
00084         void end();
00085 
00089         void commit();
00090 
00094         void rollback();
00095 
00100         bool isActive() const { return m_isActive; }
00101     private:
00102         void exec(std::string const &);
00103         connection & m_con;
00104         bool m_isActive; 
00105     };
00106 }
00107 
00108 #endif //GUARD_SQLITE_TRANSACTION_HPP_INCLUDED
00109 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends