parent
4c929725aa
commit
a5d84208fe
@ -0,0 +1,81 @@
|
|||||||
|
#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 "";
|
||||||
|
}
|
||||||
Loading…
Reference in new issue