#include #include #include #include "opts.h" using namespace std; Option::Option(const string& str, function func) : m_void_func(func) { parse(str); } Option::Option(const string& str, function func) : m_func(func) { parse(str); } void Option::parse(const string& str) { auto iend = str.end(); if (*(iend - 1) == '=') { iend--; m_has_arg = 1; } else if (*(iend - 1) == '?') { iend--; m_has_arg = 2; } else { m_has_arg = 0; } auto isplit = find(str.begin(), iend, '|'); if (isplit != str.begin()) m_short = str[0]; else m_short = 0; if (isplit != iend) m_long = string(isplit + 1, iend); } OptionSet::OptionSet(initializer_list