Added count functionality in SavableManager.
[UnsignedByte.git] / src / DAL / StatementStrings.h
blob8f86f5ba1b596371b071dbe71f19ea19a1f66221
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 StatementStrings.h
25 * @brief This file contains the StatementStrings class.
27 * @see StatementStrings
28 */
30 #include "Types.h"
32 /**
33 * This class is a bucket that contains the SQL statements for a certain action on a table.
34 */
35 class StatementStrings
37 public:
38 /** Creates an empty statements bucket. */
39 StatementStrings() { }
41 /** Destructor, a noop. */
42 ~StatementStrings() { }
44 /** Returns the SQL to erase an entry from this table. */
45 cstring getErase() const {return m_erase;}
47 /** Returns the SQL to insert an entry into this table. */
48 cstring getInsert() const {return m_insert;}
50 /** Returns the SQL to update an entry from this table. */
51 cstring getUpdate() const {return m_update;}
53 /** Returns the SQL to select an entry from this table. */
54 cstring getSelect() const {return m_select;}
56 /** Returns the SQL to look up an entry from this table on the specified field. */
57 cstring getLookup(FieldPtr field) {return m_lookup[field.get()];}
59 /** Returns the SQL to list all entries in a table. */
60 cstring getList() const {return m_list;}
63 /** Sets the SQL to erase an entry from this table. */
64 void setErase(cstring erase) { m_erase = erase; }
66 /** Sets the SQL to insert an entry into this table. */
67 void setInsert(cstring insert) { m_insert = insert; }
69 /** Sets the SQL to update an entry in this table. */
70 void setUpdate(cstring update) { m_update = update; }
72 /** Sets the SQL to select an entry from this table. */
73 void setSelect(cstring select) { m_select = select; }
75 /** Sets the SQL to look up an entry from this table on the specified field. */
76 void setLookup(FieldPtr field, cstring lookup) { Assert(field); m_lookup[field.get()] = lookup; }
78 /** Sets the SQL to list all entries in a table. */
79 void setList(cstring list) { m_list = list; }
81 private:
82 typedef std::map<Field*, std::string> fieldmap; /**< A type of a map containing the SQL for each field's lookup*/
84 std::string m_insert; /**< The SQL to insert an entry into this table. */
85 std::string m_erase; /**< The SQL to erase an entry from this table. */
86 std::string m_update; /**< The SQL to update an entry in this table. */
87 std::string m_select; /**< The SQL to select an entry from this table. */
88 fieldmap m_lookup; /**< The map containing the SQL for each field's lookup. */
89 std::string m_list; /**< The SQL to list all entries in a table. */
92 typedef SmartPtr<StatementStrings> StatementStringsPtr; /**< The type of a pointer to a statements bucket. */