jeudi 24 septembre 2020

value is

i have to open a txt file which contains lines like this :

route_id,service_id,trip_id,trip_headsign,trip_short_name,direction_id,block_id,shape_id,wheelchair_accessible
300820,20203011multint-1111100,71682319-20203011multint-1111100,"Place Jacques-Cartier (Sud)",,1,1000_1,08200529,2
300740,20203011multint-1111100,71680213-20203011multint-1111100,"Val-Bélair (Nord)",,0,1000_1,07400326,2

Right now i am doing this code :

void DonneesGTFS::ajouterVoyagesDeLaDate(const std::string &p_nomFichier)
{

    ifstream file(p_nomFichier);
    string str;

    if (!file) throw logic_error("Un problème est survenu lors de la lecture du fichier.");
    while (getline(file, str))
    {
        str.erase(remove(str.begin(), str.end(), '"'), str.end());
        if (str == "route_id,service_id,trip_id,trip_headsign,trip_short_name,direction_id,block_id,shape_id,wheelchair_accessible") {
            continue;
        }

        vector<string> string_vector = string_to_vector(str, ',');

        string trip_id = string_vector[2];

        unsigned int route_id = stoul(string_vector[0]);
        string service_id = string_vector[1];
        string headsign = string_vector[3];

        for(const auto& id : m_services)
        {
            if(string_vector[1] == id)
            {
                m_voyages.insert({trip_id, Voyage(trip_id, route_id, service_id, headsign)});
            }
        }

        }
    file.close();

}

The problem:

When using the debuguer on this line :

unsigned int route_id = stoul(string_vector[0]);

The value of route_id is assigned to and from what i read around here it could either be a problem ( bug in my code) or normal.

Could anyone confirm to me that it's not a bug ? Thanks

here's my debuger infos :

enter image description here

Aucun commentaire:

Enregistrer un commentaire