From a5d84208febbeada18b2de3ca4d5058cf54bf3ce Mon Sep 17 00:00:00 2001 From: shurik3313 Date: Tue, 31 Jan 2023 00:30:56 +0700 Subject: [PATCH] Version 1.0 --- CMakeLists.txt | 35 ++++++++++++++++++++++ main.cpp | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..cef5390 --- /dev/null +++ b/CMakeLists.txt @@ -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}) # подключаем библиотеку diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..9e1cf0e --- /dev/null +++ b/main.cpp @@ -0,0 +1,81 @@ +#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 ""; +} \ No newline at end of file