Mercurial > thymian
annotate 3rdparty/vmime/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-regex.cpp @ 0:a4671277546c tip
created the repository for the thymian project
| author | ferencd |
|---|---|
| date | Tue, 17 Aug 2021 11:19:54 +0200 |
| parents | |
| children |
| rev | line source |
|---|---|
| ferencd@0 | 1 #include <algorithm> |
| ferencd@0 | 2 #include <regex> |
| ferencd@0 | 3 |
| ferencd@0 | 4 int parse_line(std::string const& line) |
| ferencd@0 | 5 { |
| ferencd@0 | 6 std::string tmp; |
| ferencd@0 | 7 if(std::regex_search(line, std::regex("(\\s)+(-)?(\\d)+//(-)?(\\d)+(\\s)+"))) { |
| ferencd@0 | 8 tmp = std::regex_replace(line, std::regex("(-)?(\\d)+//(-)?(\\d)+"), std::string("V")); |
| ferencd@0 | 9 } else if(std::regex_search(line, std::regex("(\\s)+(-)?(\\d)+/(-)?(\\d)+(\\s)+"))) { |
| ferencd@0 | 10 tmp = std::regex_replace(line, std::regex("(-)?(\\d)+/(-)?(\\d)+"), std::string("V")); |
| ferencd@0 | 11 } else if(std::regex_search(line, std::regex("(\\s)+(-)?(\\d)+/(-)?(\\d)+/(-)?(\\d)+(\\s)+"))) { |
| ferencd@0 | 12 tmp = std::regex_replace(line, std::regex("(-)?(\\d)+/(-)?(\\d)+/(-)?(\\d)+"), std::string("V")); |
| ferencd@0 | 13 } else { |
| ferencd@0 | 14 tmp = std::regex_replace(line, std::regex("(-)?(\\d)+"), std::string("V")); |
| ferencd@0 | 15 } |
| ferencd@0 | 16 return static_cast<int>(std::count(tmp.begin(), tmp.end(), 'V')); |
| ferencd@0 | 17 } |
| ferencd@0 | 18 |
| ferencd@0 | 19 int main() |
| ferencd@0 | 20 { |
| ferencd@0 | 21 bool test = (parse_line("f 7/7/7 -3/3/-3 2/-2/2") == 3) && |
| ferencd@0 | 22 (parse_line("f 7//7 3//-3 -2//2") == 3) && |
| ferencd@0 | 23 (parse_line("f 7/7 3/-3 -2/2") == 3) && |
| ferencd@0 | 24 (parse_line("f 7 3 -2") == 3); |
| ferencd@0 | 25 return test ? 0 : 1; |
| ferencd@0 | 26 } |
