Initial commit. Created basic project structure, begun creating a cmake config and implemented the start of a command line argument parser
This commit is contained in:
+29
@@ -0,0 +1,29 @@
|
|||||||
|
# Compiled Object files
|
||||||
|
*.slo
|
||||||
|
*.lo
|
||||||
|
*.o
|
||||||
|
*.obj
|
||||||
|
|
||||||
|
# Precompiled Headers
|
||||||
|
*.gch
|
||||||
|
*.pch
|
||||||
|
|
||||||
|
# Compiled Dynamic libraries
|
||||||
|
*.so
|
||||||
|
*.dylib
|
||||||
|
*.dll
|
||||||
|
|
||||||
|
# Fortran module files
|
||||||
|
*.mod
|
||||||
|
*.smod
|
||||||
|
|
||||||
|
# Compiled Static libraries
|
||||||
|
*.lai
|
||||||
|
*.la
|
||||||
|
*.a
|
||||||
|
*.lib
|
||||||
|
|
||||||
|
# Executables
|
||||||
|
*.exe
|
||||||
|
*.out
|
||||||
|
*.app
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.5.2)
|
||||||
|
# Set the project name
|
||||||
|
project (concatenator)
|
||||||
|
|
||||||
|
set(Boost_USE_STATIC_LIBS OFF)
|
||||||
|
set(Boost_USE_MULTITHREADED ON)
|
||||||
|
set(Boost_USE_STATIC_RUNTIME OFF)
|
||||||
|
find_package(Boost 1.60.0 COMPONENTS program_options)
|
||||||
|
|
||||||
|
|
||||||
|
# Set build flags
|
||||||
|
set(CMAKE_CXX_FLAGS "-g -Wall")
|
||||||
|
# Set cmake to output executable to the bin directory
|
||||||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||||
|
|
||||||
|
include_directories(include)
|
||||||
|
|
||||||
|
# Find all the source fies in the src directory
|
||||||
|
file(GLOB SOURCES "src/*.cpp")
|
||||||
|
|
||||||
|
# Build the executable from the source files found
|
||||||
|
if(Boost_FOUND)
|
||||||
|
include_directories(${Boost_INCLUDE_DIRS})
|
||||||
|
add_executable(concatenator ${SOURCES})
|
||||||
|
target_link_libraries(concatenator ${Boost_LIBRARIES})
|
||||||
|
endif()
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include "boost/program_options.hpp"
|
||||||
|
|
||||||
|
namespace po = boost::program_options;
|
||||||
|
|
||||||
|
class ArgumentParser {
|
||||||
|
public:
|
||||||
|
ArgumentParser();
|
||||||
|
~ArgumentParser() {};
|
||||||
|
ArgumentParser(const ArgumentParser&);
|
||||||
|
ArgumentParser& operator=(const ArgumentParser&);
|
||||||
|
int parseargs(int argc, char** argv);
|
||||||
|
|
||||||
|
private:
|
||||||
|
//Create a positional options object for parsing input, output etc
|
||||||
|
//positional arguments from command line.
|
||||||
|
po::positional_options_description positionalOptions;
|
||||||
|
//
|
||||||
|
po::variables_map vm;
|
||||||
|
po::options_description desc;
|
||||||
|
};
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#include "argument_parser.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
ArgumentParser::ArgumentParser() : desc("Allowed options") {
|
||||||
|
positionalOptions.add("input_db", 1);
|
||||||
|
positionalOptions.add("output_db", 1);
|
||||||
|
|
||||||
|
|
||||||
|
desc.add_options()
|
||||||
|
("help,h", "produce help message")
|
||||||
|
("compression", po::value<int>(), "set compression level")
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ArgumentParser::parseargs(int argc, char** argv) {
|
||||||
|
po::store(po::command_line_parser(argc, argv).options(desc).positional(positionalOptions).run(), vm);
|
||||||
|
po::notify(vm);
|
||||||
|
|
||||||
|
// If help option is specified then output help message
|
||||||
|
if (vm.count("help")) {
|
||||||
|
cout << desc << "\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include "argument_parser.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
|
||||||
|
// Declare the supported options.
|
||||||
|
ArgumentParser argparse = ArgumentParser();
|
||||||
|
argparse.parseargs(argc, argv);
|
||||||
|
cout << "Hello world!" << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user