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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
| const int afficher_Avec(std::wstring& a, std::wstring const& nomFichier, std::vector<std::wstring>& Avec, std::vector<std::wstring>& Avec_role)
{
#if afficher_Avec_ == 1
B.Ok_T(L"const int afficher_Avec(" + a + L", " + nomFichier + L", std::vector<std::wstring>&Avec, std::vector<std::wstring>&Avec_role) :");
#endif
std::size_t pos, pos2;
pos = a.length();
std::vector<std::wstring>::iterator iter, iter2;
if (a == L"Avec.txt")
{
try
{
a = lire_fichierTxt(nomFichier);
}
catch (runtime_error const& exception)
{
std::wcout << L"Erreur : " << exception.what() << std::endl;
}
a = replace_all(a, L",", L" -");
a = replace_all(a, L"(", L"[");
a = replace_all(a, L")", L"]");
if (!a.empty())
{
if (pos = a.find(L", "))
a = replace_all(a, L", ", L"\n");
a += L"\n";
while (pos = a.find(L"\n"))
{
if (a[0] != a.length())
{
pos2 = a.find(L"
");
if (pos2 != std::wstring::npos && a[0] == L'
')
// Avec={L'
'}
{
B.Ok_W(L"Avec={L'
'}");
Avec.push_back(L"
");
Avec_role.push_back(L"");
break;
}
pos2 = a.find(L" : ");
if (pos2 == std::wstring::npos && pos != std::wstring::npos)
// Avec={XXX} et Avec_role={}
{
B.Ok_W(L"Avec={" + a.substr(0, pos - 1) + L"}, Avec_role={}");
Avec.push_back(a.substr(0, pos - 1));
Avec_role.push_back(L"");
}
else if (pos2 == 0)
// Avec={} et Avec_role={XXX}
{
B.Ok_W(L"Avec={}, Avec_role={" + a.substr(3, (pos - 1) - 2) + L'}');
Avec.push_back(L"");
Avec_role.push_back(a.substr(3, (pos - 1) - 2));
}
else if (pos > pos2)
// Avec et Avec_role
{
B.Ok_W(L"Avec={" + a.substr(0, pos2) + L"}, Avec_role={" + a.substr(pos2 + 3, pos - (pos2 + 3)) + L'}');
Avec.push_back(a.substr(0, pos2));
Avec_role.push_back(a.substr(pos2 + 3, pos - (pos2 + 3)));
}
else
{
// Rrrrrrrr !!! Pas de solution
B.Ok_W(L"Avec={" + a.substr(0, pos - 1) + L"}, Avec_role={}");
Avec.push_back(a.substr(0, pos - 1));
Avec_role.push_back(L"");
}
//
a = a.substr(pos + 1);
}
else
break;
}
#if afficher_Avec_ == 1
B.Ok_W(L"-- -- -- -- --");
std::wstring wstr = L"Avec et Avec_role={";
std::wstring& avec = Avec.back();
for (int i = 0; i < Avec.size(); i++)
{
if (Avec[i] == L"")
wstr += L"Pas de Avec ";
else
wstr += Avec[i] + L' ';
wstr += L'(' + Avec_role[i] + L')';
if (Avec[i] != avec)
{
wstr += L", ";
}
else
{
wstr += L'.';
}
}
B.Ok_W(wstr + L'}');
#endif
B.Ok_T(L"const int afficher_Avec() : Ok !");
return EXIT_SUCCESS;
}
else
return EXIT_SUCCESS;
}
// Ok ou pas ?
//a = afficher_fichier_lire(a, _T);
try
{
a = lire_fichierTxt(nomFichier);
}
catch (runtime_error const& exception)
{
std::wcout << L"Erreur : " << exception.what() << std::endl;
}
a = replace_all(a, L",", L" -");
a = replace_all(a, L"(", L"[");
a = replace_all(a, L")", L"]");
if (!a.empty())
{
a = a + L"\n";
while (pos = a.find(L"\n"))
{
if (a[0] != a.length())
{
Avec_role.push_back(a.substr(0, pos));
a = a.substr(pos + 1);
}
else
break;
}
#if afficher_Avec_ == 1
std::wstring wstr = L"Avec_role={";
/*for (iter = Avec_role.begin(), i = 0; iter != Avec_role.end(); iter++, i++)
{
wstr += *iter;
if (i != Avec_role.size() - 1)
wstr += L", ";
}*/
B.Ok_W(wstr + L'}');
#endif
}
#if afficher_Avec_ == 1
B.Ok_T(L"const int afficher_Avec() : Ok !");
#endif
return EXIT_SUCCESS;
} |