00001
00002 #if !defined(__INC_MODRESULTSET_H)
00003 #define __INC_MODRESULTSET_H
00004
00005 #include <vector>
00006
00007 #include <gql++/result-set.h>
00008 #include <gql++/result-set-metadata.h>
00009
00010 namespace GQL
00011 {
00012
00013 class ModResultSetMetaData : public ResultSetMetaData
00014 {
00015 public:
00016 ModResultSetMetaData(int cols);
00017 virtual ~ModResultSetMetaData();
00018
00019 virtual int column_count() const { return ncols_; }
00020 virtual std::string get_column_label(int i) const {
00021 return col_labels_[i].empty() ? col_names_[i] : col_labels_[i];
00022 }
00023 virtual std::string get_column_name(int i) const {
00024 return col_names_[i];
00025 }
00026 virtual const SQLType& get_column_type(int i) const {
00027 return col_types_[i];
00028 }
00029
00030 void set_column_label(int i, const std::string& s);
00031 void set_column_name(int i, const std::string& s);
00032 void set_column_type(int i, const SQLType& type);
00033 void set_column_info(int i, const SQLType& type,
00034 const std::string& name,
00035 const std::string& label = std::string());
00036 private:
00037 int ncols_;
00038 std::string *col_labels_;
00039 std::string *col_names_;
00040 SQLType *col_types_;
00041 };
00042
00043 class ModResultSet : public ResultSet
00044 {
00045 public:
00046 ModResultSet(Connection *conn, int cols);
00047 virtual ~ModResultSet();
00048
00049 virtual bool next() throw(SQLException);
00050
00051 virtual SQLObject *get(int col, SQLObject *obj) const throw(SQLException);
00052 virtual const ResultSetMetaData *get_meta_data() const;
00053
00061 void append(const char *const*tuple);
00062
00068 void append(std::string **tuple);
00069 void set_meta_data(ResultSetMetaData *metadata);
00070 private:
00071 int cols_;
00072 int rowno_;
00073 std::vector<std::string **> rows_;
00074 ResultSetMetaData *metadata_;
00075 };
00076
00077 }
00078
00079 #endif