/
film.cpp
1365 lines (1271 loc) · 114 KB
/
film.cpp
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#define _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING
//#define _CRT_NONSTDC_NO_WARNINGS
//#define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES
//#pragma warning(disable : 4996)
//#define _CRT_SECURE_NO_WARNINGS
#include "pch.h"
#include "Utils.h"
#include "titre.h"
#include "You.h"
//#include "you_txt.h"
#include "serie.h"
#include "film.h"
#include "console.h"
#include "erreur_ok.h"
//#include "Bug.h"
#include <windows.h>
#include <cassert>
//#include <climits>
#include <algorithm>
#include <string>
#include <iostream>
//#include <sstream>
//#include <ctime>
#include <codecvt>
#include <vector>
/*#include <filesystem> // C++17 standard header file name
#include <experimental/filesystem> // Header file for pre-standard implementation
using namespace std;
using namespace std::experimental::filesystem::v1;*/
extern int X;
extern HANDLE hOut;
extern class Erreur E;
//extern class Bug B;
//extern const int afficher_Avec(std::wstring&, std::wstring const&, std::vector<std::wstring>&, std::vector<std::wstring>&);
extern const void afficher_Avec(std::wstring& a_filename, const std::wstring& nomFichier, std::vector<std::pair<std::wstring, std::wstring>>& avec);
extern const std::vector<std::wstring> lire_fichierTxt(std::wstring const& nomFichier, std::vector<std::wstring> separeteurs);
extern const std::vector<std::pair<std::wstring, std::wstring>>lire_paireCleValeur_depuisFichierTxt(std::wstring const& nomFichier, std::wstring separeteur);
extern const std::wstring lire_fichierTxt(std::wstring const& nomFichier);
extern const void Console_Lire_txt(std::wstring);
extern void Console_Lire(HANDLE hOut, const std::wstring& wstr, int taille_indentation, wchar_t);
//extern std::tm ParseDate(std::wstring& str);
extern void PrintAudiodescription(const std::wstring& ad, bool ad_, std::wstring& titre_T, std::wstring& titre_t);
extern void PrintGenres(const std::vector<std::wstring>& genres, bool genre_, const std::wstring& sous_genre, bool sous_genre_, std::wstring& titre_T, std::wstring& titre_t);
extern void PrintImages(const std::vector<std::wstring>& images, bool image_, std::wstring& titre_T, std::wstring& titre_t, int x1, int y1, int x2, int y2);
extern void PrintNationalites(const std::vector<std::wstring>& nationalites, bool nationalite_, std::wstring& titre_T, std::wstring& titre_t);
extern void PrintNetflixokounon(bool netflix_ok_ou_non, bool affichage_sur_actif, std::wstring& keyColor, std::wstring& valuesColor);
extern void PrintTitreOriginal(const std::vector<std::wstring>& titre_original, bool affichage_titre_original_actif, std::wstring& keyColor, std::wstring& valuesColor, std::wstring& keyColor2, std::wstring& valuesColor2);
extern bool checkyear(int y);
extern bool checkmonth(int m);
extern bool checkday(int m, int d, int y);
extern void test_date_year(int& year);
extern void test_date_month(int& month);
extern void test_date_day(int& day);
extern void test_date_tire(wchar_t d);
extern void test_date_tiret_sp_etc(wchar_t d);
Film::Film()
{
}
Film::~Film()
{
}
// ######################################################################################################################################################
// # #
// # afficher_dossier #
// # #
// ######################################################################################################################################################
const int Film::afficher_dossier(std::wstring const& t)
{
#if Film_afficher_dossier_ == true
B.Ok_T(L"const int Cinema::afficher_dossier(" + t + L") :");
#endif
int i = 0;
std::wstring t2;
std::size_t idx, idx2 = 0;
idx = t.find(L".(", 0);
t2 = t.substr(0, idx);
i = ::afficher_Titre(t2, titre, Titre_);
idx = t.find_last_of(L"(");
idx2 = t.find_last_of(L")");
if (idx2 - idx - 1 == 0)
return EXIT_FAILURE;
idx2--;
if (!(t.at(idx2) == L' ' || t.at(idx2) == L'-' ||
t.at(idx2) == L'0' || t.at(idx2) == L'1' || t.at(idx2) == L'2' || t.at(idx2) == L'3' || t.at(idx2) == L'4' ||
t.at(idx2) == L'5' || t.at(idx2) == L'6' || t.at(idx2) == L'7' || t.at(idx2) == L'8' || t.at(idx2) == L'9'))
{ // Sur
std::size_t idx3;
idx3 = t.find_first_of(L" ", idx);
idx3++;
t2 = t.substr(idx3, idx2 - idx3 + 1);
afficher_Sur(t2);
if (sur == t2)
{
E.afficher_X(-1, L"Sur !", L"Érreur (" + t2 + L") !!!");
return EXIT_FAILURE;
}
else
{
sur = t2;
//sur_ = true;
}
if (sur == L"Netflix")
netflix_ok_ou_non = true;
std::wcout << L"Sur={" << sur << L"}" << std::endl;
idx2 = idx3 - 2;
}
idx++;
if (t.at(idx2) == L' ' || t.at(idx2) == L'-' ||
t.at(idx2) == L'0' || t.at(idx2) == L'1' || t.at(idx2) == L'2' || t.at(idx2) == L'3' || t.at(idx2) == L'4' ||
t.at(idx2) == L'5' || t.at(idx2) == L'6' || t.at(idx2) == L'7' || t.at(idx2) == L'8' || t.at(idx2) == L'9')
{ // Date
t2 = t.substr(idx, idx2 - idx + 1);
//i = afficher_Date(t2, t);
afficher_Date(t2);
}
else
return i;
idx = t.find(L").");
if (idx != std::wstring::npos)
{ // Sous_Genre
idx = idx + 2;
sous_genre = t.substr(idx);
//wstring sous_genre = L"";
i = afficher_Sous_Genre(sous_genre);
affichage_sous_genre_actif = true;
}
return EXIT_SUCCESS;
}
// ######################################################################################################################################################
// # #
// # afficher_fichier #
// # const int Film::afficher_fichier(wstring const& _T, int const& _T_ = _TXT_) #
// # #
// ######################################################################################################################################################
const int Film::afficher_fichier(std::wstring const& nomFichier, int const& nomImage = TXT_)
{
int i = 0;
std::size_t pos;
pos = nomFichier.find_last_of(L"\\");
pos++;
std::wstring t = nomFichier.substr(pos);
if (nomImage == TXT_)
{
/* 0 1 2 3 4 5 6 7 8 9 */
if (t[0] == L'1' || t[0] == L'2' || t[0] == L'3')
{
afficher_Date_ou_Dates(t);
return EXIT_SUCCESS;
}
/* A B C D E F G H I J K L M N O P Q R S T U V W Y Z */
else
{
// AD : Audiodescription
if (t == L"AD.txt")
{
afficher_Audiodescription(t, nomFichier, audiodescription);
return EXIT_SUCCESS;
}
// Avec
if (L"Avec.txt" == t)
{
afficher_Avec(t, nomFichier, avec);
return EXIT_SUCCESS;
}
// Date de reprisé
if (t == L"Date de reprise.txt")
{
afficher_Date_de_reprise_ou_de_sortie(t, nomFichier);
return EXIT_SUCCESS;
}
// Date de sortie
if (t == L"Date de sortie.txt")
{
afficher_Date_de_reprise_ou_de_sortie(t, nomFichier);
return EXIT_SUCCESS;
}
// De
if (t == L"De.txt")
{
afficher_De(t, nomFichier, de);
return EXIT_SUCCESS;
}
// Distributeur
if (t == L"Distributeur.txt")
{
afficher_Distributeur(t, nomFichier);
return EXIT_SUCCESS;
}
// Genre
if (t == L"Genre.txt")
{
afficher_Genre(t, nomFichier, genre, ::Genre);
return EXIT_SUCCESS;
}
// Nationalité
if (t == L"Nationalité.txt")
{
afficher_Nationalite(t, nomFichier, nationalite, ::Nationalite);
return EXIT_SUCCESS;
}
// Netflix
if (t == L"Netflix.txt")
{
afficher_Netflix_SJ(t, nomFichier, netflix_sj);
return EXIT_SUCCESS;
}
// Note
if (t == L"Note.txt")
{
afficher_Note(t, nomFichier);
return EXIT_SUCCESS;
}
// Par
if (t == L"Par.txt")
{
afficher_Par(t, nomFichier, par);
return EXIT_SUCCESS;
}
// SJ
if (t == L"SJ.txt")
{
afficher_SJ(t, nomFichier, sj);
return EXIT_SUCCESS;
}
// Soundtrack
if (t == L"Soundtrack.txt")
{
afficher_Soundtrack(t, nomFichier);
return EXIT_SUCCESS;
}
// Titre
if (t == L"Titre.txt")
{
afficher_Titre(t, nomFichier);
return EXIT_SUCCESS;
}
// Titre original
if (t == L"Titre original.txt")
{
afficher_Titre_Original(t, nomFichier, titre_original);
return EXIT_SUCCESS;
}
// www.nautiljon.com
if (t == L"www.nautiljon.com.txt")
{
return EXIT_SUCCESS;
}
}
}
else if (nomImage == JGP_ || nomImage == PNG_ || nomImage == WEBP_)
{
afficher_Image(nomFichier, image);
return EXIT_SUCCESS;
}
else
{
E.afficher_X(-1, t, t + L" erreur (" + t + L") !!!");
return EXIT_FAILURE;
}
E.afficher_X(-1, t, t + L" erreur (" + t + L") !!!");
return EXIT_FAILURE;
}
// ######################################################################################################################################################
// # #
// # Date #
// # const void Film::afficher_Date(std::wstring& d) #
// # #
// ######################################################################################################################################################
const void Film::afficher_Date(std::wstring& d)
{ // Date
std::size_t pos = 0;
// year
int year = 0;
year = std::stoi(d, &pos);
try
{
test_date_year(year);
}
catch (exception_date_year e)
{
std::wcout << L"Exception a été capturée : " << e.get_message() << std::endl;
exit(1);
}
d = d.substr(4);
// date
try
{
test_date_tire(d[0]);
}
catch (exception_date_tiret e2)
{
std::wcout << L"Exception a été capturée : " << e2.get_message() << std::endl;
exit(1);
}
d = d.substr(1);
// mon
int mon = 0;
pos = 0;
mon = std::stoi(d, &pos);
try
{
test_date_month(mon);
}
catch (exception_date_month e3)
{
std::wcout << L"Exception a été capturée : " << e3.get_message() << std::endl;
exit(1);
}
d = d.substr(2);
// date
try
{
test_date_tire(d[0]);
}
catch (exception_date_tiret e2)
{
std::wcout << L"Exception a été capturée : " << e2.get_message() << std::endl;
exit(1);
}
d = d.substr(1);
// mday
int mday = 0;
mday = std::stoi(d, &pos);
try
{
test_date_day(mday);
}
catch (exception_date_day e4)
{
std::wcout << L"Exception a été capturée : " << e4.get_message() << std::endl;
exit(1);
}
//
date.tm_year = year - 1900;
date.tm_mon = mon - 1;
date.tm_mday = mday;
}
// ######################################################################################################################################################
// # #
// # afficher_Date_de_reprise_ou_de_sortie #
// # const void Film::afficher_Date_de_reprise_ou_de_sortie(std::wstring& d_filename, const std::wstring& nomFichier) #
// # #
// ######################################################################################################################################################
const void Film::afficher_Date_de_reprise_ou_de_sortie(std::wstring& d_filename, const std::wstring& nomFichier)
{ // Date de reprise
//assert((d_filename == createdBy_filename) && L"Erreur !!! Date de reprise... !");
std::wstring d = lire_fichierTxt(nomFichier);
std::size_t pos = 0;
// year
/*int year = 0;
year = std::stoi(d, &pos);
try
{
test_date_year(year);
}
catch (exception_date_year e)
{
std::wcout << L"Exception a été capturée : " << e.get_message() << std::endl;
exit(1);
}
d = d.substr(4);*/
int year = std::stoi(d);
// date_tire_sp_etc
try
{
test_date_tiret_sp_etc(d[0]);
}
catch (exception_date_tiret_sp_etc e2)
{
std::wcout << L"Exception a été capturée : " << e2.get_message() << std::endl;
exit(1);
}
d = d.substr(1);
// mon
int mon = 0;
pos = 0;
mon = std::stoi(d, &pos);
try
{
test_date_month(mon);
}
catch (exception_date_month e3)
{
std::wcout << L"Exception a été capturée : " << e3.get_message() << std::endl;
exit(1);
}
d = d.substr(2);
// date_tire_sp_etc
try
{
test_date_tiret_sp_etc(d[0]);
}
catch (exception_date_tiret_sp_etc e2)
{
std::wcout << L"Exception a été capturée : " << e2.get_message() << std::endl;
exit(1);
}
d = d.substr(1);
// mday
int mday = 0;
mday = std::stoi(d, &pos);
try
{
test_date_day(mday);
}
catch (exception_date_day e4)
{
std::wcout << L"Exception a été capturée : " << e4.get_message() << std::endl;
exit(1);
}
//
std::tm date;
date.tm_year = year - 1900;
date.tm_mon = mon - 1;
date.tm_mday = mday;
if (d_filename == L"Date de reprise.txt")
date_de_reprise = date;
else
date_de_sortie = date;
}
/*void Cinema::afficherDateRepriseOuSortie(std::wstring& d, const std::wstring& nomFichier)
{
//afficherDate(m_dateReprise != nullptr ? m_dateReprise : m_dateSortie);
assert((d_filename == createdBy_filename) && L"Erreur !!! date... !");
afficherDate(date_de_reprise != nullptr ? date_de_reprise : date_de_sortie);
}
void Cinema::afficherDate(const& myDate date)
{
//mise en forme d'une date selon les règles d'affichage ad hoc
// PrintTmp(...);
}*/
// ######################################################################################################################################################
// # #
// # afficher_Date_ou_Dates #
// # void Film::afficher_Date_ou_Dates() #
// # #
// ######################################################################################################################################################
void Film::afficher_Date_ou_Dates(std::wstring const& wstr)
{
assert(nomFichier.length() > 0 && L"Nom de fichier vide");
std::size_t pos;
pos = wstr.length();
std::wstring strRestant = wstr.substr(0, pos - 4);
assert(strRestant.length() > 9 && L"Nom de fichier trop court pour avoir au moins une date");
std::vector<DateRecord> dr;
std::wstring streaming = L"";
wchar_t sp = L' ', tiret = L'-', tiret_bas = L'_';
int y, m, d;
int firstYear = 0, firstMon = 0, firstDay = 0;
int i = 0;
do
{
if (strRestant[0] == sp)
{
if (strRestant[1] == std::wstring::npos || strRestant[1] == sp)
{
// try cath !!!
// Explique-moi ???
// ou :
exit(1);
}
strRestant = strRestant.substr(1);
// try cath !!!
// Explique-moi ???
// ou :
try // Erreur !!!
{
test_sp_et_npos_ou_pas_isblank(strRestant[0], isblank(strRestant[1]));
}
catch (exception_test_sp_et_npos_ou_pas_isblank e)
{
exit(1);
}
if (strRestant.length() > 0)
{
streaming = strRestant;
}
strRestant = L"";
break;
}
if (!isdigit(strRestant[0]))
{
// try cath !!!
// Explique-moi ???
// ou :
exit(1);
}
// year + mon + mday
if ((y = stoi(strRestant.substr(0, 4))) && checkyear(y)
&&
strRestant[4] == tiret
&&
(m = std::stoi(strRestant.substr(5, 2))) && checkmonth(m)
&&
strRestant[7] == tiret
&&
(d = std::stoi(strRestant.substr(8, 2))) && checkday(m, d, y)
&&
firstYear < y)
{
assert(firstYear < y && L"L'année aaaaa");
firstYear = y;
assert(firstMon < m && L"Le mois aaaaa");
firstMon = m;
assert(firstDay <= d && L"Le jours aaaaa");
firstDay = d;
dr.push_back(DateRecord{ 0 });
dr[i].date.tm_year = y - 1900;
dr[i].date.tm_mon = m - 1;
dr[i].date.tm_mday = d;
strRestant = strRestant.substr(10);
if (strRestant[0] == tiret_bas)
{
dr[i].someFlag = true;
strRestant = strRestant.substr(1);
}
i++;
continue;
}
// mon + mday
if ((m = std::stoi(strRestant.substr(0, 2))) && checkmonth(m)
&&
strRestant[2] == tiret
&&
(d = std::stoi(strRestant.substr(3, 2))) && checkday(m, d, firstYear)
&&
firstMon < m)
{
assert(firstMon < m && L"Le mois aaaaa");
firstMon = m;
dr.push_back(DateRecord{ 0 });
dr[i].date.tm_year = firstYear - 1900;
dr[i].date.tm_mon = m - 1;
dr[i].date.tm_mday = d;
assert(firstDay <= d && L"Le jours aaaaa");
firstDay = d;
strRestant = strRestant.substr(5);
if (strRestant[0] == tiret_bas)
{
dr[i].someFlag = true;
strRestant = strRestant.substr(1);
}
i++;
continue;
}
// mday
if ((d = std::stoi(strRestant.substr(0, 2))) && checkday(firstMon, d, firstYear)
&&
firstDay <= d)
{
firstDay = d;
assert(firstDay <= d && L"Le jours aaaaa");
dr.push_back(DateRecord{ 0 });
dr[i].date.tm_year = firstYear - 1900;
dr[i].date.tm_mon = firstMon - 1;
dr[i].date.tm_mday = d;
strRestant = strRestant.substr(2);
if (strRestant[0] == tiret_bas)
{
dr[i].someFlag = true;
strRestant = strRestant.substr(1);
}
i++;
continue;
}
// try cath !!!
// Explique-moi ???
// ou :
exit(1);
} while (strRestant.length() > 0);
date_ou_dates.push_back(make_pair(dr, streaming));
}
// ######################################################################################################################################################
// # #
// # afficher_De #
// # void Film::afficher_De(std::wstring& d_filename, std::wstring const& nomFichier, std::vector<std::wstring>&de) const #
// # #
// ######################################################################################################################################################
void Film::afficher_De(std::wstring& d_filename, std::wstring const& nomFichier, std::vector<std::wstring>&de) const
{
assert((d_filename == createdBy_filename) && L"Erreur !!! De... !");
de = lire_fichierTxt(nomFichier, { L"\n", L", " });
assert((de.size() != 0));
}
// ######################################################################################################################################################
// # #
// # afficher_Distributeur #
// # const int Film::afficher_Distributeur(std::wstring& d_filename, std::wstring const& nomFichier) #
// # #
// ######################################################################################################################################################
const void Film::afficher_Distributeur(std::wstring& d_filename, std::wstring const& nomFichier)
{ // Distributeur
assert((d_filename == createdBy_filename) && L"Erreur !!! Distributeur... !");
distributeur = lire_fichierTxt(nomFichier);
assert((distributeur.size() != 0));
}
// ######################################################################################################################################################
// # #
// # afficher_Par #
// # void Film::afficher_Par(std::wstring& p_filename, std::wstring const& nomFichier, std::vector<std::wstring>& par) const #
// # #
// ######################################################################################################################################################
void Film::afficher_Par(std::wstring& p_filename, std::wstring const& nomFichier, std::vector<std::wstring>& par) const
{
assert((p_filename == createdBy_filename) && L"Erreur !!! Par... !");
par = lire_fichierTxt(nomFichier, { L"\n", L", " });
assert((par.size() != 0));
}
// ######################################################################################################################################################
// # #
// # afficher_Note #
// # const void Film::afficher_Note(std::wstring& n_filename, std::wstring const& nomFichier) #
// # #
// ######################################################################################################################################################
const void Film::afficher_Note(std::wstring& n_filename, std::wstring const& nomFichier)
{ // 0...5 ou -1
std::wstring n = lire_fichierTxt(nomFichier);
std::size_t pos = n.length();
if (n == L"")
{
note = -1.0;
return;
}
if (pos != 1 && pos != 3)
{
E.afficher_X(-1, n, L"Pas de [a-z] et/ou [0-9] et/ou etc…");
return;
}
if (!iswdigit(n[0]))
{
E.afficher_X(-1, n, L"Pas de [a-z] et/ou etc…");
return;
}
if (!(n[0] == L'0' || n[0] == L'1' || n[0] == L'2' || n[0] == L'3' || n[0] == L'4' || n[0] == L'5'))
{
E.afficher_X(-1, n, L"Pas de [0-5]");
return;
}
if (pos == 1)
note = std::stod(n);
else
{
if ((n[1] == L',' || n[1] == L'.') && iswdigit(n[2]) && pos == 3)
{
//
n[1] = L',';
//
// Ok !!!
note = std::stod(n);
//
}
else
{
E.afficher_X(-1, n, L"Pas de…");
return;
}
}
return;
}
// ######################################################################################################################################################
// # #
// # Soundtrack #
// # const int afficher_Soundtrack(std::wstring& s_filename, const std::wstring& nomFichier) #
// # #
// ######################################################################################################################################################
const void Film::afficher_Soundtrack(std::wstring& s_filename, const std::wstring& nomFichier)
{
// utiliser les fonctions plus générique ("de plus bas niveau") pour avoir un code simple pour les fonction de plus "haut" niveau
// Il y a peut-être un peu de customisation pour gérer les "rôles" mais rien d'insurmontable
//std::vector<std::pair<std::wstring, std::wstring>> clevaleurs = lire_paireCleValeur_depuisFichierTxt(L"Soundtrack.txt", L" : ");
//Console::PrintStringW(Console::Ponctuation_Color + L"Soundtrack :" + console.End_Ln + L"\r\n");
//Console::PrintStringW(L"Soundtrack :" + L"\r\n");
//for (const auto& [cle, valeur] : clevaleurs) {
// Console::affiche_CleValeur(L"\t" + cle, valeur);
assert((s_filename == createdBy_filename) && L"Erreur !!! Soundtrack... !");
//par = lire_fichierTxt(nomFichier, { L"\n", L", " });
//std::vector<std::wstring> qqq = lire_fichierTxt(nomFichier, { L"\n", L", " });
//std::wcout << L"soundtrack :" << std::endl;
m_soundtrack = lire_paireCleValeur_depuisFichierTxt(nomFichier, L" : ");
//std::wcout << L"soundtrack : ok !" << std::endl;
assert((soundtrack.size() != 0));
}
// ######################################################################################################################################################
// # #
// # afficher_Titre #
// # #
// ######################################################################################################################################################
const void Film::afficher_Titre(std::wstring& t_filename, std::wstring const& nomFichier)
{ // Titre_1
assert((t_filename == createdBy_filename) && L"Erreur !!! Titre... !");
std::vector<std::wstring>t = lire_fichierTxt(nomFichier, { L"\n"});
std::size_t pos = 0;
assert(t.size() < 3 L"" && L"Erreur !!! Titre[0]... !");
::afficher_Titre(t[0], titre);
titre_ok = t[0];
//
bool titre_, h_min_;
titre_ = h_min_ = false;
h_min_ = ::afficher_Temps(t[1]);
if (!h_min_)
{
E.afficher_X(-1, t[1], t[1] + L" érreur (" + t[1] + L") !!!");
return;
}
titre.push_back(t[1]);
temps.tm_hour = std::stoi(t[1]);
temps.tm_min = std::stoi(t[1].substr(2));
t.erase(t.begin());
t.erase(t.begin());
std::wstring wstr;
for (auto&& ti : t)
wstr += ti + L'\n';
titre.push_back(wstr);
return;
}
/////////////////
// //////////////
// ######################################################################################################################################################
// # #
// # pas de OK #
// # const int Film::afficher_pas_de_OK() #
// # #
// ######################################################################################################################################################
const int Film::afficher_pas_de_OK() const
{
#if Film_afficher_pas_de_OK_ == 1
B.Ok_T(L"const int Cinema::afficher_pas_de_OK() :");
#endif
if (!affichage_genres_actif)
{
E.afficher_X(-1, L"Attention !", L"Erreur de Genre !!!");
#if Film_afficher_pas_de_OK_ == 1
B.Ok_W(L"Attention : Erreur de Genre !!!");
#endif
}
if (!affichage_nationalite_actif)
{
E.afficher_X(-1, L"Attention !", L"Erreur de Nationalité !!!");
#if Film_afficher_pas_de_OK_ == 1
B.Ok_W(L"Attention : Erreur de Nationalité !!!");
#endif
}
// Note
if (!affichage_note_actif)
{
E.afficher_X(-1, L"Attention !", L"Erreur de Note !!!");
#if Film_afficher_pas_de_OK_ == 1
B.Ok_W(L"Attention : Erreur de Note !!!");
#endif
}
// Titre
if (!Titre_)
{
E.afficher_X(-1, L"Attention !", L"Erreur de Titre !!!");
#if Film_afficher_pas_de_OK_ == 1
B.Ok_W(L"Attention : Erreur de Titre !!!");
#endif
}
#if Film_afficher_pas_de_OK_ == 1
B.Ok_T(L"const int Cinema::afficher_pas_de_OK() : Ok !");
#endif
return EXIT_SUCCESS;
}
// ######################################################################################################################################################
// # #
// # afficher #
// # const int Film::afficher() #
// # #
// ######################################################################################################################################################
const int Film::afficher()
{ // OK !
std::size_t pos = 0;
std::wstring wstr;
std::wstring Textes;
Console_Lire_txt(L"-~- ");
if (titre_ok == L"")
{
if (E.Ok())
Console_Lire_txt(L"-~- ");
return -1;
}
// Titre
PrintTitre();
// Date de reprise
PrintDatedeReprise();
// Date de sortie
PrintDatedeSortie();
// Titre original
PrintTitreOriginal(titre_original, affichage_titre_original_actif, keyColor[0], valuesColor, keyColor[1], valuesColor);
// Distributeur
PrintDistributeur();
// Audiodescription
PrintAudiodescription(audiodescription, affichage_audiodescription_actif, keyColor[0], valuesColor);
// Genre
PrintGenres(genre, affichage_genres_actif, sous_genre, affichage_sous_genre_actif, keyColor[0], valuesColor);
// De
PrintDe(de);
// Par
PrintPar(par);
// Avec
PrintAvec(avec);
// Nationalité(s)
PrintNationalites(nationalite, affichage_nationalite_actif, keyColor[0], valuesColor);
// Image
PrintImages(image, affichage_image_actif, keyColor[0], valuesColor, 0, 0, 0, 0);
// Netflix ?
PrintNetflixokounon(netflix_ok_ou_non, affichage_sur_actif, keyColor[0], valuesColor);
//
Console_Lire_txt(L"-~- ");
PrintTitre_sur_4();
// Date_ou_dates
if (PrintDate_ou_Dates())
Console_Lire_txt(L"-~- ");
// Avec
PrintAvec();
// Soundtrack
PrintSoundtracks();
if(affichage_avec_actif || affichage_soundtraks_actif)
Console_Lire_txt(L"-~- ");
int i = E.Ok();
return EXIT_SUCCESS;
}
// ######################################################################################################################################################
// # #
// # afficher_Temps_OK #
// # #
// ######################################################################################################################################################
const wstring Film::afficher_Temps_OK()
{ // h:mm
#if Film_afficher_Temps_OK_ == 1
#endif
wchar_t date_string[22];
wcsftime(date_string, 20, L"%H:%M", &temps);
std::wstring t = date_string;
std::size_t pos = t.find(L':');
std::wstring h = t.substr(1, pos - 1);
std::wstring m = t.substr(pos + 1);
std::wstring wstr = h;
if (F_Espace1)
wstr += L' ';
wstr += keyColor[0] + F_H + valuesColor;
if (F_Espace2)
wstr += L' ';
wstr += m;
if (F_Espace3)
wstr += L' ';
if (F_MIN != L"")
wstr += keyColor[0] + F_MIN + valuesColor;
#if Film_afficher_Temps_OK_ == 1
#endif
return wstr;
}
// ######################################################################################################################################################
// # #
// # #
// # #
// ######################################################################################################################################################
const int Film::Ok_F(bool P_F_Espace1, wchar_t P_F_H, bool P_F_Espace2, bool P_F_Espace3, std::wstring P_F_MIN, std::vector<std::wstring> F_keyColor, std::wstring F_valuesColor)
{
F_Espace1 = P_F_Espace1;
F_H = P_F_H;
F_Espace2 = P_F_Espace2;
F_Espace3 = P_F_Espace3;
F_MIN = P_F_MIN;
//keyColor.push_back(P_F_T);
//keyColor.push_back(P_F_W);
keyColor = F_keyColor;
valuesColor = F_valuesColor;
return EXIT_SUCCESS;
}
// ######################################################################################################################################################
// # #
// # PrintAvec #
// # const void Film::PrintAvec(std::vector<std::pair<std::wstring, std::wstring>>& avec) #
// # #
// ######################################################################################################################################################
const void Film::PrintAvec(std::vector<std::pair<std::wstring, std::wstring>>& avec)
{
if (affichage_avec_actif && avec.size())
{
// j ???
int j;
std::wstring avec_str = keyColor[0] + L"Avec : " + valuesColor;
std::vector<pair<std::wstring, std::wstring>>::iterator iter2;
for (iter2 = avec.begin(), j = 0; iter2 != avec.end(); iter2++)
{
if (
(j < (avec.size() - 1)
&&
(*iter2).first != L"")
)
{
avec_str += (*iter2).first;
j++;
}
if (j > 2)
break;
avec_str += keyColor[0] + L", " + valuesColor;
}
//Console_Lire(avec_str, 0, 0);
Console_Lire(hOut, avec_str + L"\r\n", 0, L' ');
}
}
// ######################################################################################################################################################
// # #
// # PrintAvec #
// # const void Film::PrintAvec() #
// # #
// ######################################################################################################################################################
const void Film::PrintAvec()
{
if (affichage_avec_actif && avec.size())
{
//Console_Lire(keyColor[0] + L"Avec :" + valuesColor + L"\r\n", 0, 0);
Console_Lire(hOut, keyColor[0] + L"Avec :" + valuesColor + L"\r\n", 0, L' ');// , 0);
std::wstring avec_str;
bool found = false;
for (auto&& [nom, role] : avec)
{
if (nom == L"…" || nom == L"..." || nom == L".")
{
found = true;
break;
}
if (nom != L"" && role != L"")
{
avec_str += nom + L' ' + keyColor[1] + L"(" + valuesColor + role + keyColor[1] + L")" + valuesColor;
}
else if (nom == L"" && role != L"")
{
avec_str += keyColor[1] + L"(" + valuesColor + role + keyColor[1] + L")" + valuesColor;
}
else
{