00001 #ifndef QUERY_HANDLER_CLASS 00002 #define QUERY_HANDLER_CLASS 00003 00004 /*****************************************************************************\ 00005 * * 00006 * Name : query_handler * 00007 * Author : Chris Koeritz * 00008 * * 00009 ******************************************************************************* 00010 * Copyright (c) 2008-$now By Author. This program is free software; you can * 00011 * redistribute it and/or modify it under the terms of the GNU General Public * 00012 * License as published by the Free Software Foundation; either version 2 of * 00013 * the License or (at your option) any later version. This is online at: * 00014 * http://www.fsf.org/copyleft/gpl.html * 00015 * Please send any updates to: fred@gruntose.com * 00016 \*****************************************************************************/ 00017 00018 #include "common.h" 00019 00020 #include <basis/istring.h> 00021 #include <basis/object_base.h> 00022 00023 // forward. 00024 class database_login_info; 00025 class deep_string_array; 00026 class log_base; 00027 00028 const int MAX_DB_STRING = 2048; // maximum length string we handle in tables. 00029 00031 00038 class DB_FREETDS_CLASS_STYLE query_handler 00039 { 00040 public: 00041 query_handler(); 00042 virtual ~query_handler(); 00043 00044 IMPLEMENT_CLASS_NAME("query_handler"); 00045 00046 bool prepare_for_query(const istring &config_file, 00047 database_login_info &persistent_login_info); 00049 00055 bool login_to_database(const database_login_info &cred); 00057 00058 bool use_database(const database_login_info &cred); 00060 00061 DBPROCESS *current_db() { return _global_current_db; } 00063 00066 void show_column_structure(); 00068 00069 bool bind_columns(); 00071 00073 bool process_query(const istring &query, log_base &output); 00075 00078 bool print_row(log_base &output); 00080 00081 bool show_this_row(int row_num, log_base &output); 00083 00084 void show_results(bool verbose, log_base &output); 00086 00091 istring get_bound_string(int index); 00093 int get_bound_int(int index); 00095 00096 private: 00097 DBPROCESS *_global_current_db; 00098 deep_string_array *_bind_strings; 00099 int_array *_bind_ints; 00100 }; 00101 00102 #endif 00103
1.5.1