You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
1.8 KiB
81 lines
1.8 KiB
#include <iostream>
|
|
#include <string>
|
|
#include <fstream>
|
|
#include <boost/filesystem.hpp>
|
|
|
|
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 "";
|
|
} |