Version 1.0

main
parent 4c929725aa
commit a5d84208fe

@ -0,0 +1,35 @@
cmake_minimum_required(VERSION 3.25.1s)
project(myproject)
set (CMAKE_CXX_STANDARD 17)
set (Boost_NO_SYSTEM_PATHS ON)
set (BOOST_ROOT "C:/Boost/") # Путь к библиотеке Boost
set (BOOST_INCLUDEDIR "D:/libs/boost_1_81_0/bin/include/")
set (BOOST_LIBRARYDIR "C:/Boost/lib/")
set (Boost_DEBUG OFF)
set (Boost_NO_WARN_NEW_VERSIONS ON)
set (Boost_USE_STATIC_LIBS ON) # only find static libs
set (Boost_USE_DEBUG_LIBS OFF) # ignore debug libs and
set (Boost_USE_RELEASE_LIBS ON) # only find release libs
set (Boost_USE_MULTITHREADED ON)
set (Boost_USE_STATIC_RUNTIME OFF)
#set (BOOST_ALL_DYN_LINK OFF)
# Подключаем необходимые модули. Для примера подключим program_options
find_package (Boost 1.81.0 COMPONENTS REQUIRED ALL )
message(STATUS -----Boost_FOUND = ${Boost_FOUND})
message(STATUS -----BOOST_ROOT = ${BOOST_ROOT})
message(STATUS -----Boost_INCLUDE_DIRS = ${Boost_INCLUDE_DIRS})
message(STATUS -----Boost_LIBRARY_DIRS = ${Boost_LIBRARY_DIRS})
message(STATUS -----Boost_LIBRARIES = ${Boost_LIBRARIES})
message(STATUS -----Boost_VERSION_STRING = ${Boost_VERSION_STRING})
message(STATUS -----BOOST_ROOT = ${BOOST_ROOT})
include_directories (SYSTEM ${Boost_INCLUDE_DIR}) # подключаем заголовочные файлы
add_executable(chessEncode main.cpp)
target_link_libraries (chessEncode ${Boost_LIBRARIES}) # подключаем библиотеку

@ -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…
Cancel
Save