⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dataset.cpp

📁 这是一个银行系统的管理软件
💻 CPP
字号:
/**********************************************************************************
*                                                                                 *
*  Henry's DataBase Toolkit for C++ (Based on Dragon Project)                     *
*  Copyright (c) 2004 by Henry. All rights reserved.                              *
*                                                                                 *
*  Permission to use, copy, modify, and distribute this software for any purpose  *
*  is hereby granted without fee, provided that this copyright and permissions    *
*  notice appear in all copies and derivatives, and that no charge may be made    *
*  for the software and its documentation except to cover cost of distribution.   *
*                                                                                 *
*  This software is provided "as is" without express or implied warranty.         *
*                                                                                 *
**********************************************************************************/

/*
*  Description:
*
*    All common functions here.
*
*  Notes:
*
*    This code has been written to conform to standard C++ and STL. It has been
*    compiled successfully using Visual C++ 7.0.
*/

#include <vector>
#include <string>
#include "dataSet.h"
using namespace dragon;

DataSet::DataSet()
{

}

DataSet::DataSet(string file)
{
	Delimited_file temp(file, "\t");
	dataSource = temp;
	moveFirst();
}

void DataSet::transact()
{
	dataSource.begin_transaction();
}

void DataSet::commit()
{
	dataSource.commit();
}

void DataSet::update()
{
	dataSource.update_row(dataRow, getRowId());
}

size_t DataSet::getRowCount()
{
	return dataSource.row_total_count();
}

size_t DataSet::getRowId()
{
		return dataSource.current_row_no();
}

bool DataSet::Eof()
{
	return (dataSource.is_eof());
}

bool DataSet::Bof()
{
	return (dataSource.is_bof());
}

bool DataSet::moveTo(size_t row)
{
	if(dataSource.read_row(dataRow, row))
	{
		dataSource.prior();
		return true;
	}
	else
	{
		return false;
	}
}

bool DataSet::moveNext()
{
	if(Eof()) return false;
	moveTo(getRowId() + 1);
	return true;
}

bool DataSet::movePrev()
{
	if(Bof()) return false;
	moveTo(getRowId() - 1);
	return true;
}

bool DataSet::moveFirst()
{
	return moveTo(1);
}

bool DataSet::moveLast()
{
	return moveTo(getRowCount());
}

bool DataSet::query(size_t column, string value)
{
	bool res = dataSource.read_row(dataRow, column + 1, value);
	if(res)
		dataSource.prior();
	return res;
}

void DataSet::append(vector<string> vec)
{
	if(dataSource.row_total_count() <= 0)
		dataSource.initial_col_headers(vec);
	dataSource.append_row(vec);
	dataRow = vec;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -