Esempio n. 1
0
//以文件方式输出结果
void Print::ToPrintIs_f(string sText_txt, string sResult_txt) 
{
	
	ifstream in;
	ofstream out;

	//打开文件
	in.open(sText_txt.c_str(), ios::in);
	out.open(sResult_txt.c_str(), ios::out);
	
	while (!in.eof())
	{
		Scan scan;
		Calculation calculate;
		string sExperssion;
		
		//从sText_txt路径获取数据
		getline(in, sExperssion, '\n');

		//拆分表达式
		scan.ToStringQueue(sExperssion);

		
		//计算表达式的值
		calculate.ToCalculate(scan.q);

		//在sResult_txt路径下输出结果
		out << calculate.m_dResult << endl;
	}

	//关闭文件
	in.close();
	out.close();
}
Esempio n. 2
0
//--------1 输出表达式; 
void Print::PrintStringQueue(string input) 
{
	/*创建Scan对象s*/ 
	Scan s;
	Calculate c;
	/*获得Scan里所扫描的队列*/                                            
	queue<string> tmp = s.ToStringQueue(input);  
	
	//---- 除数为0或超出十位数输ERROR 
	if (s.IsError() == true )
	{
		cout << "ERROR" <<endl;
	}
	else 
	{
		if (c.iserror() == false) 
		{
			/*依次输出符合要求的元素*/
			while ( !tmp.empty() )
			{
				cout << tmp.front() ;
				tmp.pop();                                  
			}
			cout << " " << c.Calculater(input);
		}
		else
		{
			cout << "ERROR" << endl;
		}	
	}
}
Esempio n. 3
0
void File_Operate::Fileoperate()
{
	Scan Sc;    
    Print Put;  
    Calculation Ca;
	
	ifstream infile; 
    ofstream outfile;
    
    //打开文件 
    infile.open(getsfile.c_str(),ios::in); 
    outfile.open(putsfile.c_str(),ios::out);
    	
    string get_str;
    	
    while(!infile.eof()) //未处理到文件尾 
    {
    	getline(infile,get_str); //读入数据 
    		
    	queue<string> que;
    		
    	que = Sc.ToStringQueue(get_str);
    		
    	double result=0;
    		
    	result = Ca.carryout(que);
    		
    	outfile << result << endl;
    }
    	
    //关闭文件 
    infile.close();
    outfile.close();
}
Esempio n. 4
0
int main(int argc, char* argv[])
{
	Scan in;
	
	Calculation cal;
	
	string input;
	
	//将传入表达式赋给input 
	if(strcmp(argv[1], "-a") == 0)
	{
		cout << argv[2] << "= ";
		input = argv[2];
	} 
	
	else
	{
		input = argv[1];
	}
	
	//首先判断输入字符串中数字串长度不超过10位
	if (!in.checkNumberLen(input))
	{
		return 0;
	}
	
	cal.getQueue(in.ToStringQueue(input));

	return 0;
}
Esempio n. 5
0
int ScanUtils::findBestFragmentScan(RawDataFile dataFile, boost::numeric::interval<double> rtRange, boost::numeric::interval<double> mzRange) {

	int bestFragmentScan = -1;
	double topBasePeak = 0;

	std::vector<int> fragmentScanNumbers = dataFile.getScanNumbers(2, rtRange);

	for (int number : fragmentScanNumbers) {

		Scan scan = dataFile.getScan(number);
		double lb = mzRange.lower, up = mzRange.upper, ppp = scan.getPrecursorMz;
		if (lb < ppp && up > ppp)
		{
		//if (mzRange.lower() < scan.getPrecursorMz() && mzRange.upper() > scan.getPrecursorMz) {

			DataPoint basePeak = scan.getHighestDataPoint();

			// If there is no peak in the scan, basePeak can be null
			if (DataPoint* v = dynamic_cast<DataPoint*>(&basePeak))
				continue;

			if (basePeak.getIntensity() > topBasePeak) {
				bestFragmentScan = scan.getScanNumber();
				topBasePeak = basePeak.getIntensity();
			}
		}

	}

	return bestFragmentScan;

}
Esempio n. 6
0
int main(int argc, char* argv[])
{
	bool flag = false;
	stack <double>result;
	string character;
	queue<string>que_character;
	Scan INPUT;
	//Print OUTPUT;
	Calculation CAL;
	Calculation RES;
	
	character = argv[1];
	
	if(character == "-a")
	{
		character = argv[2];
		flag = true;
	}
	if(flag)
	{
		cout << character << "=";
	}
	
	que_character = INPUT.ToStringQueue (character);
	result = CAL.Separate (que_character);
	RES.CoutResult(result);
	//OUTPUT.print(que_character);
	return 0;
}
Esempio n. 7
0
//-------------------------------------------------------------------
// Sort::PassOneAndBeyond
//
// Input   : Number of files generated by Pass 0
// Output  : None
// Return  : OK if Pass 1 and beyond succeed, FAIL otherwise
//-------------------------------------------------------------------
Status Sort::PassOneAndBeyond(int numFiles) {
	passOneBeyondRuns = 0;
	int numPass = 1, numStartFiles = passZeroRuns, numEndFiles;
	do { 
		numEndFiles = 0;
		if (OneMergePass(numStartFiles, numPass, numEndFiles) != OK ) return ReturnFAIL("OneMergePass failed.");
		numStartFiles = numEndFiles;
		numPass++;
	} while (numEndFiles > 1);

	// Write out
	Status s;
	RecordID rid; char *recPtr = (char *)malloc(_recLength); int recLen = _recLength;
	char *fileName = CreateTempFilename(_outFile,numPass-1,passOneBeyondRuns);
	HeapFile file(fileName,s); // read temp file
	if (s != OK) return ReturnFAIL("Opening PassOneAndBeyond temp file failed.");
	Scan *scan = file.OpenScan(s);
	if (s != OK) return ReturnFAIL("Opening scan in PassOneAndBeyond failed.");
	HeapFile output(_outFile, s);
	if (s != OK) return ReturnFAIL("Opening output file in PassOneAndBeyond failed.");
	while (scan->GetNext(rid,recPtr,recLen) == OK) {
		output.InsertRecord(recPtr,recLen,rid);
	}
	delete fileName;
	delete scan;
	free(recPtr);
	file.DeleteFile();
	return OK;
}
// Get the scan expression for given jbbc
// if jbbc is not a scan or predIdSet is NULL
// then the original JBBC expression is returned
RelExpr * AppliedStatMan::getExprForCANodeId(
          CANodeId jbbc,
          const EstLogPropSharedPtr &inLP,
          const ValueIdSet * predIdSet)
{
  RelExpr * jbbcExpr = NULL;
  
  // should not happen but a check just in case
  CCMPASSERT(jbbc.getNodeAnalysis());
  
  //if specified by the user apply those predicates,
  // else apply predicates in the original expr
  NodeAnalysis * jbbcNode = jbbc.getNodeAnalysis();

  TableAnalysis * tableAnalysis = jbbcNode->getTableAnalysis();

  if (tableAnalysis && predIdSet)
  {
    TableDesc * tableDesc = tableAnalysis->getTableDesc();
    const CorrName& name = tableDesc->getNATable()->getTableName();

    Scan *scanExpr = new STMTHEAP Scan(name, tableDesc, REL_SCAN, STMTHEAP);
    scanExpr->setBaseCardinality(MIN_ONE (tableDesc->getNATable()->getEstRowCount())) ;

    GroupAttributes * gaExpr = new STMTHEAP GroupAttributes();

    scanExpr->setSelectionPredicates(*predIdSet);

    ValueIdSet requiredOutputs = jbbc.getNodeAnalysis()->\
  getOriginalExpr()->getGroupAttr()->getCharacteristicOutputs();

    gaExpr->setCharacteristicOutputs(requiredOutputs);

    ValueIdSet requiredInputs = jbbc.getNodeAnalysis()->\
  getOriginalExpr()->getGroupAttr()->getCharacteristicInputs();

    gaExpr->setCharacteristicInputs(requiredInputs);
    
    scanExpr->setGroupAttr(gaExpr);
    gaExpr->setLogExprForSynthesis(scanExpr);
    scanExpr->synthLogProp();
    jbbcExpr = scanExpr;
  }
  else
  {
    NodeAnalysis * nodeAnalysis = jbbc.getNodeAnalysis();

    RelExpr * relExpr = nodeAnalysis->getModifiedExpr();

    if (relExpr == NULL)
      relExpr = nodeAnalysis->getOriginalExpr();

    jbbcExpr = relExpr;
  }

  return jbbcExpr;
} // getExprForCANodeId
Esempio n. 9
0
HeapFile *SortFile(HeapFile *S, int len, int offset)
{
	Status s;

	Scan *scan;
	scan = S->OpenScan(s);
	if (s != OK)
	{
		cerr << "ERROR : cannot open scan on the heapfile to sort.\n";
	}

	//
	// Scan the HeapFile S, new a B+Tree and insert the records into B+Tree.
	// 

	BTreeFile *btree;
	btree = new BTreeFile (s, "BTree", ATTR_INT, sizeof(int));

	char *recPtr = new char[len];
	int recLen = len;
	RecordID rid;
	while (scan->GetNext(rid, recPtr, recLen) == OK)
	{
		btree->Insert(recPtr + offset, rid);
	}
	delete scan;

	HeapFile *sorted;
	sorted = new HeapFile(NULL, s); // create a temp HeapFile
	if (s != OK)
	{
	    	cerr << "Cannot create new file for sortedS\n";
	}

	//
	// Now scan the B+-Tree and insert the records into a 
	// new (sorted) HeapFile.
	//

	BTreeFileScan  *btreeScan;
	btreeScan = (BTreeFileScan *)btree->OpenScan(NULL, NULL);

	int key;

	while (btreeScan->GetNext(rid, &key) == OK)
	{
	    S->GetRecord (rid, recPtr, recLen);
	    sorted->InsertRecord (recPtr, recLen, rid);
	}
	btree->DestroyFile();

	delete btree;
	delete btreeScan;
	delete [] recPtr;

	return sorted;
}
Esempio n. 10
0
//*********************************************
//***	Test 5: Test some error conditions	***
bool HeapDriver::Test5()
{
    cout << "\n  Test 5: Test some error conditions\n";
    Status status = OK;
    Scan* scan = 0;
    RecordID rid;
	
	//	Open the heap file
    HeapFile f("file_1", status);
    if (status != OK)
        cerr << "*** Error opening heap file\n";
	
    if ( status == OK )
	{
        cout << "  - Try to change the size of a record\n";
        scan = f.OpenScan(status);
        if (status != OK)
            cerr << "*** Error opening scan\n";
	}

	//	Try to change the size of a record -- should fail
    if ( status == OK )
	{
        int len;
        Rec rec;
		len = sizeof(rec);
        status = scan->GetNext(rid, (char *)&rec, len);
        if ( status != OK )
            cerr << "*** Error reading first record\n";
        else
		{
            status = f.UpdateRecord( rid, (char*)&rec, len-1 );
            TestFailure( status, HEAPFILE, "Shortening a record" );
            if ( status == OK )
			{
                status = f.UpdateRecord( rid, (char*)&rec, len+1 );
                TestFailure( status, HEAPFILE, "Lengthening a record" );
			}
		}
	}
	
    delete scan;
	
	//	Try to insert a too long record -- should fail
    if ( status == OK )
	{
        cout << "  - Try to insert a record that's too long\n";
        char record[MINIBASE_PAGESIZE] = "";
        status = f.InsertRecord( record, MINIBASE_PAGESIZE, rid );
        TestFailure( status, HEAPFILE, "Inserting a too-long record" );
	}
	
    if ( status == OK )
        cout << "  Test 5 completed successfully.\n";
    return (status == OK);
}
Esempio n. 11
0
//-----3 采用文件读取的方法
void Print::Usedfile(string input, string read, string ans)
{
	Calculate c;
	Scan ss;
	
	//---- 3-1 文件声明及打开; 
	ifstream in;
	ofstream out;
	
	//调用.c_str()接受字符串作为文件名;
	in.open (read.c_str(),ios::in );
	out.open(ans.c_str() ,ios::out); 
	//----3-2 文件的读写;
	while ( !in.eof() )
	{
		int flag1 = 0;
		input.clear();
		getline(in, input, '\n');	
		double answer = 0;
		//---- 3-2-1 判断是否超出十位; 
		if (ss.IsError() == true)
		{
			flag1 = 1;
//			out << "ERROR" << endl;
		}
		 
		if (ss.IsError() == false)
		{
			answer = c.Calculater(input);
			
			//---- 3-2-2 判断除数是否为0; 
			if (c.iserror() == true )
			{
				out << "ERROR" << endl;
			}
			else
			{
				//---- 3-2-3 输出答案; 
				if (flag1 == 1)
				{
					out << "ERROR" << endl;
					flag1 = 0;
				}
				else
				{
					out << answer << endl;	
				}
				
			}
		}
	}
	//-----3-3 关闭文件; 
	in.close() ;
	out.close();
}
Esempio n. 12
0
void VdyneScanCloud::readBinary(std::istream& stream) {
  BinaryStreamReader<std::istream> binaryStream(stream);
  size_t numScans;
  binaryStream >> mTimestamp >> mStartRotationAngle >> mEndRotationAngle
    >> numScans;
  for (size_t i = 0; i < numScans; ++i) {
    Scan scan;
    scan.readBinary(stream);
    mScans.push_back(scan);
  }
}
Esempio n. 13
0
Sort::Sort(
	char		*inFile,			// Name of unsorted heapfile.
	char		*outFile,		// Name of sorted heapfile.
	int      	numFields,		// Number of fields in input records.
	AttrType 	fieldTypes[],	// Array containing field types of input records.
	// i.e. index of in[] ranges from 0 to (len_in - 1)
	short    	fieldSizes[],	// Array containing field sizes of input records.
	int       	sortKeyIndex,	// The number of the field to sort on.
	// fld_no ranges from 0 to (len_in - 1).
	TupleOrder 	sortOrder,		// ASCENDING, DESCENDING
	int       	numBufPages,	// Number of buffer pages available for sorting.
	Status 	&s)
{
	// Initialize private instance variables
	_recLength = 0;
	for (int i=0;i<numFields;i++) {
		_recLength += fieldSizes[i];
	}
	for (int i=0;i<sortKeyIndex;i++) {
		_sortKeyOffset += fieldSizes[i];
	}
	_numBufPages = numBufPages;
	_inFile = inFile; 
	_outFile = outFile;
	_fieldSizes = fieldSizes;
	_sortKeyIndex = sortKeyIndex;
	_sortType = fieldTypes[_sortKeyIndex];
	_sortOrder = sortOrder;

	// Pass 0
	int numTempFiles = 0;
	if (PassZero(numTempFiles) != OK) { std::cerr << "PassZero failed." << std::endl; return; }
	if (numTempFiles == 1) { // done, write out
		RecordID rid; char *recPtr = (char *)malloc(_recLength); int recLen = _recLength;
		char *fileName = CreateTempFilename(_outFile,0,0);
		HeapFile passZeroFile(fileName,s); // read temp file
		if (s != OK) { std::cerr << "Opening PassZero temp file failed." << std::endl; return; }
		Scan *scan = passZeroFile.OpenScan(s);
		if (s != OK) { std::cerr << "Opening scan in PassZero failed." << std::endl; return; }
		HeapFile output(_outFile, s);
		if (s != OK) { std::cerr << "Opening output file in PassZero failed." << std::endl; return; }
		while (scan->GetNext(rid,recPtr,recLen) == OK) {
			output.InsertRecord(recPtr,recLen,rid);
		}
		delete fileName;
		delete scan;
		free(recPtr);
		passZeroFile.DeleteFile();
		s = OK;
	} else { // more passes
		if (PassOneAndBeyond(numTempFiles) != OK) { std::cerr << "PassOneAndBeyond failed." << std::endl; return; }
		s = OK;
	}
}
int main() {
    Scan ltest;
    string s;
    cout << "input the code file: ";
    cin >> s;
    ltest.srcfile = s;
    ltest.outfile = "/Users/James/Open_Source/Debug/out.txt";
    ltest.getToken();
    Parse ptest(ltest.list_token, "/Users/James/Open_Source/Debug/asm.txt",
                "/Users/James/Open_Source/Debug/main.txt");
    ptest.test();
    return 0;
}
Esempio n. 15
0
int main(int argc, char* argv[])
{   
	string input;
	Scan scan;
	Paint print;

	

	if (argc == 2)//无-a -f
	{
		
		input = argv[1];
		scan.ToStringQueue(input);
		print.Printqueue();
	}

	else if (argc == 3 )//第二个参数-a
	{
		input = argv[2];
		cout << input << " ";
		scan.ToStringQueue(input);
		print.Printqueue();
	}
	
	else// -f的情况
	{
		
		fout.open(argv[3]);
		flag = 4;
		ifstream fin;
		fin.open(argv[2]);
		if (fin.is_open())
		{

			while (fin.good() && !fin.eof())//读取到文件尾停止读入
			{
				
				string message;//先将运算式存入message 再转存如input进行操作
				fin >> message;
				input = message;
				ssss = argv[3];
				scan.ToStringQueue(input);
				print.Printqueue();

			}
		}	
	}
	system("pause");
	return 0;
	
}
Esempio n. 16
0
int main(int argc, char* argv[])
{

	string input;	//接收键盘输入的表达式 	
	Scan sc;
	Print pr;
	Calculation cal;
	queue<string> q;
	string res;
	
	if (argc == 2)
	{
		input = argv[1];
		q = sc.toStringQueue(input);
		sc.clearQue();
		pr.print(pr.getInfomation(sc.getFlag(), cal.getResult(q)));
	}
	else if (argc == 3 && strcmp(argv[1], "-a") == 0)
	{
		input = argv[argc - 1];
		q = sc.toStringQueue(input);
		pr.printQue(q);
		sc.clearQue();
		pr.print(pr.getInfomation(sc.getFlag(), cal.getResult(q)));
	}
	else if (argc == 4 && strcmp(argv[1], "-f") == 0)
	{
		sc.read(argv[2], argv[3]);
		
	}

	return 0;
}
Esempio n. 17
0
int main()
{
	Scan scan;
	Print print;
	
	cin >> input;
	
	scan.ToStringQueue(input);
	
	if (scan.IsError())
	{
		cout << "Error" << endl;
	}	else
	{
		print.PrintQueue(scan.GetQueue());
	}
} 
Esempio n. 18
0
//以非文件方式输出结果
void Print::ToPrintIsNot_f(string sInput, bool bIs_a)
{
	Scan scan;
	Calculation calculate;

	//拆分表达式
	scan.ToStringQueue(sInput);

	//计算表达式的值
	calculate.ToCalculate(scan.q);

	if (bIs_a)
	{
		cout << sInput << "= ";
	}
	cout << calculate.m_dResult << endl;
}
Esempio n. 19
0
int main(int argc, const char * argv[]) {
    string input;
    bool p,a;
    double ans;
    int i;
    Scan scan;
    Print print;
    Calculate Calculate;
    
    p=false;
    a=false;
    i=1;
    
//    getline(cin,input);
    
    if (argc<2) return 0;
    
    input=argv[i];
    
    while (1){
        
        if (input=="-a") {
            input=argv[++i];
            a=true;
            continue;
        }
        
        if (input=="-p"){
            input=argv[++i];
            p=true;
            continue;
        }
        
        break;
    }
    

// print.PrintStringQueue( scan.ToStringQueue(input) );
    
    
    ans=Calculate.getAns( scan.ToStringQueue(input) , p);
    
    if (a) cout<<input<<"=";
    cout<<ans<<endl;
    return 0;
}
Esempio n. 20
0
int main(int argc, char* argv[])
{
	string input;
	string output;

	int temp = 0;//判断是否有“-a”
	int i;

	Scan sca;
	Calculation calcul;

	for (i = 1; i < argc; i++)
	{
		input = argv[i];
		if (input == "-a")
		{
			temp = 1;
			continue;
		}

	}

	sca.ToStringQueue(input);
	queue<string>*q = sca.GetQueue();//定义队列指针接收队列

	//如果数字符合要求才运算 
	if (sca.m_ijudge == 0)
	{
		if (temp == 1)
		{
			cout << input << "= ";
		}
		calcul.trans(q);
		double result = calcul.count();
		cout << result << endl;

	}
	else
	{
		return 0;
	}

	system("pause");
	return 0;
}
Esempio n. 21
0
//-------------------------------------------------------------
// test
//-------------------------------------------------------------
Status test(int t)
{
	char		outfile[10];
	int		Rarray[] = { 0, 1, 0, 3, 4, 4, 4 };
	int		Sarray[] = { 1, 0, 2, 2, 2, 3, 0 };
	int 		R = Rarray[t-1];
	int 		S = Sarray[t-1];
	Status		s;

	sprintf(outfile,"test%d", t);

	// Perform sort-merge on R and S
	sortMerge	sm(files[R],NUM_COLS,attrType,attrSize,JOIN_COL,files[S],NUM_COLS,attrType,attrSize,JOIN_COL,outfile,SORTPGNUM,Ascending,s);
	if (s != OK)
	{
		cout << "Test " << t << " -- sortMerge failed" << endl;
		return s;
	}

	// Write merged results to stdout
	HeapFile*	outf = new HeapFile (outfile,s);
	if (s != OK)
	{
		cout << "Test " << t << " -- result file not created " << endl;
		return s;
	}
        Scan*	scan = outf->openScan(s);
	assert(s == OK);
	int len;
	RID	rid;
	char	rec[sizeof(struct _rec)*2];
	cout << endl;
	cout << "------------ Test " << t << " ---------------" << endl;
	for (s = scan->getNext(rid, rec, len); s == OK; s = scan->getNext(rid, rec, len)) 
	{
	  cout << (*((struct _rec*)&rec)).key << "\t" << (*((struct _rec*)&rec[8])).key << endl;
	}
	cout << "-------- Test " << t << " completed --------" << endl;
	delete scan;
	s=outf->deleteFile();
	if(s!=OK) MINIBASE_CHAIN_ERROR(JOINS,s);
	delete outf;
	return s;
}
Esempio n. 22
0
//--------------------------------------------------------------------
// JoinSpec::PrintRelation
// 
// Purpose :  Prints the relation represented by a JoinSpec.
// Input   :  filename  - The file to which to write the output. When NULL (default)
//                        output is written to the screen. 
// Output  :  None
// Return  :  None
//-------------------------------------------------------------------- 
void JoinSpec::PrintRelation(const char* filename) {
	Status s;
	Scan *scan = file->OpenScan(s);

	if (s != OK) {
		std::cerr << "Cannot open scan on HeapFile in PrintRelation."<< std::endl;
		return;
	}


	FILE* f;
	if(filename == NULL) {
		f = stdout;
	}
	else {
		f = fopen(filename, "w");
		if (f == NULL) {
			std::cerr << "Cannot open file " << filename << " for writing.\n";
			return;
		}
	}

	char* rec = new char[recLen];

	int len = recLen;
	RecordID rid;

	while(scan->GetNext(rid, rec, len) != DONE) {
		if(len != recLen) {
			std::cerr << "Unexpected record length in print method." << std::endl;
			return;
		}
		for(int i = 0; i < numOfAttr; i++) {
			fprintf(f, "%d ", *(((int*)(rec)) + i));
		}
		fprintf(f, "\n");
	}

	if(filename != NULL) {
		fclose(f);
	}

	delete [] rec;
}
Esempio n. 23
0
int main(int argc , char *argv[])
{
	Scan scan;
	//Print print;
	Calculation calculation;
	string input;
	//cin >> input;
	
	/*根据argc的值对input赋值*/
	if(argc == 2)
	{
		input = argv[1];
	}
	else
	{
		input = argv[2];
	}
	
	scan.ToStringQueue (input); /*将input传入Scan进行处理*/
	calculation.GetQueue(scan.ReturnQueue()); /*将处理后的queue传入Calculation*/
	calculation.Change(scan.ReturnQueue()); /*将传入的queue进行后缀转化*/

	//calculation.Ans();
	
	/*根据argc的值进行不同输出*/
	if(argc == 2)
	{
		calculation.Ans();
	}
	else
	{
		cout << argv[2] << "= ";
		calculation.Ans();
	}

	//if(scan.IsError() == false)
	//	print.print(scan.ReturnQueue());
	//else
		//cout << "超过十位啦!";

	return 0;
}
Esempio n. 24
0
void * perform_scan(void * args) {
    ps_args_t* ps_args = ((ps_args_t *) args);
    string ip = "ip";
    int port = 0;
    while (ip != "finish" && port != -1) {
        get_next_ip_port(*ps_args, ip, port);
        if (ip == "finish" && port == -1) {
            return NULL;
        }
        for (int s = 0; s < 6; s++) {
            if (ps_args->scans[s] == 1) {
                Scan sc = Scan();
                sc.ipToScan = ip;
                sc.port = htons(port);
                //sc.scanVector = vector<ScanType>();
                switch (s) {
                    case SYN:
                        sc.cScan = SYN;

                        sc.runTcpScan();
                        break;
                    case NUL:
                        sc.cScan = NUL;

                        sc.runTcpScan();
                        break;
                    case FIN:
                        sc.cScan = FIN;

                        sc.runTcpScan();
                        break;
                    case XMAS:
                        sc.cScan = XMAS;

                        sc.runTcpScan();
                        break;
                    case ACK:
                        sc.cScan = ACK;

                        sc.runTcpScan();
                        break;
                    case UDP:
                        sc.cScan = UDP;
                        sc.runUdpScan();
                        break;
                }
                pthread_mutex_lock(&arrMutex);
                scanArray.push_back(sc);
                pthread_mutex_unlock(&arrMutex);
            }
        }
    }
    return NULL;
}
Esempio n. 25
0
int main()
{
    string input;
    cin>>input;

    if(check(input))
    {
        cout<<"出错啦!"<<endl;
        return 0;                   
    }

    else                            //数字位数不大于10时处理字符串
    {
        Scan scan;                      
        Print print;                    //创建Print对象和scan对象 

        queue<string> q = scan.ToStringQueue(input);        //调用ToStringQueue()函数获取目标队列
        print.PrintQueue(q);                                //调用PrintQueue()函数输出队列各元素

        return 0;
    }
}
Esempio n. 26
0
//-----2 输出结果; 
void Print::Printanswer(string input)
{
	Calculate c;
	Scan s;
	double answer = 0;
	answer = c.Calculater(input);
	if (s.IsError() == true)
	{
		cout << "ERROR" << endl;
	}
	else
	{
		if (c.iserror() == false)
		{
			cout << answer << endl;
		}
		else
		{
			cout << "ERROR" << endl;
		}
	} 
	
}
Esempio n. 27
0
int main(int argc,char *argv[])
{
	using namespace std;
	u_int op=0;
	Scan input;
	calculation cal;
	Print output;
	string arg[2]={"-a","-f"},exp;
	if(argc==2){
		exp=argv[1];
		double ans=cal.calc( input.toStringQueue( exp ) );	//调用input类的toStringQueue方法,返回一个<string>的队列,将其传入cal的运算函数得到结果
		output.print(exp,ans,op,cout);
	}else if(argc>2&&arg[0]==argv[1]){
		op=1;
		exp=argv[2];
		double ans=cal.calc( input.toStringQueue( exp ) );	//调用input类的toStringQueue方法,返回一个<string>的队列,将其传入cal的运算函数得到结果
		output.print(exp,ans,op,cout);
	}else if(argc>3&&arg[1]==argv[1]){
		op=2;
		ifstream in(argv[2]);
		ofstream out(argv[3]);
		if(!in||!out){
			cout<<"Open File ERROR"<<endl;
			exit(-1);
		}
		int cnt=0;
		while(!in.eof()){
			in>>exp;
			double anst;
			anst=cal.calc( input.toStringQueue( exp ) );	//调用input类的toStringQueue方法,返回一个<string>的队列,将其传入cal的运算函数得到结果
			output.print(exp,anst,op,out);
			cnt++;
			if(cnt%1000)out<<flush;
		}
		in.close();
		out.close();
	}else{
Esempio n. 28
0
int main(int argc,char* argv[])
{
	queue<string>que;
	/*创建一个Print类的对象 b;*/
	Print b;
	Scan a;
	string input;
	int flag=1;
	/*判断是否为文件输入*/
	if(argc<2)
		cout << "无参数" << endl;
	else
	{
		if(strcmp(argv[1],"-f")==0)
		{
			string text_file=argv[argc-2];  //输入文件名
			string result_file=argv[argc-1];  //输出文件名
			a.Filelong(text_file,result_file); //Print类里面处理文件计算的函数
		}
		else
		{
			if(strcmp(argv[1],"-a")==0)
			{
				flag=1;
				input=argv[2];
			}
			else
			{
				flag=0;
				input=argv[1];
			}
			b.Datalong(input,flag); //Print类里面处理非文件的函数
		}
	}
	return 0;
}
Esempio n. 29
0
bool Recording::computeActiveSegments(const util::Params& params, const Scan& scene,
                                      float maxDistToSegment, float maxDistGaze,
                                      bool forceRecompute /* = false */) {
  if (hasActiveSegments && !forceRecompute) {
    return true;
  }

  cout << "[Recording] Computing actSegs: " << id << "...";
  const int kNearestSegsPerJoint = params.get<int>("Interaction.kNearestSegsPerJoint");
  const bool ignoreInferredJoints = params.get<bool>("Interaction.ignoreInferredJoints");
  const float maxSegmentSizeRatio = params.get<float>("Interaction.maxSegmentSizeRatio");

  for (Interaction* in : interactions) {
    const int numSkels = static_cast<int>(in->skelRange.size());
    in->jointSegments.resize(numSkels);
    in->activeSegments.clear();

#pragma omp parallel for
    for (int iSkel = 0; iSkel < numSkels; iSkel++) {
      const Skeleton& skel = in->skelRange[iSkel];
      scene.getActiveSegments(skel, ignoreInferredJoints, kNearestSegsPerJoint,
                              maxDistToSegment, maxDistGaze, maxSegmentSizeRatio,
                              &in->jointSegments[iSkel]);
    }

    // Also accumulate all segs in activeSegments
    for (int iSkel = 0; iSkel < numSkels; iSkel++) {
      const auto& segs = in->jointSegments[iSkel];
      for (const auto& jointSegs : segs) {
        in->activeSegments.insert(jointSegs.begin(), jointSegs.end());
      }
    }
  }

  cout << "done." << endl;
  hasActiveSegments = true;
  return true;
}
void NearestNeighboursON2::getNearestNeighbours(
        const Scan &queryScan,
        unsigned int queryToReferenceMapping[][2],
        double nearestDistances[]) {

    const Scan &refScan = *(this->refScan);
    const unsigned int queryScanSize = queryScan.size(), refScanSize = refScan.size();

    for(unsigned int i = 0; i < queryScanSize; i++) {
        TopValues<2> tv;

        for(unsigned int j = 0; j < refScanSize; j++) {
            double dist =
                    square(refScan[j].getX() - queryScan[i].getX()) +
                    square(refScan[j].getY() - queryScan[i].getY());
            tv.add(dist, j);
        }

        queryToReferenceMapping[i][0] = tv.index(0);
        queryToReferenceMapping[i][1] = tv.index(1);
        nearestDistances[i] = tv.value(0);
    }
}