| 117 | } |
| 118 | |
| 119 | std::optional<int> CSeqConversionDefault::GetNextInteger(std::string_view &sv, bool Signed) const |
| 120 | { |
| 121 | re::svmatch m; |
| 122 | |
| 123 | if (m_bHex) { |
| 124 | static const std::regex HEX_RE {R"(^([\+-]?)[0-9A-Fa-f]+)", std::regex_constants::optimize}; |
| 125 | if (std::regex_search(sv.begin(), sv.end(), m, HEX_RE)) |
| 126 | if (!(Signed && !m[1].length())) |
| 127 | if (auto val = conv::to_int(re::sv_from_submatch(m[0]), 16)) { |
| 128 | sv.remove_prefix(std::distance(sv.begin(), m.suffix().first)); |
| 129 | return val; |
| 130 | } |
| 131 | } |
| 132 | else { |
| 133 | static const std::regex NUMBER_RE {R"(^([\+-]?)[0-9]+)", std::regex_constants::optimize}; |
| 134 | static const std::regex HEX_PREFIX_RE {R"(^([\+-]?)[\$x]([0-9A-Fa-f]+))", std::regex_constants::optimize}; // do not allow 0x prefix |
| 135 | if (std::regex_search(sv.begin(), sv.end(), m, HEX_PREFIX_RE)) { |
| 136 | if (!(Signed && !m[1].length())) |
| 137 | if (auto val = conv::to_int(re::sv_from_submatch(m[2]), 16)) { |
| 138 | if (m[1] == "-") |
| 139 | *val = -*val; |
| 140 | sv.remove_prefix(std::distance(sv.begin(), m.suffix().first)); |
| 141 | return val; |
| 142 | } |
| 143 | } |
| 144 | else if (std::regex_search(sv.begin(), sv.end(), m, NUMBER_RE)) { |
| 145 | if (!(Signed && !m[1].length())) |
| 146 | if (auto val = conv::to_int(re::sv_from_submatch(m[0]))) { |
| 147 | sv.remove_prefix(std::distance(sv.begin(), m.suffix().first)); |
| 148 | return val; |
| 149 | } |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | return std::nullopt; |
| 154 | } |
| 155 | |
| 156 | std::optional<int> CSeqConversionDefault::GetNextTerm(std::string_view &sv) |
| 157 | { |
nothing calls this directly
no test coverage detected