#include #include #include #include using namespace std; using namespace boost::filesystem; string parsingGame(string word); string parsingComment(string word); string (*parsing)(string word); //Возращает строку без первого символа string supStr(string str){ return str.assign(str, 1, str.length() -1) + " "; } int main() { setlocale(LC_ALL, "Russian"); //cout << "HelloWorld" << endl; const string nameDirSrc = "вход.txt"; const string nameDirDest = "выход.txt"; const path* dsrc = new path(nameDirSrc); const path* ddest = new path(nameDirDest); if(!exists(*dsrc)){ cout << "Файл (" + nameDirSrc + ") НЕ существует!" << endl; return 1; } if(!exists(*ddest)){ cout << "Файл (" + nameDirDest + ") НЕ существует!" << endl; return 1; } ifstream srcf{nameDirSrc}; if(!srcf){ cerr << "Ошибка прот открытии файла - " + nameDirSrc << endl; return 1; } ofstream outf{nameDirDest}; if(!outf){ cerr << "Ошибка прот открытии файла - " + nameDirDest << endl; return 1; } parsing = parsingGame; while(srcf){ string out; srcf >> out; outf << parsing(out); } return 0; } string parsingGame(string word){ switch (word[0]){ case 'K': return "Кр" + supStr(word); case 'Q': return "Ф" + supStr(word); case 'R': return "Л" + supStr(word); case 'N': return "К" + supStr(word); case 'B': return "С" + supStr(word); case 'p': return "п" + supStr(word); case '{': { parsing = parsingComment; return ""; } default: if(word.back() == '.') return word; return word + " "; } } string parsingComment(string word){ if(word[0] == '}') parsing = parsingGame; return ""; }