Used a more uniform of logging and added a commandline parser.
[UnsignedByte.git] / src / DAL / Statements.h
blobe5aeaa2a1c7a2c4c5c338babf3e8bcc9ede89fe9
1 /***************************************************************************
2 * Copyright (C) 2008 by Sverre Rabbelier *
3 * sverre@rabbelier.nl *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #pragma once
23 /**
24 * @file Statements.h
25 * This file contains the Statements class.
27 * @see Statements
28 */
30 #include "Types.h"
32 /**
33 * This is a bucket class for prepared sqlite3 statements.
34 */
35 class Statements
37 public:
38 /** Creates an empty statements bucket. */
39 Statements();
41 /** Destructor, a noop. */
42 ~Statements();
44 /** Returns the prepared statement to erase an entry from this table. */
45 sqlite3_stmt* getErase() const;
47 /** Returns the prepared statement to insert an entry into this table. */
48 sqlite3_stmt* getInsert() const;
50 /** Returns the prepared statement to update an entry from this table. */
51 sqlite3_stmt* getUpdate() const;
53 /** Returns the prepared statement to select an entry from this table. */
54 sqlite3_stmt* getSelect() const;
56 /** Returns the prepared statement to look up an entry from this table on the specified field. */
57 sqlite3_stmt* getLookup(FieldPtr field);
59 /** Returns the prepared statement to list all entries in a table. */
60 sqlite3_stmt* getList() const;
63 /** Sets the prepared statement to erase an entry from this table. */
64 void setErase(sqlite3_stmt* erase);
66 /** Sets the prepared statement to insert an entry into this table. */
67 void setInsert(sqlite3_stmt* insert);
69 /** Sets the prepared statement to update an entry in this table. */
70 void setUpdate(sqlite3_stmt* update);
72 /** Sets the prepared statement to select an entry from this table. */
73 void setSelect(sqlite3_stmt* select);
75 /** Sets the prepared statement to look up an entry from this table on the specified field. */
76 void setLookup(FieldPtr field, sqlite3_stmt* lookup);
78 /** Sets the prepared statement to list all entries in a table. */
79 void setList(sqlite3_stmt* list);
81 /** Commit the changes to the database (finalize all prepared statements). */
82 void commit();
84 private:
85 typedef std::map<Field*, sqlite3_stmt*> fieldmap; /**< A type of a map containing the SQL for each field's lookup*/
87 sqlite3_stmt* m_insert; /**< The prepared statement to insert an entry into this table. */
88 sqlite3_stmt* m_erase; /**< The prepared statement to erase an entry from this table. */
89 sqlite3_stmt* m_update; /**< The prepared statement to update an entry in this table. */
90 sqlite3_stmt* m_select; /**< The prepared statement to select an entry from this table. */
91 fieldmap m_lookup; /**< The map containing the prepared statement for each field's lookup. */
92 sqlite3_stmt* m_list; /**< The prepared statement to list all entries in a table. */
95 typedef SmartPtr<Statements> StatementsPtr; /**< The type of a pointer to a statements bucket. */