Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

db_command.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2005 The ClanLib Team
00004 **
00005 **  This software is provided 'as-is', without any express or implied
00006 **  warranty.  In no event will the authors be held liable for any damages
00007 **  arising from the use of this software.
00008 **
00009 **  Permission is granted to anyone to use this software for any purpose,
00010 **  including commercial applications, and to alter it and redistribute it
00011 **  freely, subject to the following restrictions:
00012 **
00013 **  1. The origin of this software must not be misrepresented; you must not
00014 **     claim that you wrote the original software. If you use this software
00015 **     in a product, an acknowledgment in the product documentation would be
00016 **     appreciated but is not required.
00017 **  2. Altered source versions must be plainly marked as such, and must not be
00018 **     misrepresented as being the original software.
00019 **  3. This notice may not be removed or altered from any source distribution.
00020 **
00021 **  Note: Some of the libraries ClanLib link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Magnus Norddahl
00027 */
00028 
00029 #ifndef header_db_command
00030 #define header_db_command
00031 
00032 #include "db_return_value.h"
00033 
00034 class CL_ByteArray;
00035 class CL_DBConnection;
00036 struct sqlite3_stmt;
00037 
00038 class CL_DBCommand
00039 {
00041 public:
00042         CL_DBCommand(CL_DBConnection *database);
00043 
00044         CL_DBCommand(const CL_String &sql_statement, CL_DBConnection *database);
00045         
00046         ~CL_DBCommand();
00047         
00049 public:
00050         int get_last_insert_rowid() const;
00051 
00052         int get_columns() const;
00053         
00054         const char *get_name(int column) const;
00055 
00056         int get_index(const char *name) const;
00057 
00058         int get_index(const CL_String &name) const;
00059 
00060         const char *get_decltype(int column) const;
00061 
00062         const char *get_decltype(const char *name) const;
00063 
00064         CL_ByteArray get_blob(int column) const;
00065 
00066         CL_ByteArray get_blob(const char *name) const;
00067 
00068         void get_blob(int column, CL_ByteArray &array) const;
00069 
00070         void get_blob(const char *name, CL_ByteArray &array) const;
00071 
00072         const void *get_blob_raw(int column) const;
00073 
00074         const void *get_blob_raw(const char *name) const;
00075 
00076         int get_blob_size(int column) const;
00077 
00078         int get_blob_size(const char *name) const;
00079 
00080         double get_double(int column) const;
00081 
00082         double get_double(const char *name) const;
00083 
00084         int get_int(int column) const;
00085 
00086         int get_int(const char *name) const;
00087 
00088         const char *get_text(int column) const;
00089 
00090         const char *get_text(const char *name) const;
00091         
00092         CL_DBReturnValue operator[](int column) const;
00093         
00094         CL_DBReturnValue operator[](const char *name) const;
00095         
00096         CL_DBReturnValue operator[](const CL_String &name) const;
00097 
00098         int get_param_column(const char *name) const;
00099 
00101 public:
00102         void compile(const CL_String &sql_statement);
00103         
00104         void compile(const char *sql_statement);
00105 
00106         void compilef(const char *sql_statement, ...);
00107 
00108         void set_param_double(int column, double value);
00109 
00110         void set_param_double(const char *column_name, double value);
00111 
00112         void set_param_int(int column, int value);
00113 
00114         void set_param_int(const char *column_name, int value);
00115 
00116         void set_param_blob(int column, const CL_ByteArray &blob);
00117 
00118         void set_param_blob(const char *column_name, const CL_ByteArray &blob);
00119 
00120         void set_param_text(int column, const char *text);
00121 
00122         void set_param_text(const char *column_name, const char *text);
00123 
00124         bool step();
00125         
00126         void reset();
00127 
00129 private:
00130         CL_DBConnection *db;
00131         
00132         sqlite3_stmt *vm;
00133 
00134         int last_insert_rowid;
00135 };
00136 
00137 #endif

Generated on Sat Feb 19 22:51:15 2005 for npcore by  doxygen 1.4.1