Пример #1
0
bool Conf_Process(std::fstream & f)
{
	char line[MAX_LINE_LENGTH];
	unsigned l = 0;
	bool breakflag = false;
	
	while (!f.eof() && !breakflag) {
		l++;
		f.getline(line, sizeof(line));
		if (line[0] == '\0') {
			// empty line, skip it (yeah we should ignore whitespaces too)
			continue;
		}
		if (line[0] == '/' && line[1] == '/') {
			// comment, skip it
			continue;
		}

		Conf_AcceptCommand(line, breakflag);
	}

	if (breakflag) {
		printf("Line: %u\n", l);
	}

	return true;
}
Пример #2
0
int LuaHistoryFile::LoadLuaTable(lua_State* luaState, size_t nBufferLen, std::fstream& fileStream)
{
	char* szRead = new char[4 * nBufferLen];
	lua_newtable(luaState);
	if(fileStream.getline(szRead, 4 * nBufferLen))
	{
		int nStrCnt = atoi(szRead);
		for(int ix = 1; ix <= nStrCnt; ++ix)
		{
			if(fileStream.getline(szRead, 4 * nBufferLen))
			{
				string strRead;
				wstring wstrRead;
				ANSI_to_Unicode(szRead, strlen(szRead), wstrRead);
				Unicode_to_UTF8(wstrRead.c_str(), wstrRead.size(), strRead);
				lua_pushstring(luaState, strRead.c_str());
				lua_rawseti(luaState, -2, ix);
			}
		}
	}
	delete []szRead;
	return 1;
}
Пример #3
0
void parseVC( std::fstream &file, std::string array_name, unsigned long int **array, char *chars,
		const unsigned int s, const unsigned long int P, const char skip=1 ) {
	std::string line;
	unsigned long int uli;
	std::cout << "Will read " << array_name << std::endl;
	if( skip )
		file.getline( chars, 500 ); //go past EOL
	if( file.peek() != '%' ) {
		std::cout << "Not at header line!" << std::endl;
		file >> line;
		std::cout << line << std::endl;
		file >> line;
		std::cout << line << std::endl;
		exit( 1 );
	}
void Agente::leerLinea(std::fstream& archivo, std::string& linea) {
	linea.clear();

	char buffer[T_BUFFER];

	bool seguirLeyendo = true;
	do {
		archivo.getline(buffer, T_BUFFER, '\n');
		linea.append(buffer, archivo.gcount());

		seguirLeyendo = (archivo.gcount() == T_BUFFER);

		if (archivo.bad())
			archivo.clear();

	} while (seguirLeyendo);
}
Пример #5
0
void calculateTransform(std::fstream &pointsFs) {
    Eigen::Matrix4f trans;
    pcl::PointCloud<pcl::PointXYZ> points_in_kinect;
    pcl::PointCloud<pcl::PointXYZ> points_in_arm;

    //read data from file into data structures
    char temp_buf[200];
    pcl::PointXYZ KinPos;
    pcl::PointXYZ ArmPos;
    while(true){
        pointsFs.getline(temp_buf,200);
        if(pointsFs.eof()) break;
        if (sscanf(temp_buf,"%f,%f,%f,%f,%f,%f", &(KinPos.x), 
                   &(KinPos.y), &(KinPos.z), &(ArmPos.x), &(ArmPos.y), 
                   &(ArmPos.z)) == 6) {
            points_in_kinect.push_back(KinPos);
            points_in_arm.push_back(ArmPos);
        }
    }

    //calibrate
    pcl::registration::TransformationEstimationSVD<pcl::PointXYZ,pcl::PointXYZ> transformation_estimator;
    if(points_in_kinect.size() > 6 ) {
        transformation_estimator.estimateRigidTransformation(points_in_kinect,points_in_arm,trans);
        cout << "Calculated transformation: " <<endl;
        cout << trans << endl;
        //write to file
        std::ofstream fs("mat.txt");
        if(!fs){
            std::cerr<<"Cannot open the output file."<<std::endl;
        }
        else{
            fs<< trans << endl ;
            fs.close();
        }
        cout << "transformation matrix written to mat.txt " << endl;
    }
    else{
        cout << "Not enough points to run SVD estimation" << endl;
    }
}
Пример #6
0
//options
void createandprintlist()//option1
{
    
    
    
    char x[80];
    
    
    while (((s[0])>'9' || (s[0])<'0') && !f1.eof())
    {
        f1.getline(s, 80, ' ');
        l1.insertqueue(x);
        
       
    }
    
    
    l1.display();
    


}
Пример #7
0
int main()
{
    
    f1.open("/Users/robinmalhotra2/Desktop/csl201check.txt",std::ios::in|std::ios::out);
    
    f1.getline(s, 80, ' ');
        while (f1.good())
    {

        
        
        
       
        std::cout<<"addasd";
        if ((strlen(s)==1) && (s[0])<'9' && (s[0])>'0')
            
        {
            switch ((s[0]))
            {
                    
                case '1':
                    createandprintlist();
                    
                
                    break;
                    
                case '2':
                    sortlist();
                    break;
                    
                case '3':
                    nextinsert();
                    break;
                    
                case '4':
                    searchlist();
                    break;
                    
                case '5':
                    deletenext();
                    break;
                    
                case '6':
                    deduplicate();
                    break;
                    
                case '7':
                    mergesortthing();
                    break;
                    
                case '8':
                    credits();
                    break;
                    
                    
                    
                default:
                    break;
            }
        }
        
        
    }
    f1.close();
    
    
    
}