Webmaster  |  Imprint 
C++ Server Pages
Main  |  License  |  Documentation  |  Download 

/home/tommi/tntdb/include/tntdb/bits/connection.h

00001 /* 
00002  * Copyright (C) 2005 Tommi Maekitalo
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00017  */
00018 
00019 #ifndef TNTDB_BITS_CONNECTION_H
00020 #define TNTDB_BITS_CONNECTION_H
00021 
00022 #include <string>
00023 #include <cxxtools/smartptr.h>
00024 #include <tntdb/iface/iconnection.h>
00025 #include <tntdb/bits/statement.h>
00026 
00027 namespace tntdb
00028 {
00029   class Result;
00030   class Row;
00031   class Value;
00032   class Statement;
00033 
00056   class Connection
00057   {
00058     public:
00059       typedef unsigned size_type;
00060 
00061     private:
00062       cxxtools::SmartPtr<IConnection> conn;
00063 
00064     public:
00068       Connection() { }
00072       Connection(IConnection* conn_)
00073         : conn(conn_)
00074         { }
00075 
00080       void close()
00081         { conn = 0; }
00082 
00087       void beginTransaction();
00091       void commitTransaction();
00095       void rollbackTransaction();
00096 
00104       size_type execute(const std::string& query);
00109       Result select(const std::string& query);
00115       Row selectRow(const std::string& query);
00121       Value selectValue(const std::string& query);
00125       Statement prepare(const std::string& query);
00131       Statement prepareCached(const std::string& query);
00132 
00136       void clearStatementCache()         { conn->clearStatementCache(); }
00137 
00141       bool ping()                        { return conn->ping(); }
00142 
00146       bool operator!() const             { return !conn; }
00150       const IConnection* getImpl() const { return &*conn; }
00151   };
00152 }
00153 
00154 #endif // TNTDB_BITS_CONNECTION_H
00155 
Copyright © 2008 The Tntnet Development Team
Tntnet 1.6