-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlatin.h
722 lines (707 loc) · 27.6 KB
/
latin.h
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
//-----------------------------------------------------------------------
// Header : latin.h
// Last modified : 01.04.2023
// Version : 10
// Description : Contains main project classes, reference to
// functions in "latin.cpp" and global variables
//-----------------------------------------------------------------------
#ifndef LATIN_H_INCLUDED
#define LATIN_H_INCLUDED
//-----------------------------------------------------------------------
#include <iostream>
#include <fstream>
#include <conio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <ctime>
#include <chrono>
#include <map>
//-----------------------------------------------------------------------
typedef uint16_t uint;
namespace menuCode {
const int DEFAULT = 0, // Return to menu
DICTIONARYSEARCH = 1, // Start dictionarySearch with empty currentRequest
FORMANALYSIS = 2, // Start formanalysis with empty currentRequest
OUTPUTACTION = 3, // Start mainOutput.action
OUT_DICTIONARYSEARCH = 4, // Start dictionarySearch with not empty currentRequest
OUT_FORMANALYSIS = 5, // Start formAnalysis with not empty currentRequest
QUIT = -21; // End program
}
using namespace std;
//-----------------------------------------------------------------------
// Function declarations
//-----------------------------------------------------------------------
void dictionarySearch(string DICTIONARYLR_PATH, string DICTIONARYRL_PATH);
void formAnalysis();
void openFile(fstream& file, string path, ios::openmode mode, bool isLogNote);
int charToInt(char c);
string intToStr(int a, int len);
int inputInt();
// Put several chars/strings into one string
template <class T> string add(vector<T> vec) {
string result;
for (auto i : vec)
result += i;
return result;
}
//-----------------------------------------------------------------------
// Classes
//-----------------------------------------------------------------------
// Logging class
class Log {
private:
fstream file_;
string PATH_;
bool isStartNotepadLog_ = false;
public:
// Constructor opens file and starts logging
Log(string PATH) {
PATH_ = PATH;
file_.open(PATH_, ios::ate | ios::app);
if (file_.is_open() == false) {
file_.open(PATH_, ios::out);
}
auto start = std::chrono::system_clock::now();
auto legacyStart = std::chrono::system_clock::to_time_t(start);
char str[26];
ctime_s(str, sizeof str, &legacyStart);
file_ << "\n-#- Start processing -#-\n" << str << endl;
}
// Destructor ends logging and closes file
~Log() {
auto start = std::chrono::system_clock::now();
auto legacyStart = std::chrono::system_clock::to_time_t(start);
char str[26];
ctime_s(str, sizeof str, &legacyStart);
file_ << endl << "#-# Finish processing #-#\n" << str << endl;
file_.close();
if(isStartNotepadLog_ == true)
system("start notepad.exe log.txt");
}
// Prints single line to a log
void print(string message) {
file_ << message << endl;
}
// Set new isStartNotepadLog
// Default isStartNotepadLog = false
void setIsStartNotepadLog(bool b) {
isStartNotepadLog_ = b;
}
// Prints single line(a string given by its constituents) to a log
void print(vector<string> vMessage) {
file_ << add<string>(vMessage) << endl;
}
// Terminates the program with a message with exit code
void noteExit(int code) {
//mainOutput.writeData();
print({ "!!! Program finished with exit code: ", intToStr(code, 4) });
exit(code);
}
};
extern Log mainLog;
// Class for simpler menu console output
// Example:
// ConsoleOutputBlock("Select:", 5, {"First option", "Second option", "Esc - Third option"}, {1, 2, -1});
// | Select:
// | 1 - First option
// | 2 - Second option
// | Esc - Third option
class ConsoleOutputBlock {
private:
string headerMessage_;
vector<string> vMessages_;
vector<int> vNumbers_;
uint space_;
char filler_ = ' ';
public:
// vMessage and vNumbers sizes must be equal!
// Set number = -1 if you want to add atypical output
ConsoleOutputBlock(string headerMessage, uint space, vector<string> vMessages, vector<int> vNumbers) {
headerMessage_ = headerMessage;
space_ = space;
vMessages_ = vMessages;
vNumbers_ = vNumbers;
if (vNumbers.size() != vMessages.size()) {
vMessages_.resize(max(vNumbers.size(), vMessages.size()));
vNumbers_.resize(max(vNumbers.size(), vMessages.size()));
}
}
// Add new message and its number
void addMessage(string addedMesage, int addedNumber) {
vMessages_.push_back(addedMesage);
vNumbers_.push_back(addedNumber);
}
// Prints ConsoleOutputBlock (see example)
void print() {
if (headerMessage_.empty() == 0) {
cout << headerMessage_ << endl;
}
for (int i = 0; i < vMessages_.size(); i++) {
string spaceString;
spaceString.assign(space_, filler_);
if (vNumbers_[i] != -1)
cout << spaceString << vNumbers_[i] << " - " << vMessages_[i] << endl;
else
cout << spaceString << vMessages_[i] << endl;
}
}
// Sets new filler_
void setFiller(char c) {
filler_ = c;
}
// User input related to block
int inputChoice() {
char c = _getch();
return (int)(c)-48;
}
};
// Ñlass for user requests
class WordInfo {
public:
string word,
definition;
vector<string> forms;
int code;
// Compare two WordInfo, if word && (definitions || forms) are equal returns true,
// else returns false
friend bool operator==(const WordInfo wi1, const WordInfo wi2) {
if (wi1.word == wi2.word &&
(wi1.definition == wi2.definition || wi1.forms == wi2.forms))
return true;
else
return false;
}
// Clears WordInfo
void clear() {
mainLog.print("=G= currentRequest.word cleared");
word.clear();
definition.clear();
forms.clear();
}
// Checks if a WordInfo is empty
bool empty() {
if (word.empty() == true &&
definition.empty() == true &&
forms.empty() == true)
return true;
else
return false;
}
// Input new word by the user, if word is Latin - returns true,
// else - returns false
bool inputWord() {
cin >> word;
while (word[0] == ' ')
word.erase(word.begin());
bool isLat = ((int)(word[0]) >= 97 && (int)(word[0]) <= 122);
bool isRus = ((int)(word[0]) >= -32 && (int)(word[0]) <= -1);
if (isLat == isRus) {
cout << "Ñëîâî ââåäåíî íåêîððåêòíî, ïîâòîðèòå ââîä: ";
return inputWord();
}
else {
for (int i = 0; i < word.size(); i++) {
if (isLat == true) {
if ((int)(word[i]) < 97 || (int)(word[i]) > 122 == true) {
cout << "Ñëîâî ââåäåíî íåêîððåêòíî, ïîâòîðèòå ââîä: ";
return inputWord();
break;
}
}
if (isRus == true) {
if ((int)(word[i]) < -32 || (int)(word[i]) > -1 == true) {
cout << "Ñëîâî ââåäåíî íåêîððåêòíî, ïîâòîðèòå ââîä: ";
return inputWord();
break;
}
}
}
}
mainLog.print({ "=G= Input new currentRequest.word: ", word });
return isLat;
}
// Set .word members with logging
void setWord(string s) {
word = s;
mainLog.print({ "=G= Set new currentRequest.word: ", word });
}
// Set .definition with logging
void setDef(string s) {
definition = s;
mainLog.print({ "=G= Set new currentRequest.definition: ", definition });
}
// Set .forms with logging
void setForms(vector<string>& vStrings) {
forms = vStrings;
mainLog.print("=G= Set new currentRequest.forms");
}
// Set .code with logging
void setCode(int n) {
code = n;
mainLog.print({ "=G= Set new currentRequest.code: ", intToStr(code,0) });
}
// Add one line to forms
void addForm(string s) {
forms.push_back(s);
}
// Print forms
void printForms() {
if (forms.size() != 0) {
cout << "Info about forms:\n";
for (auto i : forms)
cout << i << endl;
}
}
// Print full WordInfo except code
void print() {
cout << endl;
if(word.empty() == false)
cout << "Word: " << word << endl;
if (definition.empty() == false)
cout << "Definition: " << definition << endl;
printForms();
}
};
extern WordInfo currentRequest;
// Class for actions with user dictionary
class OutputStream {
private:
vector<WordInfo> vWords_;
string PATH_;
vector<string> userNotes_;
// Reads data from a file
void readData() {
fstream file;
openFile(file, PATH_, ios::in, true);
string inputLine;
while (inputLine != "FILE_END" && file.eof() == false) {
getline(file, inputLine);
if (inputLine[0] == '#') {
WordInfo currWordInfo;
while (inputLine != "###") {
getline(file, inputLine);
if (inputLine.substr(0, 5) == "Word:") {
inputLine.erase(0, 5);
while (inputLine[0] == ' ')
inputLine.erase(inputLine.begin());
currWordInfo.word = inputLine;
continue;
}
if (inputLine.substr(0, 11) == "Definition:") {
inputLine.erase(0, 11);
while (inputLine[0] == ' ')
inputLine.erase(inputLine.begin());
currWordInfo.definition = inputLine;
continue;
}
if (inputLine.substr(0, 6) == "Forms:") {
inputLine.erase(0, 5);
while (inputLine != "###") {
getline(file, inputLine);
if (inputLine != "###")
currWordInfo.forms.push_back(inputLine);
}
continue;
}
}
vWords_.push_back(currWordInfo);
}
}
while (file.eof() == false) {
getline(file, inputLine);
if (inputLine != "Ìåñòî äëÿ çàìåòîê:")
userNotes_.push_back(inputLine);
}
file.close();
mainLog.print("= Data from user dictionary was read");
}
// Writes data to a file
void writeData() {
fstream file;
openFile(file, PATH_, ios::out, true);
for (int i = 0; i < vWords_.size(); i++) {
file << "\n# " << i + 1 << endl;
file << "Word: " << vWords_[i].word << endl;
if (vWords_[i].definition.empty() == false)
file << "Definition: " << vWords_[i].definition << endl;
if (vWords_[i].forms.empty() == false) {
file << "Forms:\n";
for (auto j : vWords_[i].forms) {
file << j << endl;
}
}
file << "###\n";
}
file << "\nFILE_END\nÌåñòî äëÿ çàìåòîê:\n";
for (auto i : userNotes_) {
file << i << endl;
}
file.close();
mainLog.print("= User dictionary file was rewrited");
}
// Ñhecks the validity of the file and creates it if it does not exist
void makeFile() {
fstream file;
file.open(PATH_, ios::in);
if (file.is_open() == false)
file.open(PATH_, ios::out);
file.close();
mainLog.print("= User dictionary file was made");
}
// Deletes the user-selected member of WordInfo
void deleteWordInfoElement(WordInfo& currWordInfo) {
mainLog.print("== Start of: OutputStream::deleteWordInfoElement");
const int WORD = 1,
DEFINITION = 2,
FORMS = 3;
currWordInfo.print();
ConsoleOutputBlock deleteMod("Âûáåðèòå ýëåìåíò, êîòîðûé õîòåëè áû óäàëèòü:", 5,
{ }, { });
if (currWordInfo.word.empty() == false)
deleteMod.addMessage("Ñëîâî", 1);
if (currWordInfo.definition.empty() == false)
deleteMod.addMessage("Îïðåäåëåíèå", 2);
if (currWordInfo.forms.empty() == false)
deleteMod.addMessage("Èíôîðìàöèÿ î ôîðìàõ", 3);
deleteMod.addMessage("Ëþáàÿ äðóãàÿ êëàâèøà - âûõîä", -1);
deleteMod.print();
switch (deleteMod.inputChoice()) {
case WORD: {
if (currWordInfo.word.empty() == false) {
currWordInfo.word.clear();
cout << "Ñëîâî óäàëåíî\n";
}
break;
}
case DEFINITION: {
if (currWordInfo.definition.empty() == false) {
currWordInfo.definition.clear();
cout << "Îïðåäåëåíèå óäàëåíî\n";
}
break;
}
case FORMS: {
if (currWordInfo.forms.empty() == false) {
currWordInfo.forms.clear();
cout << "Èíôîðìàöèÿ î ôîðìàõ óäàëåíà\n";
}
break;
}
}
mainLog.print("== End of: OutputStream::deleteWordInfoElement");
}
// Changes the user-selected member of WordInfo
void changeWordInfo(WordInfo& currWordInfo) {
mainLog.print("== Start of: OutputStream::changeWordInfo");
const int WORD = 1,
DEFINITION = 2,
FORMS = 3;
system("cls");
currWordInfo.print();
ConsoleOutputBlock changeMod("Âûáåðèòå ýëåìåíò, êîòîðûé õîòåëè áû èçìåíèòü èëè äîáàâèòü:", 5,
{ "Ñëîâî","Îïðåäåëåíèå ñëîâà","Ôîðìû ñëîâà","Ëþáàÿ äðóãàÿ êëàâèøà - âûõîä" }, { 1,2,3,-1 });
changeMod.print();
switch (changeMod.inputChoice()) {
case WORD: {
if (currWordInfo.word.empty() == false)
cout << "Òåêóùåå ñëîâî: " << currWordInfo.word
<< "\nÂâåäèòå íîâîå ñëîâî:\n";
else
cout << "Ñëîâî îòñóòñòâóåò, ââåäèòå íîâîå: ";
cin >> currWordInfo.word;
cout << "Íîâîå ñëîâî óñòàíîâëåíî, íàæìèòå ëþáóþ êëàâèøó, ÷òîáû âåðíóòüñÿ â ðåäàêòîð ñëîâàðÿ\n";
_getch();
break;
}
case DEFINITION: {
if (currWordInfo.definition.empty() == false)
cout << "Òåêóùåå îïðåäåëåíèå: " << currWordInfo.definition
<< "\nÂâåäèòå íîâîå îïðåäåëåíèå:\n";
else
cout << "Îïðåäåëåíèå îòñóòñòâóåò, ââåäèòå íîâîå: ";
cin >> currWordInfo.definition;
cout << "Íîâîå îïðåäåëåíèå óñòàíîâëåíî, íàæìèòå ëþáóþ êëàâèøó, ÷òîáû âåðíóòüñÿ â ðåäàêòîð ñëîâàðÿ\n";
_getch();
break;
}
case FORMS: {
int strNumber = -1;
const int ENDWHILE = 0;
while (strNumber != ENDWHILE) {
system("cls");
if (currWordInfo.forms.empty() == false) {
cout << "Òåêóùàÿ èíôîðìàöèÿ î ôîðìå ñëîâà:\n";
for (int i = 0; i < currWordInfo.forms.size(); i++) {
cout << i + 1 << ": " << currWordInfo.forms[i] << endl;
}
}
ConsoleOutputBlock selectAction("Íàæìèòå:", 5, { "äîáàâèòü ñòðîêó" }, { 1 });
if (currWordInfo.forms.empty() == false)
selectAction.addMessage("èçìåíèòü ñóùåñòâóþùóþ ñòðîêó", 2);
selectAction.addMessage("Ëþáàÿ äðóãàÿ êëàâèøà - âûéòè", -1);
selectAction.print();
char c = _getch();
if (c == '1') {
if (currWordInfo.forms.empty() == false) {
cout << "Ââåäèòå íîìåð ñòðîêè, ïîñëå êîòîðîé íóæíî äîáàâèòü ñòðîêó, èëè 0 äëÿ âûõîäà: ";
cin >> strNumber;
if (strNumber == ENDWHILE) { // Cycle breaker
break;
}
else if (strNumber < 1 || strNumber > currWordInfo.forms.size()) {
system("cls");
cout << "Íîìåð " << strNumber << " íå ÿâëÿåòñÿ äîïóñòèìûì çíà÷åíèì, ïîâòîðèòå ââîä...\n";
continue;
}
}
else
strNumber = 0;
cout << "Ââåäèòå íîâóþ ñòðîêó: ";
currWordInfo.forms.resize(currWordInfo.forms.size() + 1);
if(currWordInfo.forms.size() > 1)
for (int i = currWordInfo.forms.size() - 1; i >= strNumber; i--) {
currWordInfo.forms[i] = currWordInfo.forms[i - 1];
}
cin >> currWordInfo.forms[strNumber];
cout << "Äîáàâëåíà íîâàÿ ñòðîêà ñ íîìåðîì " << strNumber <<
", íàæìèòå 1 äëÿ ïðîäîëæåíèÿ ðàáîòû ñ ôîðìàìè èëè ëþáóþ äðóãóþ êëàâèøó äëÿ âîçâðàùåíèÿ â ðåäàêòîð ñëîâàðÿ\n";
strNumber = -1;
switch (_getch()) {
case '1':
continue;
default:
strNumber = ENDWHILE;
break;
}
}
if (c == '2') {
cout << "Ââåäèòå íîìåð ñòðîêè äëÿ èçìåíåíèÿ èëè 0 äëÿ âûõîäà: ";
cin >> strNumber;
if (strNumber == ENDWHILE) { // Cycle breaker
break;
}
else if (strNumber < 1 || strNumber > currWordInfo.forms.size()) {
system("cls");
cout << "Íîìåð " << strNumber << " íå ÿâëÿåòñÿ äîïóñòèìûì çíà÷åíèì, ïîâòîðèòå ââîä...\n";
continue;
}
else {
cout << "Ââåäèòå íîâîå çíà÷åíèå ñòðîêè " << strNumber << " (äëÿ óäàëåíèÿ ââåäèòå '000'): ";
cin >> currWordInfo.forms[strNumber - 1];
if (currWordInfo.forms[strNumber - 1] == "000")
currWordInfo.forms.erase(currWordInfo.forms.begin() + strNumber - 1);
cout << "Ñòðîêà ïîä íîìåðîì " << strNumber <<
" èçìåíåíà(óäàëåíà), íàæìèòå 1 äëÿ ïðîäîëæåíèÿ ðàáîòû ñ ôîðìàìè èëè ëþáóþ äðóãóþ êëàâèøó äëÿ âîçâðàùåíèÿ â ðåäàêòîð ñëîâàðÿ\n";
switch (_getch()) {
case '1':
continue;
default:
strNumber = ENDWHILE;
break;
}
}
}
break;
}
break;
}
default:
break;
}
mainLog.print("== End of: OutputStream::changeWordInfo");
}
// User makes new WordInfo and add it to vWords_
void makeNewWordInfo() {
mainLog.print("== Start of: OutputStream::makeNewWordInfo");
WordInfo currWordInfo;
cout << "Ââåäèòå ñëîâî: ";
currWordInfo.inputWord();
string s;
cout << "Ââåäèòå îïðåäåëåíèå ('-' â ñëó÷àå îòñóòñòâèÿ): ";
cin >> s;
if (s != "-")
currWordInfo.definition = s;
cout << "Ââåäèòå èíôîðìàöèþ î ôîðìàõ ('-' â ñëó÷àå îòñóòñòâèÿ):\n";
cin >> s;
while (s != "-") {
currWordInfo.addForm(s);
cin >> s;
}
vWords_.push_back(currWordInfo);
mainLog.print("== End of: OutputStream::makeNewWordInfo");
}
public:
// Set path to output file and read info form it
OutputStream(string PATH) {
PATH_ = PATH;
makeFile();
readData();
mainLog.print("=C OutputStream");
}
// Write finished vWords_ to file
~OutputStream() {
writeData();
mainLog.print("=D OutputStream");
}
// Clears file
void clear() {
vWords_.clear();
writeData();
mainLog.print("=G= OutputStream was cleared");
}
// Updates WordInfo in vWords_ using its number
// numWordInfo is a number of updated WordInfo
// numWordInfo = -1 if add new WordInfo at the end of vWords_ with replacement
// numWordInfo = -2 if add new WordInfo without relacement
void updateWordInfo(int numWordInfo, WordInfo &currWordInfo) {
if (numWordInfo == -1) {
if (vWords_.empty() == false && currWordInfo == vWords_[vWords_.size() - 1])
vWords_[vWords_.size() - 1] = currWordInfo;
else
vWords_.push_back(currWordInfo);
}
else if (numWordInfo == -2)
vWords_.push_back(currWordInfo);
else
vWords_[numWordInfo] = currWordInfo;
mainLog.print("== Happened: updateWordInfo");
}
// Function for user actions with a user dictionary
void action() {
mainLog.print("= Start of: mainOutput.action");
system("cls");
cout << "Îòêðûò ðåäàêòîð ñëîâàðÿ\n\n";
if (vWords_.empty() == true) {
cout << "Â äàííûé ìîìåíò ñëîâàðü ïóñò, íàæìèòå 1 - äëÿ äîáàâëåíèÿ íîâîãî ñëîâà\n" <<
" èëè ëþáóþ äðóãóþ êëàâèøó äëÿ âîçâðàùåíèÿ â ìåíþ\n";
currentRequest.setCode(0);
char c = _getch();
if (c == '1')
makeNewWordInfo();
else {
currentRequest.setCode(menuCode::DEFAULT);
return void();
}
}
for (int i = 0; i < vWords_.size(); i++) {
cout << "# " << i + 1;
vWords_[i].print();
}
const int DELETEWORDINFO = 1,
DELETEWORDINFOELEMENT = 2,
CHANGEWORDINFO = 3,
MAKENEWWORDINFO = 6,
CLEAROUTPUT = 7;
ConsoleOutputBlock editMod("\nÂûáåðèòå äåéñòâèå:", 5,
{ "Óäàëèòü âñþ èíôîðìàöèþ î ñëîâå","Óäàëèòü îòäåëüíûé ýëåìåíò èíôîðìàöèè î ñëîâå",
"Èçìåíèòü èíôîðìàöèþ î ñëîâå","Íàéòè ïåðåâîä âûáðàííîãî ñëîâà",
"Îïðåäåëèòü ôîðìó âûáðàííîãî ñëîâà", "Äîáàâèòü íîâîå ñëîâî", "Î÷èñòèòü ñëîâàðü",
"Ëþáàÿ äðóãàÿ êëàâèøà - Âûéòè èç ðåæèìà ðåäàêòèðîâàíèÿ" },
{ 1,2,3,4,5,6,7,-1 });
editMod.print();
switch (editMod.inputChoice()) {
case DELETEWORDINFO: {
cout << "Âûáåðèòå íîìåð ñëîâà äëÿ óäàëåíèÿ\n";
int numWordInfo = inputInt();
if (numWordInfo > 0 && numWordInfo <= vWords_.size())
vWords_.erase(vWords_.begin() + numWordInfo - 1);
else
cout << "Ââåä¸í íåêîððåêòíûé íîìåð\n";
break;
}
case DELETEWORDINFOELEMENT: {
cout << "Âûáåðèòå íîìåð ñëîâà äëÿ óäàëåíèÿ ýëåìåíòà\n";
int numWordInfo = inputInt();
if (numWordInfo > 0 && numWordInfo <= vWords_.size()) {
deleteWordInfoElement(vWords_[numWordInfo - 1]);
if (vWords_[numWordInfo - 1].empty() == true)
vWords_.erase(vWords_.begin() + numWordInfo - 1);
}
else
cout << "Ââåä¸í íåêîððåêòíûé íîìåð\n";
break;
}
case CHANGEWORDINFO: {
cout << "Âûáåðèòå íîìåð ñëîâà äëÿ èçìåíåíèÿ\n";
int numWordInfo = inputInt();
if (numWordInfo > 0 && numWordInfo <= vWords_.size())
changeWordInfo(vWords_[numWordInfo - 1]);
else
cout << "Ââåä¸í íåêîððåêòíûé íîìåð\n";
break;
}
case MAKENEWWORDINFO: {
makeNewWordInfo();
cout << "Äîáàâëåíî íîâîå ñëîâî:\n";
vWords_[vWords_.size() - 1].print();
break;
}
case menuCode::OUT_DICTIONARYSEARCH: {
while (true) {
cout << "Ââåäèòå íîìåð ñëîâà äëÿ ïîèñêà îïðåäåëåíèÿ\n";
int numWordInfo = inputInt();
if (numWordInfo == -1) // Cycle breaker
break;
if (numWordInfo > 0 && numWordInfo <= vWords_.size()) {
currentRequest = vWords_[numWordInfo - 1];
break;
}
else {
cout << "Ââåä¸í íåêîððåêòíûé íîìåð, ïîâòîðèòå ââîä èëè ââåäèòå -1 äëÿ âîçâðàùåíèÿ â ðåäàêòîð\n";
continue;
}
currentRequest.setCode(menuCode::OUT_DICTIONARYSEARCH);
return void();
}
break;
}
case menuCode::OUT_FORMANALYSIS: {
while (true) {
cout << "Ââåäèòå íîìåð ñëîâà äëÿ àíàëèçà ôîðìû\n";
int numWordInfo = inputInt();
if (numWordInfo == -1) // Cycle breaker
break;
if (numWordInfo > 0 && numWordInfo <= vWords_.size())
currentRequest = vWords_[numWordInfo - 1];
else {
cout << "Ââåä¸í íåêîððåêòíûé íîìåð, ïîâòîðèòå ââîä èëè ââåäèòå -1 äëÿ âîçâðàùåíèÿ â ðåäàêòîð\n";
continue;
}
if (currentRequest.word[0] < 0) {
cout << "Íåäîïóñòèìîå äëÿ àíàëèçà ôîðìû ñëîâî: âûáåðèòå ñëîâî, " <<
"ñîñòîÿùåå òîëüêî èç áóêâ ëàòèñíêîãî àëôàâèòà èëè -1 äëÿ âîçâðàùåíèÿ â ðåäàêòîð\n";
continue;
}
currentRequest.setCode(menuCode::OUT_FORMANALYSIS);
return void();
}
break;
}
case CLEAROUTPUT: {
clear();
cout << "Ñëîâàðü î÷èùåí, íàæìèòå ëþáóþ êëàâèøó, ÷òîáû âåðíóòüñÿ â ìåíþ\n";
_getch();
return void();
}
default: {
currentRequest.setCode(0);
writeData();
return void();
}
}
cout << "Íàæìèòå 1 äëÿ íîâîãî çàïðîñà èëè ëþáóþ äðóãóþ êëàâèøó äëÿ âûõîäà â ìåíþ\n";
char c = _getch();
if (c == '1')
currentRequest.setCode(menuCode::OUTPUTACTION);
else {
currentRequest.setCode(menuCode::DEFAULT);
}
writeData();
mainLog.print("= End of: mainOutput.action");
}
};
extern OutputStream mainOutput;
//-----------------------------------------------------------------------
#endif
//-----------------------------------------------------------------------