Move cmdLineArgs lib to external
This commit is contained in:
@@ -1,28 +1,30 @@
|
||||
add_executable(main main.cpp cmdLineArgs.cpp)
|
||||
add_executable(main main.cpp)
|
||||
|
||||
# tell CMake to generate config.hpp
|
||||
configure_file (
|
||||
configure_file(
|
||||
"${PROJECT_SOURCE_DIR}/config.hpp.in"
|
||||
"${PROJECT_BINARY_DIR}/config.hpp"
|
||||
)
|
||||
)
|
||||
|
||||
add_subdirectory(TopTeamBedrijfssimulaties)
|
||||
#add_subdirectory(initial)
|
||||
#add_subdirectory(io)
|
||||
#add_subdirectory(parser)
|
||||
|
||||
# add_subdirectory(initial)
|
||||
# add_subdirectory(io)
|
||||
# add_subdirectory(parser)
|
||||
target_link_libraries(main
|
||||
PRIVATE
|
||||
TopTeamBedrijfssimulaties
|
||||
)
|
||||
TopTeamBedrijfssimulaties
|
||||
cmdLineArgs
|
||||
)
|
||||
|
||||
target_include_directories(TopTeamBedrijfssimulaties
|
||||
target_include_directories(TopTeamBedrijfssimulaties
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
${CMAKE_CURRENT_LIST_DIR}/TopTeamBedrijfssimulaties
|
||||
${PROJECT_BINARY_DIR}
|
||||
)
|
||||
|
||||
target_compile_options(main PRIVATE $<$<CONFIG:Debug>:
|
||||
${CMAKE_MAIN_SOURCE_DIR}/external/**
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
${CMAKE_CURRENT_LIST_DIR}/TopTeamBedrijfssimulaties
|
||||
${PROJECT_BINARY_DIR}
|
||||
)
|
||||
|
||||
target_compile_options(main PRIVATE $<$<CONFIG:Debug>:
|
||||
-Wall -Wextra -pedantic-errors -Wconversion -Wsign-conversion
|
||||
>)
|
||||
@@ -1,71 +0,0 @@
|
||||
#include "cmdLineArgs.hpp"
|
||||
|
||||
cmdLineArgs_c::cmdLineArgs_c(int argc, char *argv[])
|
||||
{
|
||||
for (int i = 0; i < argc; i++)
|
||||
{
|
||||
this->args.push_back(argv[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::string cmdLineArgs_c::get_option(
|
||||
const std::string &option_name)
|
||||
{
|
||||
for (auto it = this->args.begin(), end = this->args.end(); it != end; ++it)
|
||||
{
|
||||
if (*it == option_name)
|
||||
if (it + 1 != end)
|
||||
return *(it + 1);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
bool cmdLineArgs_c::has_option(
|
||||
const std::string &option_name)
|
||||
{
|
||||
for (auto it = this->args.begin(), end = this->args.end(); it != end; ++it)
|
||||
{
|
||||
if (*it == option_name)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void cmdLineArgs_c::setUsage(std::string usage)
|
||||
{
|
||||
this->usage = usage;
|
||||
}
|
||||
std::string cmdLineArgs_c::getUsage()
|
||||
{
|
||||
return this->usage;
|
||||
}
|
||||
|
||||
bool cmdLineArgs_c::available(
|
||||
const std::string &option_name,
|
||||
const std::string usage
|
||||
)
|
||||
{
|
||||
for (auto it = this->args.begin(), end = this->args.end(); it != end; ++it)
|
||||
{
|
||||
if (*it == option_name)
|
||||
return true;
|
||||
}
|
||||
debugWarnln("Missing option: " << option_name << " " << usage);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cmdLineArgs_c::available(
|
||||
const std::string &option_name
|
||||
)
|
||||
{
|
||||
for (auto it = this->args.begin(), end = this->args.end(); it != end; ++it)
|
||||
{
|
||||
if (*it == option_name)
|
||||
return true;
|
||||
}
|
||||
debugWarnln("Missing option: " << option_name << std::endl << "\t" << this->usage);
|
||||
return false;
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "debug.hpp"
|
||||
|
||||
class cmdLineArgs_c
|
||||
{
|
||||
public:
|
||||
cmdLineArgs_c(int argc, char *argv[]);
|
||||
std::string get_option(
|
||||
const std::string &option_name);
|
||||
bool has_option(
|
||||
const std::string &option_name);
|
||||
void setUsage(std::string usage);
|
||||
std::string getUsage();
|
||||
bool available(
|
||||
const std::string &option_name, const std::string usage);
|
||||
bool available(
|
||||
const std::string &option_name);
|
||||
|
||||
private:
|
||||
std::vector<std::string> args;
|
||||
std::string usage;
|
||||
};
|
||||
Reference in New Issue
Block a user