续--table.cpp

#include "table.hpp"

using namespace sqlpp;

Table::Table(const std::string& create_cmd):_create_cmd(create_cmd),_index_is_string(false)
{
}

Table::~Table()
{
}

std::vector<row_digit>& Table::get_rows(void)throw()
{
  if (_index_is_string)
    {
      trans_to_digit();
    }
  return _rows;
}

std::vector<row_string>& Table::get_rows_index_string(void)throw()
{
  if (!_index_is_string)
  {
    trans_to_string();
  }
  return _rows_string;
}

field_list& Table::get_fields(void) throw()
{
  return _fields;
}

const std::string& Table::get_create_cmd(void)const throw()
{
  return _create_cmd;
}

const std::vector<std::string>& Table::get_update_cmds(void)const throw()
{
  return _update_cmds;
}

void Table::trans_to_digit(void)throw()
{
  _rows.clear();
  _rows.resize(_rows_string.size());

  row_digit row;
  while (!_rows_string.empty())
  {
    for (int k=0; k<_fields.size(); k++)
    {
      row[k] = _rows_string.front()[_fields[k]];
    }
    _rows_string.erase(_rows_string.begin());
    _rows.push_back(row);
  }
}

void Table::trans_to_string(void)throw()
{
  _rows_string.clear();
  //for save time
  _rows_string.resize(_rows.size());
  row_string row;
  //assign a row,delete it,for save space
  while (!_rows.empty())
  {   
    for (int k=0; k<_fields.size(); k++)
    {
      row[_fields[k]] = _rows.front()[k];     
    }
    _rows.erase(_rows.begin());
    _rows_string.push_back(row);
   }
  _index_is_string = true;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值