vector<float> stringToVectorFloat ( string s, string tok ) { vector<float> to_return; string to_push ( "" ); bool pushed = false; string::iterator sIt; for ( sIt = s.begin(); sIt < s.end(); sIt++ ) { pushed = false; for ( string::iterator sTok = tok.begin(); sTok < tok.end(); sTok++ ) { if ( ( *sIt ) == ( *sTok ) ) { if ( ( int ) to_push.length() > 0 ) { to_return.push_back ( atof ( to_push.c_str() ) ); } to_push = ""; pushed = true; } } if ( !pushed ) { to_push.push_back ( ( *sIt ) ); } } if ( ( int ) to_push.length() > 0 ) { to_return.push_back ( atoi ( to_push.c_str() ) ); } return to_return; }
vector<string> stringToVector ( string s, string tok ) { vector<string> to_return; string to_push ( "" ); bool pushed = false; string::iterator sIt; for ( sIt = s.begin(); sIt < s.end(); sIt++ ) { pushed = false; for ( string::iterator sTok = tok.begin(); sTok < tok.end(); sTok++ ) { if ( ( *sIt ) == ( *sTok ) ) { to_return.push_back ( to_push ); to_push = ""; pushed = true; } } if ( !pushed ) { to_push.push_back ( ( *sIt ) ); } } to_return.push_back ( to_push ); return to_return; }
void operator()(const int threadID) const { for (int i=0; i<N; ++i) { op_data to_push(threadID); agg.process( &to_push ); } for (int i=0; i<N; ++i) { op_data to_pop; agg.process( &to_pop ); } }
level_converter::level_converter ( const string& input_file_name, const string& s_output_prefix ) { output_dirname = dirname(strdup(s_output_prefix.c_str())); output_basename = basename(strdup(s_output_prefix.c_str())); fstream sublevel_file_names_file( input_file_name, ios_base::in ); if ( !sublevel_file_names_file.is_open() ) { file_was_opened = false; return; } file_was_opened = true; // Read the whole file into sublevel_file_names_str_raw getline( sublevel_file_names_file, sublevel_file_names_str_raw, '\0' ); sublevel_file_names_file.close(); //cout << sublevel_file_names_str_raw; stringstream sublevel_file_names_sstm(sublevel_file_names_str_raw); string line; while ( getline( sublevel_file_names_sstm, line, '\n' ) ) { if ( line.empty() ) { //cout << "I found an empty line!\n"; continue; } sublevel_file_names_vec.push_back(line); } if ( sublevel_file_names_vec.size() > max_num_sublevels ) { cout << "Error! A maximum of " << max_num_sublevels << " sublevels per level is permitted! Exiting....\n"; exit(1); } else if ( sublevel_file_names_vec.size() == 0 ) { cout << "Error! At least one sublevel is needed to be able to " << "convert! Exiting....\n"; exit(1); } for ( u32 i=0; i<sublevel_file_names_vec.size(); ++i ) { string& sublevel_file_name = sublevel_file_names_vec.at(i); stringstream sublevel_num_sstm; string sublevel_num_str; sublevel_num_sstm << i; sublevel_num_sstm >> sublevel_num_str; tiled_sublevel to_push( sublevel_file_name, output_dirname, string("sublevel_") + sublevel_num_str ); if ( !to_push.file_was_opened ) { cout << "Error! The following sublevel file could not be " << "opened: " << sublevel_file_name << ". Exiting....\n"; exit(1); } //to_push.mostly_generate_the_sublevel(); //cout << to_push.layer_vec.size() << " sdf\n"; tiled_sublevel_vec.push_back(to_push); } for ( tiled_sublevel& the_tiled_sublevel : tiled_sublevel_vec ) { //the_tiled_sublevel.generate_sublevel_entrance_vec(); //cout << the_tiled_sublevel.get_sublevel_str_raw() << endl; cout << the_tiled_sublevel.get_sublevel_file_name() << endl; the_tiled_sublevel.generate_the_sublevel(); cout << endl; } generate_level_header_file(); generate_level_cpp_file(); }