1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
| // ######################################################################################################################################################
// # #
// # Gense #
// # const int afficher_Gense(wstring _T, vector<wstring>& G) #
// # #
// ######################################################################################################################################################
const int afficher_Gense(wstring const& _T, vector<wstring>& G)
{ // Gense
#if afficher_Gense_ == true
B.Ok_T(L"const int afficher_Gense(" + _T + L", vector<wstring>& G) :");
#endif
size_t pos;
static const basic_string <wchar_t>::size_type npos = -1;
pos = _T.find_last_of(L"\\");
if (pos == npos)
{
E.afficher_X(-1, _T, L"Érreur !!! Gense pas... !");
return EXIT_FAILURE;
}
pos++;
wstring g = _T.substr(pos);
if (g == L"Gense.txt")
{
try
{
// Dans le try, on est assuré que toute exception levée
// pourra être traitée dans le bloc catch situé après.
g = afficher_fichier_lire(_T);
}
// Notez qu'une exception s'attrape par référence constante.
catch (runtime_error const& exception)
{
// On affiche la cause de l'exception.
wcout << L"Erreur : " << exception.what() << endl;
}
}
else
{
E.afficher_X(-1, _T, L"Érreur !!! Gense pas... !");
return EXIT_FAILURE;
}
g = replace_all(g, L", ", L"\n");
g += L'\n';
pos = g.find(L'\n');
// Ok !
while (pos = g.find(L'\n'))
{
if (g[0] != g.length())
{
if (find(::Gense.begin(), ::Gense.end(), g.substr(0, pos)) != ::Gense.end())
{
G.push_back(g.substr(0, pos));
g = g.substr(pos + 1);
}
else
{
return EXIT_FAILURE;
}
}
else
break;
}
#if afficher_Gense_ == true
int i = 0;
vector <wstring>::iterator iter;
wstring wstr = L"Gense={";
for (iter = G.begin(); iter != G.end(); iter++)
{
wstr += *iter;
i++;
if (i != G.size())
wstr += L", ";
}
B.Ok_W(wstr + L'}');
B.Ok_T(L"const int afficher_Gense() : Ok !");
#endif
return EXIT_SUCCESS;
} |