当前位置: 首页>>代码示例>>C++>>正文


C++ Columns::initiateAsset方法代码示例

本文整理汇总了C++中Columns::initiateAsset方法的典型用法代码示例。如果您正苦于以下问题:C++ Columns::initiateAsset方法的具体用法?C++ Columns::initiateAsset怎么用?C++ Columns::initiateAsset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Columns的用法示例。


在下文中一共展示了Columns::initiateAsset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: detectData

void detectData(const string& dataFile, Asset*& calls, Asset*& puts, const string& writeTo,
		long lastDate, double lastByte){ //function used to detect data if data contains the cp_flag
										 //function returns number of bytes extracted.

	ifstream inFile(dataFile.c_str()); // object for handling file input
	string row;
	stringstream srow;
	getline(inFile,row);
	srow.str(row); //replace old row with new row;
	//used to find out what column I am in, and thus what deque to extract the data to.
	Columns columnHeaders; //instantiate an object of Columns class.

	//find out if we are using a european or american style csv file. Following conditions
	char delimiter = getDelim(row, dataFile);


	columnHeaders.setColNbr(srow, delimiter); //set column numbers
	columnHeaders.checkValid(dataFile); //check if data is valid according to column numbers
	int cpColNbr = columnHeaders.getCpColNbr();
	string callOrPutRow; //used to determine what type of option is contained in row
	int i = 0; //used for collOrPutRow

	if ((calls == NULL)){ // we initialize here the proper options objects to contain our data. This is done only at the beginning of a file.


		vector<Asset**>dummyAssets; dummyAssets.push_back(&calls); dummyAssets.push_back(&puts);//just a dummy assets used for initiateAsset.
		columnHeaders.initiateAsset(dummyAssets, dataFile); //find what the Assets object will point to depending on the rows identity.
		//uses pointer to pointer, so that the copy made automatically is not a copy of our pointer to initialize, but a copy to
		//the pointer to those addresses.

		calls->setExFromByte((double)inFile.tellg());  //skip first line for rest of code as I am starting at beginning of file.
													   //!!!!information has to be set in both objects.
		puts->setExFromByte((double)inFile.tellg());
		calls->setWriteTo(writeTo); //setting folder to write to, using data passed as argument to detectData.
		puts->setWriteTo(writeTo);
	}


	//we first detect what type of options object we are dealing with
	//and save all the data to two single deques of row objects in order to sort columns in parallel.

	bool optionsOrNot = calls->getIsOption();

	////////////////////////////////////////////////////////////////////
	//if Options data was entered, find out what kind of options it was.
	////////////////////////////////////////////////////////////////////
	if (optionsOrNot == true) {

		//Skip to wanted position, after first line if new file, and as of last accessed byte
		//if return file.
		inFile.seekg(calls->getExFromByte(), ios_base::beg);
		double before = time(0);
		while ((inFile.eof() != 1)){ //while I am in the file

			getline(inFile, row); //get next line.
			srow.clear(); //clear eofbit set from last line.
			srow.str(row); //replace old row with new row.

			for(i = 0; i < cpColNbr; ++i)
				getline(srow, callOrPutRow, delimiter);

			srow.seekg(0); //reset row for srow

			if(callOrPutRow.find("C") != string::npos){ //we have a call
				calls->extractRow(srow, delimiter); //row is extracted and put in temporary values
				//line is now completely extracted. Now dealing with file size and multiple files part
				if(calls->fileSizeManagement(lastDate, lastByte, inFile) == true){ //file read status set only for calls.
					puts->setExToDate(calls->getExToDate());
					puts->setExFromByte(calls->getExFromByte());
					break; //break only if member function returned to break, otherwise, do nothing.
				}
				calls->writeCurrValues();
			}
			else{
				puts->extractRow(srow, delimiter); //row is extracted and put in temporary values
				//line is now completely extracted. Now dealing with file size and multiple files part
				if(puts->fileSizeManagement(lastDate, lastByte, inFile) == true){ //file read status set only for calls.
					calls->setExToDate(puts->getExToDate());
					calls->setExFromByte(puts->getExFromByte());
					break; //break only if member function returned to break, otherwise, do nothing.
				}
				puts->writeCurrValues();
			}

			//Done with dealing with filesize and multiple files part.



		}
		cout << "It took " << time(0) - before << " seconds to extract " << endl;

		before = time(0);

		calls->addExRows();
		puts->addExRows();

		before = time(0);
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		//Program will quickly sort the data. This is currently done whether data needs sorting or not.
		//So that all the times where data is already sorted, there is no need to even go through the deque of objects.
//.........这里部分代码省略.........
开发者ID:jdwuarin,项目名称:algoRobot,代码行数:101,代码来源:detectData.cpp


注:本文中的Columns::initiateAsset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。