Ejemplo n.º 1
0
int SList::readTransaction(string fname)
{
	ifstream readTransaction(fname);
	if(readTransaction.good())
	{
		queue<string> trans;
		getline(readTransaction,temp); //transaction ID
		trans.push(temp);
		getline(readTransaction,temp); //num jobs
		trans.push(temp);
		stringtoothers(temp,numJobs);
		getline(readTransaction,temp);
		while(numJobs>0)
		{
			numJobs--;
			getline(readTransaction,job); //what job it is
			trans.push(job);
			getline(readTransaction,temp); //since all jobs have at least one line, take in one line first.
			trans.push(temp);
			if(!job.compare("SALE")||!job.compare("RESTOCK"))
			{
				getline(readTransaction,temp);
				trans.push(temp);
			}
			else if(!job.compare("ADD"))
			{
				for(int i=0;i<5;i++)
				{
					getline(readTransaction,temp);
					trans.push(temp);
				}
			}
			getline(readTransaction,temp);
		}
		storeTrans.push(trans);
	
	readTransaction.close();
	storeExistingBatch(0); //need to copy out from existing file
	numT++;
	writeTransaction();
	return 1;
	}
	else
	{
		readTransaction.close();
		return 0;
	}
}
Ejemplo n.º 2
0
Pattern::Pattern(std::string fileName){
	std::ifstream f;
	int sTrans;
	std::string item;
	f.open(fileName.c_str());
	nTransactions = 0;

	while(f.good()){
		// Optimizable
		std::vector<std::string> trans;
		f >> sTrans;
		for (int i = 0; i < sTrans; i++){
			f >> item;
			trans.push_back(item);
		}
		readTransaction(trans);
	}
}