table类--初步修改

#ifndef TABLE_HPP
#define TABLE_HPP
#include <vector>
#include <map>
#include <string>
#include "connection.hpp"

namespace sqlpp
{  
  class Table
  {
  public:
    typedef std::vector<std::string> field_list;
    typedef std::map<int, std::string> row_digit;
    typedef std::map<std::string, std::string> row_string;
    typedef row_string row;
    typedef std::vector<row_digit> rows_digit;
    typedef std::vector<row> rows_string;
    typedef rows_string rows;

    Table(const std::string& cmd, Connection& conn)throw();
    Table(Connection& conn)throw();
    virtual ~Table();
    
    void download(const std::string& cmd)throw(sqlerror);
    void download(void) throw(sqlerror);

    void online_start(row_digit& row)throw(sqlerror);
    void online_next(row_digit& row)throw(sqlerror);
    bool online_is_eof(void)throw();

    template<typename row_type>
    std::vector<row_type>& get_rows(void)throw();

    field_list&  get_fields(void)throw();
    const std::string& get_create_cmd(void)const throw();
    const std::vector<std::string>& get_update_cmds(void)const throw();
    
  protected:
  private:
    const Table& operator=(const Table& rh);
    Table(const Table& rh);

    void trans_to_digit(void)throw();//trans row index to digit
    void trans_to_string(void)throw();//trans row index to string
    //create,modify,update table sql cmd list;
    std::vector<std::string> _update_cmds;
    std::vector<row_digit> _rows;
    std::vector<row_string> _rows_string;
    field_list _fields;
    std::string _create_cmd;
    bool _is_row_digit;

    //for online assess
    unsigned int _num_fields;
    MYSQL_RES* _ptr_result;
    Connection& _conn;
  };
  /*
    must this write.or g++ report error
  */  
  template<typename row_type>
  inline std::vector<row_type>& Table::get_rows(void)throw()
  {
  }
  template <>
  inline Table::rows_digit& Table::get_rows<Table::row_digit>(void)throw()
  {
    if (!_is_row_digit)//now is string
      {
    trans_to_digit();      
      }
    return _rows;  
  }

  template <>
  inline Table::rows& Table::get_rows<Table::row>(void)throw()
  {
    if (_is_row_digit)//now is digit
      {
    trans_to_string();
      }
    return _rows_string;
  }
};
#endif

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值