Exemple #1
0
		/* 
		 * Formats a number with commas and optionally decreases\increases the
		 * number of digits after the decimal point.
		 *   563946.4274  ->  563,946.43
		 */
		std::string
		format_number (double num, int trunc)
		{
			std::ostringstream ss;
			std::locale comma_locale (std::locale (), new comma_numpunct ());
			ss.imbue (comma_locale);
			ss << std::fixed << std::setprecision (2) << std::showpoint << num;
			return ss.str ();
		}
std::string Utility::formatScore(int value) {

  std::locale comma_locale(std::locale(), new CommaPunctuation());

  std::stringstream ss;
  ss.imbue(comma_locale);

  ss << value;

  return ss.str();
}
Exemple #3
0
void main()
{	
	//reset_globals();

	setGameInputToEnabled(true, true);
	setAirbrakeRelatedInputToBlocked(false, true);

	write_text_to_log_file("Setting up calls");

	set_periodic_feature_call(update_features);

	write_text_to_log_file("Loading settings");

	load_settings();

	init_vehicle_feature();

	write_text_to_log_file("Loaded settings OK");

	// this creates a new locale based on the current application default
	// (which is either the one given on startup, but can be overriden with
	// std::locale::global) - then extends it with an extra facet that 
	// controls numeric output.
	std::locale comma_locale(std::locale(), new comma_numpunct());

	// tell cout to use our new locale.
	std::cout.imbue(comma_locale);
	
	set_status_text("~HUD_COLOUR_MENU_YELLOW~ENT ~HUD_COLOUR_WHITE~is ready!");

	while (true)
	{
		if (trainer_switch_pressed())
		{
			menu_beep();
			set_menu_showing(true);
			process_main_menu();
			set_menu_showing(false);
		}
		else if (airbrake_switch_pressed())
		{
			menu_beep();
			process_airbrake_menu();
		}

		update_features();

		WAIT(0);
	}
}
Exemple #4
0
std::vector<std::string> srs(std::istream& fin, int sample_size, int header_flag)
{
    // initialize vector of size sample_size
    std::vector<std::string> reservoir (sample_size);
    std::string line;

    int row_number = 0;
    int random_int;

    std::mt19937 rng;
    int seed = std::random_device()();
    rng.seed(seed);
        
    std::string header;

    // if file as flagged as having a header,
    // remove first line and store it in header
    if (header_flag == 1)
    {
        std::getline(fin, header);
    }
   
    while (std::getline(fin, line))
    {
        if (row_number < sample_size)
        {
            reservoir[row_number] = line;
        }

        else
        {
            std::uniform_int_distribution<std::mt19937::result_type> dist(0, row_number - 1);
            random_int = dist(rng);
            
            if (random_int < sample_size)
            {
               reservoir[random_int] = line;
            } 
        }

        row_number++;
    }

    // this creates a new locale based on the current application default
    // (which is either the one given on startup, but can be overriden with
    // std::locale::global) - then extends it with an extra facet that 
    // controls numeric output.
    std::locale comma_locale(std::locale(), new comma_numpunct());

    // tell cerr to use our new locale
    std::cerr.imbue(comma_locale);

    std::cerr << "Seed: " << seed << std::endl;

    if (row_number < sample_size)
    {
        std::cerr << "Sample size is larger than size of data\n" <<
            "Selecting all data.\n";
        reservoir.resize(row_number);
    }

    std::cerr << "Sampled " << reservoir.size() << " items of " << row_number;

    if (header_flag == 1)
    {
        reservoir.insert(reservoir.begin(), header);
    }

    return reservoir;
}