From d3eed666dd1396d0ca492d80e5c8dd64fe27cc4a Mon Sep 17 00:00:00 2001 From: VectorKappa Date: Thu, 15 Dec 2022 10:51:50 +0100 Subject: [PATCH] Aktualizacja makefila i poprawki --- Projekt/Doxyfile | 2 +- Projekt/Makefile | 4 +++ Projekt/main.cpp | 74 +++++++++++++++++++++++++++--------------------- 3 files changed, 47 insertions(+), 33 deletions(-) diff --git a/Projekt/Doxyfile b/Projekt/Doxyfile index f350dc2..67a1fbf 100644 --- a/Projekt/Doxyfile +++ b/Projekt/Doxyfile @@ -68,7 +68,7 @@ PROJECT_LOGO = # entered, it will be relative to the location where doxygen was started. If # left blank the current directory will be used. -OUTPUT_DIRECTORY = /home/vectorkappa/CODE/Polsl/PPK_LAB/427f5252-gr04-repo/Projekt/Dokumentacja +OUTPUT_DIRECTORY = ./Dokumentacja # If the CREATE_SUBDIRS tag is set to YES then doxygen will create up to 4096 # sub-directories (in 2 levels) under the output directory of each output format diff --git a/Projekt/Makefile b/Projekt/Makefile index 2a9bebf..c96b27e 100644 --- a/Projekt/Makefile +++ b/Projekt/Makefile @@ -1,2 +1,6 @@ build: g++ -Iinclude main.cpp + +clean: + rm -f a.out + rm -rf Dokumentacja diff --git a/Projekt/main.cpp b/Projekt/main.cpp index 7de5115..39b431a 100644 --- a/Projekt/main.cpp +++ b/Projekt/main.cpp @@ -10,20 +10,28 @@ Zapis ( -> : ), oznacza długość drogi j od klienta C do klienta D. Poszczególne drogi są rozdzielone przecinkami. Nie jest podana liczba dróg. Jeżeli nie jest możliwe wyznaczenie drogi, program zgłasza odpowiedni komunikat. Przykładowy plik wejściowy: -(1 - 2 : 4.5), (4 -> 3: -4.5), -(4 - 2: 0.4) +(1 - 2 : 4.5), (4 -> 3 : 4.5), (4 - 2 : 0.4) W pliku wynikowym należy zapisać drogę kuriera (kolejność odwiedzania klientów i długość drogi). Program uruchamiany jest z linii poleceń z potrzebnymi przełącznikami, natomiast -uruchomienie programu bez parametrów powoduje wypisanie krótkiej instrukcji **/ +uruchomienie programu bez parametrów powoduje wypisanie krótkiej instrukcji + + 1 2 3 4 +1 4.5 + +2 4.5 0.4 + +3 4.5 + +4 0.4 + +**/ #include #include #include #include cxxopts::Options options("Kurier", "Program rozwiązujący problem kuriera"); -char helpText[] = "To jest program rozwiązujący problem kuriera. Użycie: kurier -i [plik wejściowy] -o [plik wyjściowy]"; using namespace std; /** @@ -35,10 +43,9 @@ using namespace std; * * @return iterator pliku */ -int parseInput(char* inputFile){ - fopen(inputFile, "r"); - - return 0; +int parseInput(char* inputFile) { + fopen(inputFile, "r"); + return 0; } /** * @brief Główna funkcja. @@ -47,35 +54,38 @@ int parseInput(char* inputFile){ int main (int argc, char *argv[]) { - options.add_options() - ("d,debug", "Włącza tryb debugowania") // a bool parameter - ("h,help", "Pokazuje pomoc") // a bool parameter - ("i,input", "Nazwa pliku wejściowego", cxxopts::value()) - ("o,output", "Nazwa pliku wyjściowego", cxxopts::value()) - ("v,verbose", "Verbose output", cxxopts::value()->default_value("false")); + options.add_options() + ("d,debug", "Włącza tryb debugowania") // a bool parameter + ("h,help", "Pokazuje pomoc") // a bool parameter + ("i,input", "Nazwa pliku wejściowego", cxxopts::value()) + ("o,output", "Nazwa pliku wyjściowego", cxxopts::value()) + ("v,verbose", "Pokazuje tok działania programu", cxxopts::value()->default_value("false")); - auto result = options.parse(argc, argv); + auto result = options.parse(argc, argv); - - if (result.count("help") || argc == 1){ - std::cout << options.help() << std::endl; - exit(0); + // Jeżeli przełącznik -h jest ustawiony albo nie podano argumetów, wyświetla pomoc. + if (result.count("help") || argc == 1) { + std::cout << options.help() << std::endl; + exit(0); } bool debug = result["debug"].as(); - std::string plikWejsciowy; - if (result.count("input")) - plikWejsciowy = result["input"].as(); + string plikWejsciowy; + string plikWyjsciowy; + if (result.count("input") && result.count("output")) { + plikWejsciowy = result["input"].as(); + plikWyjsciowy = result["output"].as(); + } else { + std::cout << "Błąd 03 - nie podano wymaganych parametrów" << std::endl << options.help() << std::endl; + exit(3); + } + if (debug == true) { + for (int i = 0; i < argc; i++) { + std::cout << argv[i] << std::endl; + } + } - - - - if (debug == true) { - for (int i = 0; i < argc; i++) { - std::cout << argv[i] << std::endl; - } - } - return 0; + exit(0); }