| | |
| | | #include <string> |
| | | #include <algorithm> |
| | | #include <cstring> |
| | | #include <iostream> |
| | | #include <string> |
| | | #include <sstream> |
| | | |
| | | // 全局变量定义 |
| | | CPatternResult* g_pattern_results = nullptr; |
| | | CPatternResult* g_pattern_results = new (std::nothrow) CPatternResult(); |
| | | int g_pattern_count = 0; |
| | | |
| | | class Segment { |
| | |
| | | while (end != std::string::npos) |
| | | { |
| | | std::string token = input.substr(start, end - start); |
| | | trim_whitespace(token); |
| | | if (!token.empty()) result.push_back(token); |
| | | start = end + 1; |
| | | end = input.find('|', start); |
| | | } |
| | | |
| | | std::string last_token = input.substr(start); |
| | | trim_whitespace(last_token); |
| | | last_token = remove_colon(last_token); |
| | | if (!last_token.empty()) result.push_back(last_token); |
| | | return result; |
| | |
| | | if (end_pos == std::string::npos) break; |
| | | |
| | | std::string content = pattern.substr(pos + 1, end_pos - pos - 1); |
| | | trim_whitespace(content); |
| | | |
| | | Segment segment; |
| | | segment.is_variable = false; |
| | | segment.options = split_options(content); |
| | |
| | | if (end_pos == std::string::npos) break; |
| | | |
| | | std::string content = pattern.substr(pos + 1, end_pos - pos - 1); |
| | | trim_whitespace(content); |
| | | |
| | | Segment segment; |
| | | segment.variableSize += 1; |
| | |
| | | { |
| | | content = pattern.substr(pos); |
| | | } |
| | | trim_whitespace(content); |
| | | |
| | | if (!content.empty()) |
| | | { |
| | |
| | | while (end != std::string::npos) |
| | | { |
| | | std::string token = content.substr(start, end - start); |
| | | trim_whitespace(token); |
| | | |
| | | if (!token.empty()) |
| | | { |
| | | Segment segment; |
| | |
| | | end = content.find(':', start); |
| | | } |
| | | std::string last_token = content.substr(start); |
| | | trim_whitespace(last_token); |
| | | if (!last_token.empty()) |
| | | { |
| | | Segment segment; |
| | |
| | | return PatternParser::match_all_segments(inputList, segments) ? 1 : 0; |
| | | } |
| | | |
| | | CPatternResult *GetInstance() |
| | | { |
| | | return g_pattern_results; |
| | | } |