initial commit

This commit is contained in:
Jarryd Beck 2014-09-10 16:47:22 +10:00
commit 2deb5d87fb
4 changed files with 45 additions and 0 deletions

7
CMakeLists.txt Normal file
View File

@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 2.6)
project(cxxopts)
set(VERSION "0.0.1")
add_subdirectory(src)

3
src/CMakeLists.txt Normal file
View File

@ -0,0 +1,3 @@
add_executable(cxxopts main.cpp)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")

1
src/cxxopts.hpp Normal file
View File

@ -0,0 +1 @@
#include <regex>

34
src/main.cpp Normal file
View File

@ -0,0 +1,34 @@
#include <iostream>
#include "cxxopts.hpp"
int main(int argc, char* argv[])
{
try
{
std::basic_regex<char> options("--([a-zA-Z][-a-zA-Z]+)|-([a-zA-Z]+)");
std::match_results<const char*> 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;
}