From 2deb5d87fbbeab5c3aa8a75a64a7bbb6e090e209 Mon Sep 17 00:00:00 2001 From: Jarryd Beck Date: Wed, 10 Sep 2014 16:47:22 +1000 Subject: [PATCH] initial commit --- CMakeLists.txt | 7 +++++++ src/CMakeLists.txt | 3 +++ src/cxxopts.hpp | 1 + src/main.cpp | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 src/CMakeLists.txt create mode 100644 src/cxxopts.hpp create mode 100644 src/main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..dc82487 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.6) +project(cxxopts) + +set(VERSION "0.0.1") + +add_subdirectory(src) + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..09162e3 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,3 @@ +add_executable(cxxopts main.cpp) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall") diff --git a/src/cxxopts.hpp b/src/cxxopts.hpp new file mode 100644 index 0000000..7e3936a --- /dev/null +++ b/src/cxxopts.hpp @@ -0,0 +1 @@ +#include diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..6f6a6f9 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,34 @@ +#include + +#include "cxxopts.hpp" + +int main(int argc, char* argv[]) +{ + try + { + + std::basic_regex options("--([a-zA-Z][-a-zA-Z]+)|-([a-zA-Z]+)"); + std::match_results result; + + for (int i = 1; i < argc; ++i) + { + std::cout << "Argument " << i << std::endl; + std::regex_match(argv[i], result, options); + std::cout << "empty = " << result.empty() << std::endl; + std::cout << "size = " << result.size() << std::endl; + + std::cout << "matches:" << std::endl; + for (int j = 0; j != result.size(); ++j) + { + std::cout << result[j] << std::endl; + } + } + + } catch (const std::regex_error& e) + { + std::cout << "regex_error: " << e.what() << std::endl; + exit(1); + } + + return 0; +}