Commit 2deb5d87fbbeab5c3aa8a75a64a7bbb6e090e209

Authored by Jarryd Beck
0 parents

initial commit

CMakeLists.txt 0 → 100644
  1 +++ a/CMakeLists.txt
  1 +cmake_minimum_required(VERSION 2.6)
  2 +project(cxxopts)
  3 +
  4 +set(VERSION "0.0.1")
  5 +
  6 +add_subdirectory(src)
  7 +
src/CMakeLists.txt 0 → 100644
  1 +++ a/src/CMakeLists.txt
  1 +add_executable(cxxopts main.cpp)
  2 +
  3 +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
src/cxxopts.hpp 0 → 100644
  1 +++ a/src/cxxopts.hpp
  1 +#include <regex>
src/main.cpp 0 → 100644
  1 +++ a/src/main.cpp
  1 +#include <iostream>
  2 +
  3 +#include "cxxopts.hpp"
  4 +
  5 +int main(int argc, char* argv[])
  6 +{
  7 + try
  8 + {
  9 +
  10 + std::basic_regex<char> options("--([a-zA-Z][-a-zA-Z]+)|-([a-zA-Z]+)");
  11 + std::match_results<const char*> result;
  12 +
  13 + for (int i = 1; i < argc; ++i)
  14 + {
  15 + std::cout << "Argument " << i << std::endl;
  16 + std::regex_match(argv[i], result, options);
  17 + std::cout << "empty = " << result.empty() << std::endl;
  18 + std::cout << "size = " << result.size() << std::endl;
  19 +
  20 + std::cout << "matches:" << std::endl;
  21 + for (int j = 0; j != result.size(); ++j)
  22 + {
  23 + std::cout << result[j] << std::endl;
  24 + }
  25 + }
  26 +
  27 + } catch (const std::regex_error& e)
  28 + {
  29 + std::cout << "regex_error: " << e.what() << std::endl;
  30 + exit(1);
  31 + }
  32 +
  33 + return 0;
  34 +}